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
GoのGenericsによるslice操作との付き合い方
syumai
3
720
What Spring Developers Should Know About Jakarta EE
ivargrimstad
0
380
Flutterで備える!Accessibility Nutrition Labels完全ガイド
yuukiw00w
0
140
Quand Symfony, ApiPlatform, OpenAI et LangChain s'allient pour exploiter vos PDF : de la théorie à la production…
ahmedbhs123
0
120
Railsアプリケーションと パフォーマンスチューニング ー 秒間5万リクエストの モバイルオーダーシステムを支える事例 ー Rubyセミナー 大阪
falcon8823
4
1k
来たるべき 8.0 に備えて React 19 新機能と React Router 固有機能の取捨選択とすり合わせを考える
oukayuka
2
880
コードの90%をAIが書く世界で何が待っているのか / What awaits us in a world where 90% of the code is written by AI
rkaga
50
32k
なぜ適用するか、移行して理解するClean Architecture 〜構造を超えて設計を継承する〜 / Why Apply, Migrate and Understand Clean Architecture - Inherit Design Beyond Structure
seike460
PRO
1
720
PHPでWebSocketサーバーを実装しよう2025
kubotak
0
250
#QiitaBash MCPのセキュリティ
ryosukedtomita
0
790
XP, Testing and ninja testing
m_seki
3
220
データの民主化を支える、透明性のあるデータ利活用への挑戦 2025-06-25 Database Engineering Meetup#7
y_ken
0
340
Featured
See All Featured
The Invisible Side of Design
smashingmag
300
51k
The MySQL Ecosystem @ GitHub 2015
samlambert
251
13k
YesSQL, Process and Tooling at Scale
rocio
173
14k
Done Done
chrislema
184
16k
No one is an island. Learnings from fostering a developers community.
thoeni
21
3.3k
Testing 201, or: Great Expectations
jmmastey
42
7.6k
Imperfection Machines: The Place of Print at Facebook
scottboms
267
13k
Measuring & Analyzing Core Web Vitals
bluesmoon
7
500
Navigating Team Friction
lara
187
15k
Creating an realtime collaboration tool: Agile Flush - .NET Oxford
marcduiker
30
2.1k
Designing for Performance
lara
609
69k
Keith and Marios Guide to Fast Websites
keithpitt
411
22k
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ສԁউͯΔ ʢΪϟϯϒϥʔࢥߟʣ
Φν
ύϥϝʔλαΠζͷ্ݶ؇͞Εͯͨ
͋Γ͕ͱ͏͍͟͝·ͨ͠ɻ