AWS CDK で Infrastructure as Code にチャレンジ! 合同勉強会 in 大都会岡山 – 2021 Summer Online - LT 2021.09.04
© 2021, Amazon Web Services, Inc. or its Affiliates. All rights reserved.アマゾン ウェブ サービス ジャパン株式会社ソリューションアーキテクト藤原 吉規 @twingo_bAWS CDK で Infrastructure asCode にチャレンジ︕合同勉強会 in ⼤都会岡⼭ – 2021 Summer Online - LT2021.09.04
View Slide
© 2021, Amazon Web Services, Inc. or its Affiliates. All rights reserved.AWS の環境を構築するには
© 2021, Amazon Web Services, Inc. or its Affiliates. All rights reserved.⼿動操作(マネジメントコンソール)〇 始めるのは簡単× 繰り返し可能ではない× エラーが起きやすい× 時間がかかるHighlevelLowlevelManual管理レベル操作⼿順書が別途必要
© 2021, Amazon Web Services, Inc. or its Affiliates. All rights reserved.スクリプト (SDK, CLI)︖ APIコールが失敗したら何が起こる︖︖どうやってアップデートする︖︖リソースが準備完了なのはどうやって知る︖︖どうやってロールバックする︖ScriptedManualHighlevelLowlevel管理レベル操作⼿順の定義が可能
© 2021, Amazon Web Services, Inc. or its Affiliates. All rights reserved.プロビジョニング ツール (CloudFormation など)AWS CloudFormation テンプレート(JSON/YAML)HashiCorpConfigurationLanguage (HCL)あるべき状態の定義が可能DeclarativeScriptedManualHighlevelLowlevel〇⾃動化が容易〇再⽣成可能× ツール固有の記述⽅式× 抽象化なし、詳細な記述管理レベルCloudFormationやTerraformでデプロイ
© 2021, Amazon Web Services, Inc. or its Affiliates. All rights reserved.Document Object Models (DOMs)Troposphere PythonSparkleFormation RubyGoFormation Go…if⽂、for ループ、IDE利⽤可能例えば、TroposphereでVPCを作成するには128⾏必要〇 リアルコード〇 あるべき状態の定義× 抽象化は組み込まれていないDOMsDeclarativeScriptedManualHighlevelLowlevel管理レベルCFnでデプロイCFnテンプレートの⽣成あるべき状態の定義がコードで可能
© 2021, Amazon Web Services, Inc. or its Affiliates. All rights reserved.AWS CDK ApplicationStack(s)Construct ConstructAWS CDKComponentizedDOMsDeclarativeScriptedManualHighlevelLowlevel管理レベルコードであるべき状態を定義CFnでデプロイCFnテンプレートの⽣成あるべき状態の定義がコードで可能+抽象化(Developer preview)Java
© 2021, Amazon Web Services, Inc. or its Affiliates. All rights reserved.AWS CDK で構築を⾼速に
© 2021, Amazon Web Services, Inc. or its Affiliates. All rights reserved.AWS CDK で構築を⾼速に• リファレンスの参照回数と試⾏錯誤が格段に少なくなる• 型定義(TypeScript)とエディタによるサジェスト• リソース間の依存関係把握が楽(オブジェクト指向)• CDK diff とテストによるチェック• 記述の絶対量が⼩さい• 最低限のパラメータ指定でリソースを作れる• つまり他⼈のコードを読むのも楽• ⼀括タグ付けなどの便利機能• 開発者を集めやすい• アプリケーション開発者が始めやすい
© 2021, Amazon Web Services, Inc. or its Affiliates. All rights reserved.S3バケットのコードサジェスト:必須プロパティ(?なし)オプションプロパティ(?あり)サジェスト︓型がわかる⽂字列でなく ENUM で指定L2 Constructは少ないプロパティで複数のリソースをまとめて構成可能VPC作成のコード複雑なものはコンストラクタでなくメソッドで追加する
© 2021, Amazon Web Services, Inc. or its Affiliates. All rights reserved.AWS CDK の主なコンポーネントAuto ScalingCDK を構成する基本要素 CDK アプリケーションの基本要素クラウドコンポーネントを表すCDK アプリケーションを操作するツールCloudFormation テンプレートを⽣成・デプロイする
© 2021, Amazon Web Services, Inc. or its Affiliates. All rights reserved.デモ
© 2021, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
© 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
© 2021, Amazon Web Services, Inc. or its Affiliates. All rights reserved.© 2021, Amazon Web Services, Inc. or its Affiliates. All rights reserved.Thank You!