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
Sponsored
·
SiteGround - Reliable hosting with speed, security, and support you can count on.
→
OouchiNaoki
September 20, 2020
Programming
1.7k
1
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
AWS CLIで月160万円の負債を 解消した話 / AWS CLI debt resolution
AWS CLIで月160万円の負債を 解消した話 / AWS CLI debt resolution
https://www.ooooouchi.info/
OouchiNaoki
September 20, 2020
More Decks by OouchiNaoki
See All by OouchiNaoki
生産性が向上しそうなTips/Programming Tips
naokioouchi
1
660
Other Decks in Programming
See All in Programming
エンジニア向け会社紹介/Findy Company Profile
findyinc
6
350k
Vue × Nuxt × Oxc どこまで使える?実運用の現在地
andpad
0
290
AI 時代のソフトウェア設計の学び方
masuda220
PRO
29
13k
Semantic Version 単位で戦略を柔軟に変えて、パッケージアップデートを自動化する
daitasu
1
280
Lessons from Spec-Driven Development
simas
PRO
0
220
なぜ型を書くのか? TSKaigi2026で改めて考える #tskaigi_smarthr
kajitack
0
120
AIとASP.NET Coreで雑Webアプリを作った話
mayuki
0
670
The ROI of Quarkus for Spring Boot Applications
hollycummins
0
130
依存関係から依存物へ―Dependencyという言葉の歴史をひも解く
j_lee
0
130
dRuby over BLE
makicamel
2
380
エージェンティックRAGにAWSで入門しよう!
har1101
8
1.7k
PHPで使える日時の表現と、その知り方 #frontend_phpcon_do
o0h
PRO
0
260
Featured
See All Featured
HTML-Aware ERB: The Path to Reactive Rendering @ RubyCon 2026, Rimini, Italy
marcoroth
1
210
Highjacked: Video Game Concept Design
rkendrick25
PRO
1
400
SEOcharity - Dark patterns in SEO and UX: How to avoid them and build a more ethical web
sarafernandez
0
210
Have SEOs Ruined the Internet? - User Awareness of SEO in 2025
akashhashmi
0
370
Creating an realtime collaboration tool: Agile Flush - .NET Oxford
marcduiker
35
2.5k
The Curse of the Amulet
leimatthew05
1
13k
ReactJS: Keep Simple. Everything can be a component!
pedronauck
666
130k
YesSQL, Process and Tooling at Scale
rocio
174
15k
Neural Spatial Audio Processing for Sound Field Analysis and Control
skoyamalab
0
340
4 Signs Your Business is Dying
shpigford
187
22k
Bootstrapping a Software Product
garrettdimon
PRO
307
120k
[RailsConf 2023 Opening Keynote] The Magic of Rails
eileencodes
31
10k
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ສԁউͯΔ ʢΪϟϯϒϥʔࢥߟʣ
Φν
ύϥϝʔλαΠζͷ্ݶ؇͞Εͯͨ
͋Γ͕ͱ͏͍͟͝·ͨ͠ɻ