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
AWS CLIで月160万円の負債を 解消した話 / AWS CLI debt resolution
Search
OouchiNaoki
September 20, 2020
Programming
1
1.7k
AWS CLIで月160万円の負債を 解消した話 / AWS CLI debt resolution
AWS CLIで月160万円の負債を 解消した話 / AWS CLI debt resolution
https://www.ooooouchi.info/
OouchiNaoki
September 20, 2020
Tweet
Share
More Decks by OouchiNaoki
See All by OouchiNaoki
生産性が向上しそうなTips/Programming Tips
naokioouchi
1
630
Other Decks in Programming
See All in Programming
Portapad紹介プレゼンテーション
gotoumakakeru
1
130
バイブスあるコーディングで ~PHP~ 便利ツールをつくるプラクティス
uzulla
1
330
『リコリス・リコイル』に学ぶ!! 〜キャリア戦略における計画的偶発性理論と変わる勇気の重要性〜
wanko_it
1
510
202507_ADKで始めるエージェント開発の基本 〜デモを通じて紹介〜(奥田りさ)The Basics of Agent Development with ADK — A Demo-Focused Introduction
risatube
PRO
6
1.4k
オホーツクでコミュニティを立ち上げた理由―地方出身プログラマの挑戦 / TechRAMEN 2025 Conference
lemonade_37
2
460
AHC051解法紹介
eijirou
0
470
Dart 参戦!!静的型付き言語界の隠れた実力者
kno3a87
0
190
decksh - a little language for decks
ajstarks
4
21k
#QiitaBash TDDで(自分の)開発がどう変わったか
ryosukedtomita
1
360
Vibe coding コードレビュー
kinopeee
0
430
Understanding Ruby Grammar Through Conflicts
yui_knk
1
100
CLI ツールを Go ライブラリ として再実装する理由 / Why reimplement a CLI tool as a Go library
ktr_0731
3
1.1k
Featured
See All Featured
VelocityConf: Rendering Performance Case Studies
addyosmani
332
24k
Principles of Awesome APIs and How to Build Them.
keavy
126
17k
Why Our Code Smells
bkeepers
PRO
338
57k
StorybookのUI Testing Handbookを読んだ
zakiyama
30
6k
The Web Performance Landscape in 2024 [PerfNow 2024]
tammyeverts
8
760
Stop Working from a Prison Cell
hatefulcrawdad
271
21k
実際に使うSQLの書き方 徹底解説 / pgcon21j-tutorial
soudai
PRO
183
54k
What's in a price? How to price your products and services
michaelherold
246
12k
Typedesign – Prime Four
hannesfritz
42
2.8k
What’s in a name? Adding method to the madness
productmarketing
PRO
23
3.6k
Optimising Largest Contentful Paint
csswizardry
37
3.4k
Designing Experiences People Love
moore
142
24k
Transcript
AWS CLIͰ݄160ສԁͷෛ࠴Λ ղফͨ͠ େ थʢ@NaoNoaNaoNoaNʣ 2020.09.24
େ थ @NaoNoaNaoNoaN • System Shared, Inc. • AWS, Nuxt.js,
Node.js, TypeScript • ٳΑ͘ເͷࠃʹߦ·͢ • ϒϩάॻ͍ͯ·͢ https://www.ooooouchi.info/
ຊͷલʹ
System Shared, Inc. Ͳ͏͍͏ձࣾʁ
SESͬͯ·͢
डୗ։ൃͬͯ·͢
৽ଔ͚ITݚमͬͯ·͢ ʢ̐ʙ݄̒ʣ
ݚमதʹ AWSͷೖͬͯ·͢ ʢ̏͘Β͍ʣ
ࣗࣾαʔϏεͬͯ·͢
AWSΞΧϯτཧߦαʔϏε ʢڴҖݕͱ͔༧ࢉཧͱ͔ͬͯ·͢ʣ
None
͜Ε System Shared, Inc.͕ ݚमੜͷAWSΞΧϯτΛ ཧߦͨ࣌͠ͷ ޠ
ຊ
AWSೖݚमͰ͏ AWSϦιʔε
EIP + EC2 + RDS
ݚमੜͷAWSΞΧϯτ AWS OrganizationsͰ৫ཧͯ͠Δ →ແྉར༻ྔͳ͠
Ϧιʔείετ ֹ݄2000ԁ
ݚमੜͷ
800ਓऑ
2000 × 800 = ʁ
1,600,000
̏͘Β͍ͷݚमͰ ݄160ສԁͷෛ࠴
ղܾ͍͖ͯ͠·͢
ղܾํ๏
ᾇ
StepFunctions + Lambda Node.js + AWS SDK Ͱ֤छϦιʔεΛফ͢
ςετ༻ʹ༻ҙͨ͠ AWSΞΧϯτ 10ΞΧϯτͰআޭ
͍͟ຊ൪
Τϥʔൃੜ
The state/task ‘arn:xxxxxxxxxxxxxxxx’ returned a result with a size exceeding
the maximum number of characters service limit.
λεΫؒͷύϥϝʔλαΠζ͕େ͖͗͢Δ ※্ݶɿ32,768byte
800ΞΧϯτͷใΛ͢ʹ গͳ͗͢Δ
ࠔͬͨɾɾ
͓ʁ
None
͜Εͩʂʂ
ᾈ
Shell + AWS CLI
AWSΞΧϯτIDΛऔಘͯ͠ aws organizations list-accounts-for-parent \ --parent-id ${OU_ID} \ --profile ${AWS_PROFILE_NAME}
| jq -r ".Accounts[].Id" | sed -e "s/[\r\n]\+//g"
શϦʔδϣϯ໊Λऔಘͯ͠ regions=$( aws ec2 describe-regions \ --query Regions[*].RegionName \ --output
text \ --region ap-northeast-1 )
EC2Πϯελϯεআ INSTANCE_IDS=$( aws ec2 describe-instances \ --region $1 \ --filters
“Name=instance-state-name, Values=pending,running,stopped,stopping" \ --query "Reservations[].Instances[].[InstanceId]" \ --output text | sed -e "s/[\r\n]\+//g" ) if [ -n "${INSTANCE_IDS[0]}" ]; then aws ec2 terminate-instances \ --instance-ids ${INSTANCE_IDS} \ --region $1 fi
EBS,NAT,EIP,RDS ҎԼಉจ
AWS CLIͰ݄160ສԁͷෛ࠴Λղফ ྃ
·ͱΊ
ᾇ
ԿࣄεέʔϧͱϦϛοτΛ֬ೝ͠Α͏
ᾈ
݄160ສͷϚΠφεΛ0ʹͨ͠ ͱ͍͏͜ͱɾɾʁ
AWS CLIΛ͏ͱ ݄160ສԁউͯΔ ʢΪϟϯϒϥʔࢥߟʣ
Φν
ύϥϝʔλαΠζͷ্ݶ؇͞Εͯͨ
͋Γ͕ͱ͏͍͟͝·ͨ͠ɻ