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! 実際どうよ? / Policy as Code with CloudFormation Guard
Search
Yukitaka Ohmura
October 08, 2022
Technology
0
300
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
20240208_CFn_IaC_Gen_with_CDK.pdf
ohmura
1
230
CloudFormation IaC generatorを使った既存AWS環境の管理方法 / Managing existing environment with AWS CFn IaC generator
ohmura
9
2.9k
スタートアップに学ぶイノベーションの起こし方とクラウドの活用方法 / Learning from startup - how to innovate and to use AWS
ohmura
0
83
AWS Well-Architected Framework 2023年10月 アップデート情報 / AWS Well-Architected Framework Oct. 2023 update
ohmura
0
480
Cloud Financial Management ~AWSコストの可視化・最適化・予測・FinOps~ / Cloud Financial Management Overview
ohmura
8
3.6k
What we leaned about CDK from developing BLEA
ohmura
0
48
Other Decks in Technology
See All in Technology
さらばあのボタンとは言わせない SORACOM LTE-M Button powerd by AWSをまだ使えるようにした(前編?)
miura55
0
110
中年男性がメインフレームから クラウドへキャリアシフトしてみた
uechishingo
1
430
MixIT 2024 - Pulumi : Gérer son infra avec son langage de programmation préféré
ju_hnny5
1
130
TiDBにおけるテーブル設計と最適化の事例
cygames
0
490
TDD - Test Driven Drupal
opdavies
0
3k
Prisma ORMを2年運用して培ったノウハウを共有する
tockn
15
3.3k
Amplify 🩷 Bedrock 〜生成AI入門〜
minorun365
PRO
10
1.1k
【NW X Security JAWS#3】L3-4:AWS環境のIPv6移行に向けて知っておきたいこと
shotashiratori
1
730
個人のAWSアカウントをマルチ運用してみた
miura55
2
270
Documentação de Produtos: Artefatos essenciais na prática
rigolon
1
230
多言語化対応における TypeScript の型定義を通して開発のしやすさについて考えた / TSKaigi TypeScript Multilingualization
nabeliwo
2
220
複雑なビジネスルールに挑む:正確性と効率性を両立するfp-tsのチーム活用術 / Strike a balance between correctness and efficiency with fp-ts
kakehashi
4
360
Featured
See All Featured
CoffeeScript is Beautiful & I Never Want to Write Plain JavaScript Again
sstephenson
155
14k
A better future with KSS
kneath
231
16k
Practical Orchestrator
shlominoach
183
9.7k
The Language of Interfaces
destraynor
151
23k
Dealing with People You Can't Stand - Big Design 2015
cassininazir
358
22k
In The Pink: A Labor of Love
frogandcode
138
21k
Optimizing for Happiness
mojombo
370
69k
Distributed Sagas: A Protocol for Coordinating Microservices
caitiem20
323
20k
5 minutes of I Can Smell Your CMS
philhawksworth
199
19k
Design by the Numbers
sachag
274
18k
Bash Introduction
62gerente
605
210k
Designing the Hi-DPI Web
ddemaree
276
33k
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