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
520
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
99
20240208_CFn_IaC_Gen_with_CDK.pdf
ohmura
1
310
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
AIエージェント元年
shukob
0
150
急成長する企業で作った、エンジニアが輝ける制度/ 20250227 Rinto Ikenoue
shift_evolve
0
120
エンジニアが加速させるプロダクトディスカバリー 〜最速で価値ある機能を見つける方法〜 / product discovery accelerated by engineers
rince
4
560
JavaにおけるNull非許容性
skrb
2
2.6k
実は強い 非ViTな画像認識モデル
tattaka
2
1.2k
AWS Well-Architected Frameworkで学ぶAmazon ECSのセキュリティ対策
umekou
2
140
データベースの負荷を紐解く/untangle-the-database-load
emiki
2
490
EDRの検知の仕組みと検知回避について
chayakonanaika
11
4.7k
OSS構成管理ツールCMDBuildを使ったAWSリソース管理の自動化
satorufunai
0
630
脳波を用いた嗜好マッチングシステム
hokkey621
0
280
Windows の新しい管理者保護モード
murachiakira
0
200
設計を積み重ねてシステムを刷新する
sansantech
PRO
0
160
Featured
See All Featured
The Success of Rails: Ensuring Growth for the Next 100 Years
eileencodes
44
7k
Exploring the Power of Turbo Streams & Action Cable | RailsConf2023
kevinliebholz
30
4.6k
Designing for humans not robots
tammielis
250
25k
YesSQL, Process and Tooling at Scale
rocio
172
14k
Testing 201, or: Great Expectations
jmmastey
42
7.2k
Building Flexible Design Systems
yeseniaperezcruz
328
38k
Done Done
chrislema
182
16k
How to Think Like a Performance Engineer
csswizardry
22
1.4k
Sharpening the Axe: The Primacy of Toolmaking
bcantrill
40
2k
Agile that works and the tools we love
rasmusluckow
328
21k
A Modern Web Designer's Workflow
chriscoyier
693
190k
Performance Is Good for Brains [We Love Speed 2024]
tammyeverts
7
640
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:
[email protected]
Twitter: @yktko