Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Sign up for free
Menu
Search
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Pricing
Search
Sign in
Sign up for free
AWSインフラのデプロイをCDKでカイゼンする/2022-03-23-llt25
Search
Sponsored
·
Ship Features Fearlessly
Turn features on and off without deploys. Used by thousands of Ruby developers.
→
Satoshi SAKAO
March 23, 2022
Programming
130
0
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
AWSインフラのデプロイをCDKでカイゼンする/2022-03-23-llt25
社内のLTイベント「えるLT Vol.25 オンライン」で発表した資料です
Satoshi SAKAO
March 23, 2022
More Decks by Satoshi SAKAO
See All by Satoshi SAKAO
Testcontainers/2024-11-20-llt32
ottijp
0
120
Pkl/2024-04-17-llt31
ottijp
0
140
JavaScriptのデバッグ/2023-09-04-llt30
ottijp
0
200
CDK for TerraformでAzureリソースをデプロイする/2023-05-15-llt29
ottijp
1
360
TWELITEへの誘い/2022-12-27-llt28
ottijp
0
190
ビルドツールBazelを触ってみた/2022-09-28-llt27
ottijp
0
230
HashiCorp Vaultを使ったシークレットのセキュアな一元管理 〜Ansibleを添えて〜/2022-07-12-llt26
ottijp
0
190
Amazon Timestreamでデータ補間/2021-12-27-llt24
ottijp
0
130
ncurses/2021-05-12-llt21
ottijp
0
250
Other Decks in Programming
See All in Programming
AIで開発が速くなった先で、開発チームは何を目指すか
shihochan
1
1.7k
パスワード再設定メールのURLについて知っておこう
uyuki234
0
170
Kotlinの15年とServer-Side Kotlin
n_takehata
1
160
Optunaを作ったときにやりたかったこと、その後 (2026/10/16, Optuna Meetup #3)
iwiwi
2
1.1k
エージェントを使い続けるためのメタワーク / Meta-work for keeping using the agent
rkaga
3
1k
AmebaブログはKMPから卒業します
kmars0605
0
210
Lambda durable functionsでHuman in the Loopを楽に…楽に……
har1101
0
150
PumaからFalconに移行したRailsアプリケーションでの実践
falcon8823
0
190
SalesForceを内製化!? ~ HR事業を支える顧客管理基盤のインフラを大公開 ~
oku053
0
190
ソニーのクラウド共通基盤の変遷とAI時代の開発スタイルに合わせた進化 / The Journey of Sony’s Common Cloud Platform and Its Evolution for AI-Native Development
kenjiyoneyama
0
290
【加筆修正版】Laravel のアプリケーションをどこにデプロイするか #phpcon_ehime
akase244
0
150
AIに “答え“を書かせるのを やめてみた
___akari11
0
120
Featured
See All Featured
The Psychology of Web Performance [Beyond Tellerrand 2023]
tammyeverts
49
3.6k
Technical Leadership for Architectural Decision Making
baasie
3
600
How People are Using Generative and Agentic AI to Supercharge Their Products, Projects, Services and Value Streams Today
helenjbeal
2
370
The Invisible Side of Design
smashingmag
301
52k
How to Ace a Technical Interview
jacobian
280
24k
Groundhog Day: Seeking Process in Gaming for Health
codingconduct
0
430
Building Flexible Design Systems
yeseniaperezcruz
330
41k
The untapped power of vector embeddings
frankvandijk
2
1.9k
Let's Do A Bunch of Simple Stuff to Make Websites Faster
chriscoyier
508
140k
Practical Tips for Bootstrapping Information Extraction Pipelines
honnibal
25
2.1k
YesSQL, Process and Tooling at Scale
rocio
174
15k
Imperfection Machines: The Place of Print at Facebook
scottboms
270
14k
Transcript
AWSインフラのデプロイをCDKでカイゼンする Satoshi SAKAO えるLT Vol.25 2022-03-23 1
話すひと 2 🏢 インフォコム株式会社 品質マネジメント推進室 👨🔧 ソフトウェアエンジニア 🛠 Node.js /
AWS / IoT / iOS (Swift) 💖 猫,テクテクライフ(ランク: 24) Satoshi SAKAO @ottijp
3 3 months have passed
Disclaimer • CloudFormationの話が出てきますが, 実はほとんど触ったことがないので, 多少間違っている部分があるかも. 間違ってたら誠にごめんなさい. 4
AWSインフラのデプロイ方法 • マネジメントコンソール • CLI, SDK • CloudFormation • CDK
(Cloud Development Kit) 5
AWSインフラのデプロイ方法 6 マネジメント コンソール CLI, SDK Cloud- Formation CDK GUI
x IaCʢ܁Γฦ͠ੑ, ࠶ݱੑʣ x x x એݴతΞϓϩʔν ϦιʔεηοτʢStackͷཧʣ x x ߴϨϕϧͳఆٛ x CloudFormation ⊆ CDK
CDK (Cloud Development Kit) • 宣言的アプローチのIaCのひとつ • 使い慣れたPG言語で定義できる • 内部でCloudFormationテンプレートを生成してデプロイする
• 高いレベル(抽象度)でインフラを定義できる • OSSとして公開されている 7
CDKによるAWSインフラ構築例 • Minecraftサーバを立てた • 誰かがログインしたら通知が来てほしい 8
構成 9
CDKのコード 10 // ログアップロード用のユーザ const minecraftServer = new iam.User(this, 'MinecraftServer');
// ログ解析用のファンクション const lambdaFunction = new lambda.Function(this, 'minecraft-join-notifier', { runtime: lambda.Runtime.NODEJS_14_X, handler: 'minecraft-join-notifier.handler', code: lambda.Code.fromAsset('resources'), environment: { SLACK_WEBHOOK_URL: this.node.tryGetContext('slackWebhookUrl') as string, DISCORD_WEBHOOK_URL: this.node.tryGetContext('discordWebhookUrl') as string, }, }); // ログアップロード先キュー const queue = new sqs.Queue(this, 'MinecraftLog', { fifo: true, contentBasedDeduplication: true, }); queue.grant(minecraftServer, 'sqs:SendMessage'); // キューとファンクションの結合 const eventSource = new lambda_event_sources.SqsEventSource(queue); lambdaFunction.addEventSource(eventSource); IAMポリシというリソースを 意識する必要がない リソースを特定するIDを 意識する必要がない オブジェクトを作る感覚で リソースを定義できる https://github.com/ottijp/minecraft-man/blob/main/lib/minecraft-man-stack.ts
話したこと CDKを使うことで,AWSインフラのデプロイを • 宣言的なIaCで • 高レベルに • 好きなPG言語で 実現する方法へカイゼンできる. 11
勧誘(Java版) 12
13 Appendix
SAMとの違い • どちらもCloudFormationにトランスレーションしてデプロイする • SAMはサーバレスアプリケーションに特化しており,ローカルでビルド,テストできる • CDKはサーバレスに限らずAWSの全リソースのデプロイを汎用的に可能だが, ローカルでのビルド,テストはサポートしていない • 両者の統合
• 正式な統合はパブリックプレビュー中 • SAMを併用することでサーバレスアプリケーションをローカルでビルド,テストできる • CDKでsynthして作られたロジカルIDを指定して,SAMコマンドを実行する • https://docs.aws.amazon.com/cdk/v2/guide/sam.html 14
CDKがすべてのユースケースにおいて最適解なのか? • No.それぞれに利点があるのでユースケースに合わせて選択することが必要 • マネジメントコンソール • はじめて使うときに,GUIでどんなオプションがあるのか見ながら簡単にできる • CLI, SDK
• インフラのデプロイ以外のAPIコール(データ参照など) • カスタムスクリプトによる特殊なデプロイの構成 • CloudFormation • 低レベルな調整が必要な構成 • (ただ,CDKで基本ラップされているので,CloudFormationに限っては 互換性の課題がなければCDKに優先して採用する理由は無い気がする) 15
CDKはCloudFormation以外にも対応している • cdktf • Terraform HCL ステートファイルの定義 • alpha release
• cdk8s • Kubernetes 構成の定義 • alpha release 16
CodePipelineとの統合 • 公式ドキュメントには見つからなかった • SAMが一般的にCodeBuildでやるようなので,同様かな? 17
今回の例で作成されるリソース 18
refs • aws/aws-cdk: The AWS Cloud Development Kit is a
framework for defining cloud infrastructure in code • https://github.com/aws/aws-cdk • AWS クラウド開発キット – アマゾン ウェブ サービス • https://aws.amazon.com/jp/cdk/ • IaC (Infrastructure as Code) とは • https://www.redhat.com/ja/topics/automation/what-is-infrastructure-as-code-iac • ottijp/minecraft-man • https://github.com/ottijp/minecraft-man 19