$30 off During Our Annual Pro Sale. View Details »

Try Infrastructure as Code with AWS CDK!

@twingo_b
September 04, 2021

Try Infrastructure as Code with AWS CDK!

AWS CDK で Infrastructure as Code にチャレンジ!
合同勉強会 in 大都会岡山 – 2021 Summer Online - LT
2021.09.04

@twingo_b

September 04, 2021
Tweet

More Decks by @twingo_b

Other Decks in Technology

Transcript

  1. © 2021, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
    アマゾン ウェブ サービス ジャパン株式会社
    ソリューションアーキテクト
    藤原 吉規 @twingo_b
    AWS CDK で Infrastructure as
    Code にチャレンジ︕
    合同勉強会 in ⼤都会岡⼭ – 2021 Summer Online - LT
    2021.09.04

    View Slide

  2. © 2021, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
    AWS の環境を構築するには

    View Slide

  3. © 2021, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
    ⼿動操作(マネジメントコンソール)
    〇 始めるのは簡単
    × 繰り返し可能ではない
    × エラーが起きやすい
    × 時間がかかる
    High
    level
    Low
    level
    Manual
    管理レベル
    操作⼿順書が別途必要

    View Slide

  4. © 2021, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
    スクリプト (SDK, CLI)
    ︖ APIコールが失敗したら何が起こる︖
    ︖どうやってアップデートする︖
    ︖リソースが準備完了なのはどうやって知る︖
    ︖どうやってロールバックする︖
    Scripted
    Manual
    High
    level
    Low
    level
    管理レベル
    操作⼿順の定義が可能

    View Slide

  5. © 2021, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
    プロビジョニング ツール (CloudFormation など)
    AWS CloudFormation テ
    ンプレート
    (JSON/YAML)
    HashiCorp
    Configuration
    Language (HCL)
    あるべき状態の定義が可能
    Declarative
    Scripted
    Manual
    High
    level
    Low
    level
    〇⾃動化が容易
    〇再⽣成可能
    × ツール固有の記述⽅式
    × 抽象化なし、詳細な記述
    管理レベル
    CloudFormationや
    Terraformで
    デプロイ

    View Slide

  6. © 2021, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
    Document Object Models (DOMs)
    Troposphere Python
    SparkleFormation Ruby
    GoFormation Go

    if⽂、for ループ、IDE利⽤可能
    例えば、TroposphereでVPCを作成するには128⾏必要
    〇 リアルコード
    〇 あるべき状態の定義
    × 抽象化は組み込まれていない
    DOMs
    Declarative
    Scripted
    Manual
    High
    level
    Low
    level
    管理レベル
    CFnで
    デプロイ
    CFn
    テンプレート
    の⽣成
    あるべき状態の定義がコードで可能

    View Slide

  7. © 2021, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
    AWS CDK Application
    Stack(s)
    Construct Construct
    AWS CDK
    Componentized
    DOMs
    Declarative
    Scripted
    Manual
    High
    level
    Low
    level
    管理レベル
    コードであるべき状態を定義
    CFnで
    デプロイ
    CFn
    テンプレート
    の⽣成
    あるべき状態の定義がコードで可能+抽象化
    (Developer preview)
    Java

    View Slide

  8. © 2021, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
    AWS CDK で構築を⾼速に

    View Slide

  9. © 2021, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
    AWS CDK で構築を⾼速に
    • リファレンスの参照回数と試⾏錯誤が格段に少なくなる
    • 型定義(TypeScript)とエディタによるサジェスト
    • リソース間の依存関係把握が楽(オブジェクト指向)
    • CDK diff とテストによるチェック
    • 記述の絶対量が⼩さい
    • 最低限のパラメータ指定でリソースを作れる
    • つまり他⼈のコードを読むのも楽
    • ⼀括タグ付けなどの便利機能
    • 開発者を集めやすい
    • アプリケーション開発者が始めやすい

    View Slide

  10. © 2021, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
    S3バケットのコード
    サジェスト:
    必須プロパティ(?なし)
    オプションプロパティ(?あり)
    サジェスト︓
    型がわかる
    ⽂字列でなく ENUM で指定
    L2 Constructは
    少ないプロパティで
    複数のリソースを
    まとめて構成可能
    VPC作成のコード
    複雑なものは
    コンストラクタでなく
    メソッドで追加する

    View Slide

  11. © 2021, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
    AWS CDK の主なコンポーネント
    Auto Scaling
    CDK を構成する基本要素 CDK アプリケーションの基本要素
    クラウドコンポーネントを表す
    CDK アプリケーションを操作するツール
    CloudFormation テンプレートを
    ⽣成・デプロイする

    View Slide

  12. © 2021, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
    デモ

    View Slide

  13. © 2021, Amazon Web Services, Inc. or its Affiliates. All rights reserved.

    View Slide

  14. © 2021, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
    AWS CDK ドキュメントとワークショップ
    • [AWS Black Belt Online Seminar] AWS CDK
    • PDF: LINK
    • YouTube: LINK
    • GitHub: LINK
    • APIリファレンス: LINK
    • Developer Guide: LINK
    • Roadmap: LINK
    • RFCs: LINK
    • ワークショップ: LINK

    View Slide

  15. © 2021, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
    © 2021, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
    Thank You!

    View Slide