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
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
260
Other Decks in Programming
See All in Programming
TS 7.0 で baseUrl が使えなくなった今、パスエイリアスをどうするか
bicstone
1
270
Performance Optimization With LLMs
xleitix
0
230
AmebaブログはKMPから卒業します
kmars0605
0
310
AI-Powered Domain-Driven Design
ziobrando
0
360
No More NoSuchMethodError
exoego
1
120
[Dev Group Paris Octobre 26] Agentforce, SIforce, Claudeforce, Slackbot… on s'y retrouve ?
nabondance
0
120
AIで開発が速くなった先で、開発チームは何を目指すか
shihochan
1
1.9k
Kotlinの15年とServer-Side Kotlin
n_takehata
1
170
[JA] Domain Modeling with Vanilla Rails: 「操作」から再考するRailsの設計論
yasaichi
4
1.4k
Spec-driven Development with AI
simas
PRO
0
2.2k
自作Discord音声botをLambda MicroVMsに移行した話 / Migrating My Discord Voice Bot to Lambda MicroVMs
akihisaikeda
0
190
PyConTW 2026 - AI Coding 不只是工具升級, 區域醫院醫療資訊系統協作開發與資訊團隊轉型實踐
cclai999
0
210
Featured
See All Featured
Agile that works and the tools we love
rasmusluckow
331
22k
How STYLIGHT went responsive
nonsquared
100
6.3k
The AI Search Optimization Roadmap by Aleyda Solis
aleyda
2
6.4k
Being A Developer After 40
akosma
PRO
92
590k
4 Signs Your Business is Dying
shpigford
187
23k
Thoughts on Productivity
jonyablonski
76
5.4k
Gemini Prompt Engineering: Practical Techniques for Tangible AI Outcomes
mfonobong
2
610
End of SEO as We Know It (SMX Advanced Version)
ipullrank
3
4.5k
Fashionably flexible responsive web design (full day workshop)
malarkey
409
67k
Docker and Python
trallard
47
4.2k
Sharpening the Axe: The Primacy of Toolmaking
bcantrill
46
3k
The Art of Delivering Value - GDevCon NA Keynote
reverentgeek
16
2.2k
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