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.5k
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
570
Other Decks in Programming
See All in Programming
Zero Waste, Radical Magic, and Italian Graft – Quarkus Efficiency Secrets
hollycummins
0
200
Folding Cheat Sheet #1
philipschwarz
PRO
0
210
ゆるい個人開発のススメ
kuroppe1819
10
930
[技育CAMPアカデミア]アイディアを形に!【超入門】スマホアプリ開発〜リリースまでの流れをご紹介
teamlab
PRO
0
340
デザインシステムで Tailwind CSSとCSS in JSに分散投資をしたら良かった話
fsubal
18
4.8k
Semantic search with Django and pgvector
pauloxnet
0
230
Doctrine ORMでValue Objectを扱う方法4選 #phpstudy / 4 ways to handle Value Objects with Doctrine ORM
77web
4
110
try! Swift Tokyo 2024 参加報告 / try! Swift Tokyo 2024 Report
hironytic
0
160
Code Reviews
bkuhlmann
4
860
雑に思考を整理する技術と効能
konifar
52
23k
スクラムガイドのスプリントレトロスペクティブを改めて読みかえしてみた / Re-reading the Sprint Retrospective Section in the Scrum Guide
mackey0225
3
320
受託開発でGitLab CI を活用していく
xiombatsg
1
260
Featured
See All Featured
Automating Front-end Workflow
addyosmani
1354
200k
From Idea to $5000 a Month in 5 Months
shpigford
377
45k
Git: the NoSQL Database
bkeepers
PRO
421
63k
Adopting Sorbet at Scale
ufuk
67
8.6k
Producing Creativity
orderedlist
PRO
336
39k
実際に使うSQLの書き方 徹底解説 / pgcon21j-tutorial
soudai
118
38k
The Power of CSS Pseudo Elements
geoffreycrofte
58
5k
The Success of Rails: Ensuring Growth for the Next 100 Years
eileencodes
29
6k
GraphQLとの向き合い方2022年版
quramy
30
12k
VelocityConf: Rendering Performance Case Studies
addyosmani
319
23k
Put a Button on it: Removing Barriers to Going Fast.
kastner
58
3k
It's Worth the Effort
3n
180
27k
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ສԁউͯΔ ʢΪϟϯϒϥʔࢥߟʣ
Φν
ύϥϝʔλαΠζͷ্ݶ؇͞Εͯͨ
͋Γ͕ͱ͏͍͟͝·ͨ͠ɻ