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
130
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
Workers Cache を知る
syumai
0
340
Simple Storage Service(S3) is not simple
iwatsukayura
0
210
When benchmarks go bad - what I learned from measuring performance wrong
hollycummins
0
160
Turning Architecture into Unit Tests in the AI Era (NSSpain XIV)
steliosf
PRO
1
130
AI が書く Go コードの品質を劇的に向上させる Linter: “declscope”
mpyw
0
480
Herb in Rails 8.2: Your ERB views, now HTML-aware @ Rails World 2026, Austin, Texas
marcoroth
0
190
Vue Fes Japan の “作る側”に関わってみて
naokihaba
0
120
Apple Intelligence を用いた個人情報誤送信防止、及びユーザーリクエスト体験の改善について
yukiny
0
310
JRuby: Past, Present, and Future
headius
0
220
FreeBSDでZabbixを動かす
kenkino
0
360
速く作れる。その次は、速く確かめられる開発へ 〜AIネイティブ開発を支える、Shift Down〜 / Can build fast. Next, moving to development where we can verify fast.
rkaga
8
5.5k
Domain-Driven Transformation
hschwentner
2
2.3k
Featured
See All Featured
Java REST API Framework Comparison - PWX 2021
mraible
34
9.7k
Fashionably flexible responsive web design (full day workshop)
malarkey
409
67k
HDC tutorial
michielstock
2
950
Design in an AI World
tapps
1
350
How GitHub (no longer) Works
holman
316
150k
"I'm Feeling Lucky" - Building Great Search Experiences for Today's Users (#IAC19)
danielanewman
230
23k
Introduction to Domain-Driven Design and Collaborative software design
baasie
1
1k
The untapped power of vector embeddings
frankvandijk
2
1.9k
Sam Torres - BigQuery for SEOs
techseoconnect
PRO
0
570
Product Roadmaps are Hard
iamctodd
55
13k
[RailsConf 2023] Rails as a piece of cake
palkan
59
7.1k
How to optimise 3,500 product descriptions for ecommerce in one day using ChatGPT
katarinadahlin
PRO
3
3.9k
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