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.6k
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
620
Other Decks in Programming
See All in Programming
CSC509 Lecture 12
javiergs
PRO
0
160
3 Effective Rules for Using Signals in Angular
manfredsteyer
PRO
0
120
CSC509 Lecture 13
javiergs
PRO
0
110
TypeScriptでライブラリとの依存を限定的にする方法
tutinoko
3
720
ヤプリ新卒SREの オンボーディング
masaki12
0
130
ふかぼれ!CSSセレクターモジュール / Fukabore! CSS Selectors Module
petamoriken
0
150
광고 소재 심사 과정에 AI를 도입하여 광고 서비스 생산성 향상시키기
kakao
PRO
0
180
Nurturing OpenJDK distribution: Eclipse Temurin Success History and plan
ivargrimstad
0
1.1k
シェーダーで魅せるMapLibreの動的ラスタータイル
satoshi7190
1
480
Streams APIとTCPフロー制御 / Web Streams API and TCP flow control
tasshi
2
360
Jakarta EE meets AI
ivargrimstad
0
250
Creating a Free Video Ad Network on the Edge
mizoguchicoji
0
120
Featured
See All Featured
Measuring & Analyzing Core Web Vitals
bluesmoon
4
140
A Philosophy of Restraint
colly
203
16k
Music & Morning Musume
bryan
46
6.2k
Adopting Sorbet at Scale
ufuk
73
9.1k
Teambox: Starting and Learning
jrom
133
8.8k
GitHub's CSS Performance
jonrohan
1030
460k
Learning to Love Humans: Emotional Interface Design
aarron
273
40k
CSS Pre-Processors: Stylus, Less & Sass
bermonpainter
356
29k
Testing 201, or: Great Expectations
jmmastey
38
7.1k
Evolution of real-time – Irina Nazarova, EuRuKo, 2024
irinanazarova
4
380
実際に使うSQLの書き方 徹底解説 / pgcon21j-tutorial
soudai
169
50k
Visualization
eitanlees
145
15k
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ສԁউͯΔ ʢΪϟϯϒϥʔࢥߟʣ
Φν
ύϥϝʔλαΠζͷ্ݶ؇͞Εͯͨ
͋Γ͕ͱ͏͍͟͝·ͨ͠ɻ