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
CloudFormation Guard で Policy as Code! 実際どうよ? /...
Search
Yukitaka Ohmura
October 08, 2022
Technology
0
530
CloudFormation Guard で Policy as Code! 実際どうよ? / Policy as Code with CloudFormation Guard
「JAWS DAYS 2022 AWS SA/エキスパート 怒涛のLTチャレンジ」(
https://jawsdays2022.jaws-ug.jp/
) でお話ししたLTの資料です。
Yukitaka Ohmura
October 08, 2022
Tweet
Share
More Decks by Yukitaka Ohmura
See All by Yukitaka Ohmura
JAWS-UG ちばらき 地味でも大事な re:Invent 2024 / JAWS-UG chibaraki Enjoy cool and unaware feature at pre:Invent 2024
ohmura
3
100
20240208_CFn_IaC_Gen_with_CDK.pdf
ohmura
1
320
CloudFormation IaC generatorを使った既存AWS環境の管理方法 / Managing existing environment with AWS CFn IaC generator
ohmura
9
3.5k
スタートアップに学ぶイノベーションの起こし方とクラウドの活用方法 / Learning from startup - how to innovate and to use AWS
ohmura
0
150
AWS Well-Architected Framework 2023年10月 アップデート情報 / AWS Well-Architected Framework Oct. 2023 update
ohmura
0
750
Cloud Financial Management ~AWSコストの可視化・最適化・予測・FinOps~ / Cloud Financial Management Overview
ohmura
8
4.6k
What we leaned about CDK from developing BLEA
ohmura
0
76
Other Decks in Technology
See All in Technology
1行のコードから社会課題の解決へ: EMの探究、事業・技術・組織を紡ぐ実践知 / EM Conf 2025
9ma3r
12
4.2k
システム・ML活用を広げるdbtのデータモデリング / Expanding System & ML Use with dbt Modeling
i125
1
340
AI自体のOps 〜LLMアプリの運用、AWSサービスとOSSの使い分け〜
minorun365
PRO
7
520
株式会社Awarefy(アウェアファイ)会社説明資料 / Awarefy-Company-Deck
awarefy
3
11k
AWSアカウントのセキュリティ自動化、どこまで進める? 最適な設計と実践ポイント
yuobayashi
7
850
生成AI “再”入門 2025年春@WIRED TUESDAY EDITOR'S LOUNGE
kajikent
0
140
Introduction to OpenSearch Project - Search Engineering Tech Talk 2025 Winter
tkykenmt
2
120
Ruby on Railsで持続可能な開発を行うために取り組んでいること
am1157154
3
160
AIエージェント入門
minorun365
PRO
32
19k
データエンジニアリング領域におけるDuckDBのユースケース
chanyou0311
9
2.3k
IAMのマニアックな話2025
nrinetcom
PRO
6
1.2k
AWSを活用したIoTにおけるセキュリティ対策のご紹介
kwskyk
0
400
Featured
See All Featured
Art, The Web, and Tiny UX
lynnandtonic
298
20k
Easily Structure & Communicate Ideas using Wireframe
afnizarnur
193
16k
Building a Modern Day E-commerce SEO Strategy
aleyda
38
7.1k
Designing for humans not robots
tammielis
250
25k
Gamification - CAS2011
davidbonilla
80
5.2k
Exploring the Power of Turbo Streams & Action Cable | RailsConf2023
kevinliebholz
30
4.6k
We Have a Design System, Now What?
morganepeng
51
7.4k
How GitHub (no longer) Works
holman
314
140k
A designer walks into a library…
pauljervisheath
205
24k
Principles of Awesome APIs and How to Build Them.
keavy
126
17k
Code Reviewing Like a Champion
maltzj
521
39k
The Web Performance Landscape in 2024 [PerfNow 2024]
tammyeverts
4
430
Transcript
© 2022, Amazon Web Services, Inc. or its affiliates. ©
2022, Amazon Web Services, Inc. or its affiliates. ⼤村 幸敬 Manager, Solutions Architect Amazon Web Services Japan 2022/10/08 CloudFormation Guard で Policy as Code︕ 実際どうよ︖ J AW S D AY S 2 0 2 2 AW S S A / エ キ ス パ ー ト 怒 涛 の LT チ ャ レ ン ジ
© 2022, Amazon Web Services, Inc. or its affiliates. ⼤村
幸敬(おおむら ゆきたか) 部⻑ / シニア ソリューションアーキテクト • これからクラウドを使いはじめる エンタープライズ企業をサポート • 運⽤系サービス & DevOps 系サービスをリード • Baseline Environment on AWS (BLEA) 開発者 好きなAWSのサービス︓ AWS Command Line Interface (CLI) AWS Cloud Development Kit (CDK) AWS Systems Manager Incident Manager @yktko 2
© 2022, Amazon Web Services, Inc. or its affiliates. ©
2022, Amazon Web Services, Inc. or its affiliates. Policy as Code 3
© 2022, Amazon Web Services, Inc. or its affiliates. Policy
as Code が実現する世界 開発から運⽤までいずれの⼯程でもシステム環境が ポリシーに適合していることをコードで検証できる 4 CFn 検証 コーディング デプロイ 稼働環境 ポリシーコード (従うべきセキュリティ等を定義) CloudFormation (CFn) 検証 検証 CloudFormation テンプレート
© 2022, Amazon Web Services, Inc. or its affiliates. Policy
as Code on AWS の現状 1. CFnテンプレートの検証: cfn-guard, cfn_nag, cfn-lint 2. CFnデプロイ時の 予防的ガードレール: CFn Hooks 3. 稼働環境の 発⾒的ガードレール: AWS Config Rules 5 CFn cfn-guard コーディング デプロイ 稼働環境 CloudFormation CFn Hooks Config Rules (カスタムルール) CloudFormation テンプレート
© 2022, Amazon Web Services, Inc. or its affiliates. Policy
as Code on AWS の課題 • 同じポリシーを異なる形式で定義する必要がある § cfn-guard → Guard DSLで定義 § AWS Config Rules → Lambdaコード+RDK*で定義 6 CFn cfn-guard コーディング デプロイ 稼働環境 CloudFormation Config Rules (カスタムルール) CloudFormation テンプレート *RDK = Rule Development Kit https://github.com/awslabs/aws-config-rdk CFn Guard DSL Lambda+ RDK
© 2022, Amazon Web Services, Inc. or its affiliates. Config
Rules を CFn Guard DSLで定義可能に 7 Q: 同じDSLでCFnテンプレートも 実環境も検証できるのでは︖ CFn cfn-guard コーディング デプロイ 稼働中環境 CloudFormation Config Rules (w/CFn Guard DSL) CloudFormation テンプレート CFn Guard DSL
© 2022, Amazon Web Services, Inc. or its affiliates. ©
2022, Amazon Web Services, Inc. or its affiliates. やってみた 8
© 2022, Amazon Web Services, Inc. or its affiliates. ©
2022, Amazon Web Services, Inc. or its affiliates. の前に CFn Guard おさらい 9
© 2022, Amazon Web Services, Inc. or its affiliates. AWS
CloudFormation Guard (CFn Guard) • 2020年10⽉ CFn Guard 1.0 がリリース • 2021年5⽉ 2.0 がリリースされ DSLが⼤きく変更(1.0と⾮互換) • 2022年6⽉ 2.1 がリリース • 2022年8⽉ Config Rules が CFn Guard DSL に対応 10 https://github.com/aws-cloudformation/cloudformation-guard
© 2022, Amazon Web Services, Inc. or its affiliates. CFn
Guard (フェーズ1: ルールとテストを書く) 11 S3が暗号化されていることを 検証するルール (Guard DSL) s3-encrypt.guard ルールのテストコード (YAML) s3-encrypt_tests.yaml ルールのテスト実⾏ (Guard CLI) すべてのテストが意図した結果になり テストをPASSしている
© 2022, Amazon Web Services, Inc. or its affiliates. CFn
Guard (フェーズ2: CFnテンプレートの検証) 12 S3が暗号化されていることを 検証するルール (Guard DSL) s3-encrypt.guard CFnテンプレ (S3バケット暗号化あり) ルールで検証(PASS) s3-encrypted.yaml s3-un-encrypted.yaml CFnテンプレ (S3バケット暗号化なし) ルールで検証(FAIL)
© 2022, Amazon Web Services, Inc. or its affiliates. ©
2022, Amazon Web Services, Inc. or its affiliates. AWS Config Rules を CFn Guard DSLで定義 13
© 2022, Amazon Web Services, Inc. or its affiliates. 同じDSLで
CFnテンプレート と Config を検証するルール (Parameterized Rules) 14 https://github.com/aws-cloudformation/cloudformation-guard/releases/tag/2.1.0 For CFn For CFn For Config For Config 共通のルールへそれぞれから適したパラメータを渡す サンプルルールの内容(抜粋) CFn Guard GitHubのサンプルコード CFnテンプレートの検証はOK︕ (中略)
© 2022, Amazon Web Services, Inc. or its affiliates. Parameterized
Rulesサンプルで Config Rules を定義する 15 https://aws.amazon.com/jp/blogs/mt/announcing-aws-config-custom-rules-using-guard-custom-policy/
© 2022, Amazon Web Services, Inc. or its affiliates. Parameterized
Rulesサンプルで Config Rules を定義する 16
© 2022, Amazon Web Services, Inc. or its affiliates. Parameterized
Rulesサンプルで Config Rules を定義する 17 😇
© 2022, Amazon Web Services, Inc. or its affiliates. Parameterized
Rulesサンプルで Config Rules を定義する 18 😭
© 2022, Amazon Web Services, Inc. or its affiliates. ©
2022, Amazon Web Services, Inc. or its affiliates. (今は)できませんでした 19
© 2022, Amazon Web Services, Inc. or its affiliates. まとめ
20 Q: 同じGuard DSLで CFnテンプレートも実環境も検証できるのでは︖ A: もう少し、こなれてくる必要がありそう CFn cfn-guard コーディング デプロイ 稼働中環境 CloudFormation Config Rules (w/CFn Guard DSL) CloudFormation テンプレート CFn Guard DSL
© 2022, Amazon Web Services, Inc. or its affiliates. まとめ
21 CloudFormationテンプレートの検証に Config カスタムルールの開発に CFn Guard それぞれお試しください︕ CFn cfn-guard コーディング デプロイ 稼働環境 CloudFormation CFn Hooks Config Rules (カスタムルール w/CFn Guard) CloudFormation テンプレート
© 2022, Amazon Web Services, Inc. or its affiliates. ©
2022, Amazon Web Services, Inc. or its affiliates. Thank you ! 22 Email: ohmurayu@amazon.co.jp Twitter: @yktko