Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
CDK for TerraformでAzureリソースをデプロイする/2023-05-15-l...
Search
Satoshi SAKAO
May 15, 2023
Technology
1
290
CDK for TerraformでAzureリソースをデプロイする/2023-05-15-llt29
社内のLTイベント「えるLT Vol.29 オンライン」で発表した資料です
Satoshi SAKAO
May 15, 2023
Tweet
Share
More Decks by Satoshi SAKAO
See All by Satoshi SAKAO
Testcontainers/2024-11-20-llt32
ottijp
0
65
Pkl/2024-04-17-llt31
ottijp
0
92
JavaScriptのデバッグ/2023-09-04-llt30
ottijp
0
160
TWELITEへの誘い/2022-12-27-llt28
ottijp
0
160
ビルドツールBazelを触ってみた/2022-09-28-llt27
ottijp
0
180
HashiCorp Vaultを使ったシークレットのセキュアな一元管理 〜Ansibleを添えて〜/2022-07-12-llt26
ottijp
0
160
AWSインフラのデプロイをCDKでカイゼンする/2022-03-23-llt25
ottijp
0
95
Amazon Timestreamでデータ補間/2021-12-27-llt24
ottijp
0
110
ncurses/2021-05-12-llt21
ottijp
0
210
Other Decks in Technology
See All in Technology
AIプロダクトのプロンプト実践テクニック / Practical Techniques for AI Product Prompts
saka2jp
0
110
What's new in OpenShift 4.20
redhatlivestreaming
0
300
アウトプットから始めるOSSコントリビューション 〜eslint-plugin-vueの場合〜 #vuefes
bengo4com
3
1.8k
Retrospectiveを振り返ろう
nakasho
0
120
re:Invent 2025の見どころと便利アイテムをご紹介 / Highlights and Useful Items for re:Invent 2025
yuj1osm
0
160
AI時代の開発を加速する組織づくり - ブログでは書けなかったリアル
hiro8ma
2
330
CNCFの視点で捉えるPlatform Engineering - 最新動向と展望 / Platform Engineering from the CNCF Perspective
hhiroshell
0
140
会社を支える Pythonという言語戦略 ~なぜPythonを主要言語にしているのか?~
curekoshimizu
3
860
東京大学「Agile-X」のFPGA AIデザインハッカソンを制したソニーのAI最適化
sony
0
110
個人でデジタル庁の デザインシステムをVue.jsで 作っている話
nishiharatsubasa
3
5.1k
激動の時代を爆速リチーミングで乗り越えろ
sansantech
PRO
1
130
Oracle Base Database Service 技術詳細
oracle4engineer
PRO
14
82k
Featured
See All Featured
Building Better People: How to give real-time feedback that sticks.
wjessup
369
20k
Fashionably flexible responsive web design (full day workshop)
malarkey
407
66k
Designing Dashboards & Data Visualisations in Web Apps
destraynor
231
53k
Automating Front-end Workflow
addyosmani
1371
200k
jQuery: Nuts, Bolts and Bling
dougneiner
65
7.9k
How GitHub (no longer) Works
holman
315
140k
Art, The Web, and Tiny UX
lynnandtonic
303
21k
Six Lessons from altMBA
skipperchong
29
4k
Done Done
chrislema
185
16k
Sharpening the Axe: The Primacy of Toolmaking
bcantrill
46
2.5k
4 Signs Your Business is Dying
shpigford
185
22k
Design and Strategy: How to Deal with People Who Don’t "Get" Design
morganepeng
132
19k
Transcript
CDK for TerraformでAzureリソースをデプロイする Satoshi SAKAO えるLT Vol.29 2023-05-15 1
話すひと 2 🏢 インフォコム株式会社 サービスマネジメント室 👨🔧 ソフトウェアエンジニア 🛠 Node.js /
AWS / IoT / iOS (Swift) / Linux 💖 猫,テクテクライフ(ランク: 26) Satoshi SAKAO @ottijp
3 https://gmedia.playstation.com/is/image/SIEPDC/death-stranding-screen-us-11jun18-8?$2400px$
CDK is 何 • Cloud Development Kit • AWS製OSS •
CloudFormationテンプレートへのトランスパイラ 4 https://speakerdeck.com/ottijp/2022-03-23-llt25
CDKの位置付け 5 TypeScript | Python | Java | C# |
Go CDK for tf HCL JSON AWS Azure GCP etc AWS CDK CloudFormation ARM CRDs Deployment Mgr Bicep Terraform Cloud Resource IaC Hi-Level IaC Bicep JSON SAM YAML JSON entity process YAML
CDK for tf • DSLを新しく覚えることなく,使いなれたPG言語で クロスクラウドのIaCが可能. • コード補完 •
プロシージャルな処理 • モジュール化による複雑な構成への対応力 • まだα板で,ブレイキングチェンジが起こりうるので注意. 6 https://developer.hashicorp.com/terraform/cdktf#when-to-use-cdk-for-terraform
準備 7 $ npm install -g cdktf-cli $ cdktf init
--template=typescript --providers=azurerm --local
構成 8
コードの例(一部) 9 import { Construct } from 'constructs'; import {
App, TerraformStack } from 'cdktf'; import { AzurermProvider } from '@cdktf/provider-azurerm/lib/provider' import { ResourceGroup } from '@cdktf/provider-azurerm/lib/resource-group' import { VirtualNetwork } from '@cdktf/provider-azurerm/lib/virtual-network' import { Subnet } from '@cdktf/provider-azurerm/lib/subnet' import { NetworkInterface } from '@cdktf/provider-azurerm/lib/network-interface' import { PublicIp } from '@cdktf/provider-azurerm/lib/public-ip' import { LinuxVirtualMachine } from '@cdktf/provider-azurerm/lib/linux-virtual-machine' class AzureAppInfra extends TerraformStack { constructor(scope: Construct, name: string) { super(scope, name); new AzurermProvider(this, 'AzureRm', { features: {}, }) …
出力されるHCL(一部) 10 { "//": { "metadata": { "backend": "local", "stackName":
"llt", "version": "0.16.1" }, "outputs": { } }, "provider": { "azurerm": [ { "features": { } } ] }, "resource": { "azurerm_linux_virtual_machine": { "web-server": { "//": { …
デプロイ 11 $ cdktf deploy
まとめ • CDK for Terraformを利用することで AWS以外のクラウドリソースのデプロイにCDKが利用できる. • CDK for
TerraformはHCLへのトランスパイラ. • まだα版でブレイキングチェンジが起こりうるので注意. • 本当にそのプロダクトで使うべきかどうかはよく考えること. 12
13 Appendix
CDK for tfでAzureリソースをデプロイする • 環境 • terraform: v1.4.6 • cdktf:
v0.16.1(α版) • azure-cli: 2.48.1 • 前提条件 • Node(npm)がインストールされている • Terraform CLIがインストールされている • Azure CLIがインストールされていてログインしている 14
Refs • Building Azure Resources with TypeScript Using the CDK
for Terraform • https://www.hashicorp.com/blog/building-azure-resources-with-typescript-using- the-cdk-for-terraform • CDK for Terraform | Terraform | HashiCorp Developer • https://developer.hashicorp.com/terraform/cdktf • AWSインフラのデプロイをCDKでカイゼンする/2022-03-23- llt25 - Speaker Deck • https://speakerdeck.com/ottijp/2022-03-23-llt25 15