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
Terraformのnull_resource ってなに?aws cli が実行できるらしい
Search
Yuki_Kurono
January 14, 2023
Technology
0
520
Terraformのnull_resource ってなに?aws cli が実行できるらしい
「Step Functionsからサーバレスを始めよう!! / 2023年始めLT大会!! JAWS-UGおおいた」の資料
Yuki_Kurono
January 14, 2023
Tweet
Share
More Decks by Yuki_Kurono
See All by Yuki_Kurono
re_invent 2023事前勉強会
yuki_kurono
0
8
CloudFormationの運用が 辛くならない方法を本気で考えてみた
yuki_kurono
0
58
CloudFormationで登場したForEachをちゃんと理解してみる
yuki_kurono
0
260
Turnstileのウィジェット モードとは何者か
yuki_kurono
0
120
CodeGuru Security ってなんだ?
yuki_kurono
0
320
えるしってるか CloudFrontはWAFがあっても カスタムエラーレスポンスを返せる
yuki_kurono
0
140
Cloudflare初心者がIaCから基本構成を学んでみた
yuki_kurono
1
350
Hashicorp VaultでAWSクレデンシャルの管理を楽にしたい
yuki_kurono
0
430
回転re:Invent寿司
yuki_kurono
0
38
Other Decks in Technology
See All in Technology
リテール金融(キャッシュレス・ネット銀行・ネット証券)の競争環境と経済圏
8maki
0
890
Janus
bkuhlmann
1
490
MySQL の SQL クエリチューニングの要所を掴む勉強会
andpad
2
6.2k
アクセス制御にまつわる改善 / Improving access control
itkq
0
530
ゼロから始めるVue.jsコミュニティ貢献 / first-vuejs-community-contribution-link-and-motivation
lmi
1
120
ワールドカフェI /チューターを改良する / World Café I and Improving the Tutors
ks91
PRO
0
120
Terraformあれやこれ/terraform-this-and-that
emiki
8
1.4k
On Your Data を超えていく!
hirotomotaguchi
2
670
プロトタイピングによる不確実性の低減 / Reducing Uncertainty through Prototyping
ohbarye
5
380
開発生産性大幅アップ!Postman VS Code拡張機能
nagix
2
370
家族アルバム みてねにおけるGrafana活用術 / Grafana Meetup Japan Vol.1 LT
isaoshimizu
1
620
DevOpsDays History and my DevOps story
kawaguti
PRO
9
2.5k
Featured
See All Featured
What’s in a name? Adding method to the madness
productmarketing
PRO
16
2.6k
Distributed Sagas: A Protocol for Coordinating Microservices
caitiem20
322
20k
"I'm Feeling Lucky" - Building Great Search Experiences for Today's Users (#IAC19)
danielanewman
221
21k
Designing with Data
zakiwarfel
96
4.8k
The Brand Is Dead. Long Live the Brand.
mthomps
49
28k
Responsive Adventures: Dirty Tricks From The Dark Corners of Front-End
smashingmag
244
20k
How STYLIGHT went responsive
nonsquared
92
4.8k
Into the Great Unknown - MozCon
thekraken
10
990
Web Components: a chance to create the future
zenorocha
305
41k
The MySQL Ecosystem @ GitHub 2015
samlambert
243
12k
Templates, Plugins, & Blocks: Oh My! Creating the theme that thinks of everything
marktimemedia
19
1.7k
JavaScript: Past, Present, and Future - NDC Porto 2020
reverentgeek
40
4.4k
Transcript
Terraformのnull_resourceってなに? aws cliが実行できるらしい 黒野 雄稀 | 2023/1/14 1 Step Functionsからサーバレスを始めよう!!
2023年始めLT大会!! JAWS-UGおおいた
自己紹介 黒野 雄稀 Yuki Kurono kurono_98 kurono アイレット株式会社 所属 普段はインフラ設計・構築や運用構築に従事
2022 APN ALL AWS Certifications Engineers 2
3 Terraformってなに?
4 null_resourceってなに? resource "aws_vpc" "main" { cidr_block = "10.0.0.0/16" }
resource "null_resource" "main" { } null_resource、その名の通り何も作らないリソースのこと。
5 これ作ってて意味あるの?? 何に使うの??無を生みだして楽しい? resource "null_resource" "main" { }
6 Google先生に聞いてみる
7 なるほど。 じゃあ、AWS CLI実行すれば リソース全部作れるじゃん! ちょっと前の僕
8 やってみた
9 だいたいこんな感じになる resource "null_resource" "vpc" { provisioner "local-exec" { interpreter
= ["/bin/bash", "-c"] command = <<EOT aws ec2 create-vpc \ --cidr-block 10.20.0.0/16 \ --tag-specifications "ResourceType=vpc, \ Tags=[{Key=Name,Value=vpc_from_null_resource}]" EOT } }
10 記述量を比較してみる リソース 記述量(普通) 記述量(null) 倍率 VPC 4行 28行 7倍
Subnet 7行 36行 約5倍 RouteTable 4行 32行 8倍 SecurityGroup 6行 36行 6倍 EC2 8行 46行 約6倍
11 辛いポイント① provisioner "local-exec" { when = destroy interpreter =
["/bin/bash", "-c"] command = <<EOT aws ec2 delete-vpc \ --vpc-id $(cat ./state/VPC_ID.txt) EOT on_failure = fail } destroy時の処理(コマンド)も記載しないとリソースが削除されない。
12 辛いポイント② リソースのId(VPCのIdとか)を保持したり取得できないので、 describeコマンドを打って、ファイル保存しておかないといけない。。
13 辛いポイント③ デプロイしてみても何作ってんのか全然わからん。。。
14 何が言いたいかというと... やれる と できるは違うよね ※本スライドの内容は完全にネタですので悪しからず。
15