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
RemovalPoliciesのことを知ろう!
Search
watany
April 01, 2025
Technology
2
200
RemovalPoliciesのことを知ろう!
JAWS-UG CDK支部 #20でお話しした内容でした
https://jawsug-cdk.connpass.com/event/348953/
watany
April 01, 2025
Tweet
Share
More Decks by watany
See All by watany
AIのメモリー
watany
13
1.6k
AIエージェントが書くのなら直接CloudFormationを書かせればいいじゃないですか何故AWS CDKを使う必要があるのさ
watany
21
8.6k
Coding Agentに値札を付けろ
watany
3
920
Vibe Codingをせずに Clineを使っている
watany
19
7.7k
ミリしらMCP勉強会
watany
4
1.1k
エンジニアに許された特別な時間の終わり
watany
102
200k
AI Agent時代なのでAWSのLLMs.txtが欲しい!
watany
4
1.3k
宇宙最速のランチRecap LT会(AWS re:Invent 2024)
watany
2
790
苦いビールを避ける冴えたやり方
watany
2
440
Other Decks in Technology
See All in Technology
いま注目しているデータエンジニアリングの論点
ikkimiyazaki
0
580
Pythonによる契約プログラミング入門 / PyCon JP 2025
7pairs
5
2.5k
AI時代だからこそ考える、僕らが本当につくりたいスクラムチーム / A Scrum Team we really want to create in this AI era
takaking22
6
3k
リーダーになったら未来を語れるようになろう/Speak the Future
sanogemaru
0
260
LLMアプリケーション開発におけるセキュリティリスクと対策 / LLM Application Security
flatt_security
7
1.8k
神回のメカニズムと再現方法/Mechanisms and Playbook for Kamikai scrumat2025
moriyuya
4
370
【新卒研修資料】LLM・生成AI研修 / Large Language Model・Generative AI
brainpadpr
23
16k
GA technologiesでのAI-Readyの取り組み@DataOps Night
yuto16
0
260
o11yで育てる、強い内製開発組織
_awache
3
110
組織観点からIAM Identity CenterとIAMの設計を考える
nrinetcom
PRO
1
160
KMP の Swift export
kokihirokawa
0
320
KAGのLT会 #8 - 東京リージョンでGAしたAmazon Q in QuickSightを使って、報告用の資料を作ってみた
0air
0
200
Featured
See All Featured
Docker and Python
trallard
46
3.6k
Making the Leap to Tech Lead
cromwellryan
135
9.5k
Evolution of real-time – Irina Nazarova, EuRuKo, 2024
irinanazarova
9
960
The Cult of Friendly URLs
andyhume
79
6.6k
Writing Fast Ruby
sferik
629
62k
Producing Creativity
orderedlist
PRO
347
40k
4 Signs Your Business is Dying
shpigford
185
22k
[RailsConf 2023] Rails as a piece of cake
palkan
57
5.9k
Design and Strategy: How to Deal with People Who Don’t "Get" Design
morganepeng
132
19k
The Illustrated Children's Guide to Kubernetes
chrisshort
48
51k
Creating an realtime collaboration tool: Agile Flush - .NET Oxford
marcduiker
32
2.2k
How GitHub (no longer) Works
holman
315
140k
Transcript
JAWS-UG CDK支部 #20 RemovalPoliciesのことを知ろう! 2025-04-01
About Me 渡邉 洋平(watany) • 所属:NTTテクノクロス株式会社 ◦ 「AWS 500 APN
Certification Distinction」に認定 • Personal ◦ JAWS-UG東京 運営 ◦ AWS Ambassadors(2024) ◦ Japan AWS All Certifications Engineers(2022~) https://jawsug.connpass.com/event/316
RemovalPoliciesのことを知ろう!
おさらい- RemovalPolicy • CDK’s Removal Policy ≒ CloudFormation’s DeletionPolicy •
リソースの消し方を設定する ◦ RemovalPolicy.DESTROY:削除 ◦ RemovalPolicy.RETAIN:保持 ◦ RemovalPolicy.SNAPSHOT:スナップショット取得 ◦ RemovalPolicy.RETAIN_ON_UPDATE_OR_DELETE:作成失敗で削除。以降は保持 https://docs.aws.amazon.com/cdk/v2/guide/resources.html#resources_removal
何が困るか- RemovalPolicy 大量のリソースへ 設定したい 検証用にRETAINを 止めたい RDS全部に SNAPSHOT設定したい
RemovalPolicies https://github.com/aws/aws-cdk/releases/tag/v2.183.0 2025/03/12 🚀
なぜ私が説明するか 私と3人で 作ったPR https://github.com/aws/aws-cdk/pull/32283
何ができるか- RemovalPolicies 基本形 Stack配下の 全Constructへ 設定
何ができるか- RemovalPolicies 基本形 特定のリソース タイプ全部へ設定
何ができるか- RemovalPolicies 基本形 特定のリソース タイプ以外へ設定
何ができるか- RemovalPolicies 応用編 MissingRemobalPolicies ⇒RemovalPolicyの明示的な 設定のない Constructへ設定 RemovalPolicies ⇒問答無用で設 定
何ができるか- RemovalPolicies 応用編 - Priority Priority=優先度 対応ができる
これらの課題はクリアされる 大量のリソースへ 設定したい 検証用にRETAINを 止めたい RDS全部に SNAPSHOT設定したい
RemovalPoliciesの実装秘話
RemovalPoliciesの実装秘話 1. 元ネタの技術記事
機能の元ネタ https://dev.classmethod.jp/articles/aws-cdk-set-removal-policy-all-resources-in-stack/
機能の元ネタ のんピさんありがとう Blogを無効化してしまってごめん https://dev.classmethod.jp/author/non____97/
RemovalPoliciesの実装秘話 2.実装工程
None
• VS Code Extension コーディングエージェント(OSS) ◦ ”必要になれば人間に聞く” Human-in-the-Loop ◦ ”人間に聞かない機能”
Auto Approve • 多彩なツールの実行 ◦ ファイルの作成・編集、コマンド実行 ◦ ヘッドレスブラウザを用いたデバッグ ◦ MCP経由でのPlugin機能 • 多彩なLLM APIの採用 ◦ Amazon Bedrock+Claudeも使用可能 Cline
”流行ってるから適当に言ってんだろ ” https://x.com/_watany/status/1861279373984440580 これが証拠 (2024/11/26)
経緯 Qiitaアドベントカレンダー 2024向けにClineを調べていた
RemovalPoliciesの実装秘話 3.MissingRemovalPolicies
元はこんな実装だった overwrite デフォがMissing~ overwriteを明示で 上書き
元はこんな実装だった それPriority付けたらヤバくないっすか 問題が わかりますか?
元はこんな実装だった それPriority付けたらヤバくないっすか 優先度が高いので retainが適応される 優先度が低いので destroyが後で 適応される
あなたはどっち? 俺の優先度が 高いんだから retainに なれよ! 優先度順 なんだから順番に retain→destroy だろ! https://www.irasutoya.com/2017/12/blog-post_666.html
色々あり、分割しました
ということで RemovalPolicies、超便利なので使ってください https://docs.aws.amazon.com/cdk/api/v2/python/aws_cdk/RemovalPolicies.html
宣伝 初主催のイベントを 4/23(木) オンラインでやるから聞きに来てね https://jawsug.connpass.com/event/348840/ https://x.com/_watany/status/1899298621830361566