$30 off During Our Annual Pro Sale. View Details »
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
1
1.4k
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から学ぶこと
yuki_kurono
0
69
re_invent 2023事前勉強会
yuki_kurono
0
78
CloudFormationの運用が 辛くならない方法を本気で考えてみた
yuki_kurono
0
260
CloudFormationで登場したForEachをちゃんと理解してみる
yuki_kurono
0
730
Turnstileのウィジェット モードとは何者か
yuki_kurono
0
600
CodeGuru Security ってなんだ?
yuki_kurono
0
1.1k
えるしってるか CloudFrontはWAFがあっても カスタムエラーレスポンスを返せる
yuki_kurono
0
390
Cloudflare初心者がIaCから基本構成を学んでみた
yuki_kurono
1
570
Hashicorp VaultでAWSクレデンシャルの管理を楽にしたい
yuki_kurono
0
640
Other Decks in Technology
See All in Technology
コミューンのデータ分析AIエージェント「Community Sage」の紹介
fufufukakaka
0
430
モダンデータスタック (MDS) の話とデータ分析が起こすビジネス変革
sutotakeshi
0
400
品質のための共通認識
kakehashi
PRO
2
200
5分で知るMicrosoft Ignite
taiponrock
PRO
0
150
Uncertainty in the LLM era - Science, more than scale
gaelvaroquaux
0
800
寫了幾年 Code,然後呢?軟體工程師必須重新認識的 DevOps
cheng_wei_chen
1
550
Challenging Hardware Contests with Zephyr and Lessons Learned
iotengineer22
0
120
Oracle Database@Google Cloud:サービス概要のご紹介
oracle4engineer
PRO
0
690
なぜ使われないのか?──定量×定性で見極める本当のボトルネック
kakehashi
PRO
1
1.2k
Sansanが実践する Platform EngineeringとSREの協創
sansantech
PRO
2
590
ブロックテーマとこれからの WordPress サイト制作 / Toyama WordPress Meetup Vol.81
torounit
0
390
re:Invent 2025 ふりかえり 生成AI版
takaakikakei
1
170
Featured
See All Featured
Bash Introduction
62gerente
615
210k
Making the Leap to Tech Lead
cromwellryan
135
9.7k
The Cult of Friendly URLs
andyhume
79
6.7k
The Cost Of JavaScript in 2023
addyosmani
55
9.3k
Large-scale JavaScript Application Architecture
addyosmani
515
110k
Music & Morning Musume
bryan
46
7k
jQuery: Nuts, Bolts and Bling
dougneiner
65
8.2k
How STYLIGHT went responsive
nonsquared
100
5.9k
The MySQL Ecosystem @ GitHub 2015
samlambert
251
13k
Designing for Performance
lara
610
69k
Facilitating Awesome Meetings
lara
57
6.7k
Creating an realtime collaboration tool: Agile Flush - .NET Oxford
marcduiker
35
2.3k
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