Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Sign up for free
Menu
Search
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Pricing
Search
Sign in
Sign up for free
Guard を利用した AWS Config ルール
Search
yhana
June 12, 2024
Technology
1.3k
0
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
Guard を利用した AWS Config ルール
yhana
June 12, 2024
More Decks by yhana
See All by yhana
20260929_AmazonGuardDutyの検出通知メールにAWS DevOpsAgentの調査結果を追加する
yhana
1
320
AWS Organizations 経験者向けAzure ガバナンス速習
yhana
0
60
20250903_1つのAWSアカウントに複数システムがある環境におけるアクセス制御をABACで実現.pdf
yhana
3
1.5k
AWS Organizations 新機能!マルチパーティ承認の紹介
yhana
1
1.6k
AWS re:Invent 2024 ふりかえり勉強会
yhana
0
1.3k
AWS IAM Identity Center を使わないマルチアカウントのユーザー管理
yhana
2
4.9k
組織的なクラウド統制のはじめの一歩_20240529
yhana
0
1.2k
Azureの基本的な権限管理の勉強会
yhana
1
6.9k
組織的なクラウド統制のはじめの一歩
yhana
0
2.5k
Other Decks in Technology
See All in Technology
メルカリにおけるAI時代の高速プロトタイピング基盤「Arca」
ryotarai
17
13k
Mastering Agentic Development: Harness Engineering for Effective Coding Agents
konippi
3
610
認知負荷を吸収し、プロダクトをまたぐPR Preview基盤の設計事例
taiki45
2
510
あけおめLINE 傾向とその対策
nasa9084
0
340
CI/CDではもう遅い - 人とAIが迂回しないDevSecOps Verify基盤の再設計 -
kintotechdev
1
370
IR Today: Theory, Practice, and Agents
dtunkelang
0
210
HolmesGPTで始めるSREエージェント入門!プラットフォームの障害調査はAIにお任せ 〜
sanghyuk
0
220
なぜ「決定性」が 決定的に重要なのか? Durable Execution 基盤の数理的理解 #serverlessjp / ServerlessDays Tokyo 2026
ytaka23
4
1.3k
【ゲームメーカーズスクランブル2026】『Shadowverse: Worlds Beyond』UIとアニメーションで実現する最高のユーザー体験を叶えるプロトタイピング
cygames
PRO
1
690
.NET WebAssemblyで実現するクライアントサイドAI推論:NuGetからViteまで、2つのエコシステムを繋ぐビルド戦略
yamachu
1
1k
JSONataとAWS Step Functionsで目指すRuntimelessな世界
mu7889yoon
1
540
企業の現実世界をグラフで写し取る
sansantech
PRO
0
170
Featured
See All Featured
The #1 spot is gone: here's how to win anyway
tamaranovitovic
4
1.2k
Are puppies a ranking factor?
jonoalderson
2
4k
No one is an island. Learnings from fostering a developers community.
thoeni
21
3.8k
Future Trends and Review - Lecture 12 - Web Technologies (1019888BNR)
signer
PRO
0
3.8k
The Success of Rails: Ensuring Growth for the Next 100 Years
eileencodes
47
8.3k
Why You Should Never Use an ORM
jnunemaker
PRO
61
10k
We Analyzed 250 Million AI Search Results: Here's What I Found
joshbly
1
2k
How to Align SEO within the Product Triangle To Get Buy-In & Support - #RIMC
aleyda
2
1.8k
Navigating the moral maze — ethical principles for Al-driven product design
skipperchong
2
580
Designing for humans not robots
tammielis
254
26k
AI in Enterprises - Java and Open Source to the Rescue
ivargrimstad
0
1.5k
Noah Learner - AI + Me: how we built a GSC Bulk Export data pipeline
techseoconnect
PRO
0
440
Transcript
Guard を利⽤した AWS Config ルール 1 2024.6.12 yhana
• AWS Config ルールの概要 • Guard で作成する AWS Config ルール
• Guard の評価ルール作成の役⽴ち情報 2 今⽇話すこと
3 AWS Config ルール
4 AWS Config サービスの⼀機能であり、 AWS リソースの設定が指定したルールに準拠しているかどうかを確認できる AWS Config ルールの概要
5 AWS が提供している Config ルールの例 AWS Security Hub の裏では Config
ルールが利⽤されている AWS Config ルールの概要 ルール名 ルールの確認内容 iam-user-mfa-enable IAM ユーザーの MFA が設定されているか vpc-flow-logs-enabled VPC フローログが有効化されているか ec2-ebs-encryption-by-default EBS 暗号化がデフォルトで有効になっているか cloudtrail-enabled AWS CloudTrail 証跡が有効になっているか
6 AWS Config ルールの種類 AWS Config ルールの概要 種別 評価ルールの作成⼿段 補⾜説明
マネージドルール AWS による管理 マネージドルールのリスト カスタムルール AWS Lambda 最も柔軟な評価が可能 AWS CloudFormation Guard ドメイン固有⾔語(Domain Specific Language) 今⽇の話
7 Guard で作成する AWS Config ルール
8 AWS CloudFormation Guard はオープンソースの ドメイン固有⾔語 (DSL : Domain Specific
Language) と CLI AWS CloudFormation Guard という名前の通り、 CloudFormation テンプレートのポリシーのチェックに利⽤可能 2022 年 8 ⽉に Config ルールが Guard に対応 AWS CloudFormation Guard を使⽤した AWS Config ルールの作成 AWS CloudFormation Guard の概要
9 AWS Lambda より簡易な記載で評価ルールの作成が可能 VPC が「デフォルト VPC でないこと」を確認する評価ルール デフォルト VPC
であることを⽰すパラメータが false であることを確認 「no_default_vpc」はルール名であり、任意の命名が可能 AWS CloudFormation Guard の概要 rule no_default_vpc { configuration.isDefault == false }
10 AWS Config レコーダーで取得している設定情報を評価する AWS CloudFormation Guard の概要 AWS Config
が取得している VPC の設定情報 rule no_default_vpc { configuration.isDefault == false } 評価が True (is.Default == false) であれば、準拠 評価が False (is.Default != false) であれば、⾮準拠
11 評価ルールを直接指定 2024.6.10 時点では ランタイムバージョンは単⼀ デバッグログの有効化により 評価詳細を CloudWatch Logs に出⼒
Guard を利⽤した Config ルール作成の設定画⾯
12 「変更範囲」の設定から 対象リソースを指定 VPC だけ確認するために 「AWS EC2 VPC」を選択 Guard を利⽤した
Config ルール作成の設定画⾯
13 評価結果と CloudWatch Logs に出⼒されるログ AWS CloudFormation Guard の概要 ConfigRuleId:
config-rule-g54mba, ResourceType: AWS::EC2::VPC, ResourceId: vpc-08fb9b456e5d5ede6 { "not_compliant": { "no_default_vpc": [ { "rule": "no_default_vpc", "path": "/configuration/isDefault", "provided": true, "expected": false, "comparison": { "operator": "Eq", "not_operator_exists": false }, "message": "" } ] }, "not_applicable": [], "compliant": [] } ConfigRuleId: config-rule-g54mba, ResourceType: AWS::EC2::VPC, ResourceId: vpc-0adcdeb95ec11d011 { "not_compliant": {}, "not_applicable": [], "compliant": [ "no_default_vpc" ] }
14 評価ルールの例
15 複数の条件を組み合わせる例 「デフォルト VPC ではない」かつ「Internet Gateway 割り当てなし」で準拠 評価ルールの例 - 1
rule vpc_check { configuration.isDefault == false relationships[*].resourceType != "AWS::EC2::InternetGateway" }
16 複数の条件を組み合わせる例 「デフォルト VPC ではない」かつ「Internet Gateway 割り当てなし」で準拠 評価ルールの例 - 1
rule vpc_check { configuration.isDefault == false relationships[*].resourceType != "AWS::EC2::InternetGateway" } 複数のルールブロックを記載した場合は暗黙の AND 評価で最終的な評価が決定
17 複数の条件を組み合わせる場合の評価 評価ルールの例 - 1 check-1 check-2 check-1 and check-2
(暗黙の AND 評価) rule check-1 rule check-2 when check-1 もし check-1 が「true」なら check2 (check-1 を再利⽤) check-1 or check-2 check-1 or check-2 (OR 評価は明⽰的に記載)
18 評価ルールの例 - 1 rule vpc_check { configuration.isDefault == false
relationships[*].resourceType != "AWS::EC2::InternetGateway" } AWS::EC2::InternetGateway 評価 AWS::EC2::InternetGateway 評価 AWS::EC2::InternetGateway 評価 AWS::EC2::InternetGateway 評価 AWS::EC2::InternetGateway 評価 配列の評価のイメージ
19 名前が prd から始まる S3 バケットのバージョニングが有効か確認したい場合 上記の記載でも評価はできるが、prd から始まらないバケットも表⽰される 評価ルールの例 -
2 rule s3_check { resourceId == /^prd-.*$/ supplementaryConfiguration.BucketVersioningConfiguration.status == "Enabled" }
20 ちょっとしたテクニックとして、 マネジメントコンソールに表⽰される評価結果のリソースを絞る例 評価ルールの例 - 2 let resource_name = resourceId
rule s3_check when %resource_name == /^prd-.*$/ { supplementaryConfiguration.BucketVersioningConfiguration.status == "Enabled" }
21 評価結果には PASS/FAIL の他に SKIP が存在 評価結果が SKIP のリソースはマネジメントコンソール上では表⽰されない 名前が
prd から始まらないバケットの評価イメージ 評価ルールの例 - 2 let resource_name = resourceId rule s3_check when %resource_name == /^prd-.*$/ { supplementaryConfiguration.BucketVersioningConfiguration.status == "Enabled" } バケット名が prd から始まらない場合に評価結果は SKIP となり、 マネジメントコンソールの評価結果には表⽰されない
22 評価結果には PASS/FAIL の他に SKIP が存在 評価結果が SKIP のリソースはマネジメントコンソールに表⽰されない 名前が
prd から始まるバケットの評価イメージ 評価ルールの例 - 2 let resource_name = resourceId rule s3_check when %resource_name == /^prd-.*$/ { supplementaryConfiguration.BucketVersioningConfiguration.status == "Enabled" } バケット名が prd から始まる場合はルールブロック内が評価され、 PASS/FAIL のいずれかの評価でマネジメントコンソールに表⽰される
23 Guard の評価ルール作成の役⽴ち情報
24 Guard の⽂法に関するドキュメント GitHub cloudformation-guard/docs at main · aws-cloudformation/cloudformation-guard AWSユーザーガイド
Getting started with AWS CloudFormation Guard - AWS CloudFormation Guard AWS Config の設定情報のスキーマ GitHub aws-config-resource-schema/config/properties/resource-types at master · awslabs/aws- config-resource-schema 評価ルールを作成する際に役⽴つ資料
25 VPC リソースのスキーマ 評価ルールを作成する際に役⽴つ資料 aws-config-resource-schema/config/properties/resource-types/AWS::EC2::VPC.properties.json at master · awslabs/aws- config-resource-schema
26 サンプルプログラム(CloudFormation テンプレートが対象) GitHub cloudformation-guard/guard-examples at main · aws-cloudformation/cloudformation-guard 評価ルールを作成する際に役⽴つ資料
27 ローカルで単位テストが可能(AWS CloudFormation Guard の単体テスト機能を試してみた) 単体テストに必要なもの #1 : Guard ルールのファイル
#2 : 単体テストのファイル ローカル環境のテスト rule no_default_vpc { configuration.isDefault == false } --- - name: MyTest input: expectations: rules: no_default_vpc: FAIL #1 check_default_vpc.guard #2 check_default_vpc_test.yaml AWS Config の設定情報を記載(または転記)
28 期待は⾮準拠、結果も⾮準拠のテスト結果 期待は準拠、結果は⾮準拠のテスト結果 ローカル環境のテスト $ cfn-guard test --rules-file check_default_vpc.guard --test-data
check_default_vpc_test.yaml Test Case #1 Name: "MyTest" PASS Rules: no_default_vpc: Expected = FAIL % cfn-guard test --rules-file check_default_vpc.guard --test-data check_default_vpc_test.yaml Test Case #1 Name: "MyTest" FAIL Rules: no_default_vpc: Expected = PASS, Evaluated = [FAIL]
29 さいごに
30 Guard を利⽤した Config ルールの簡単な例と関連情報を紹介 まずは Security Hub や AWS
管理のマネージドルールの利⽤を推奨 1. Security Hub で実現できるか 2. マネージドルールで実現できるか 3. カスタムルール(Guard)で実現できるか 4. カスタムルール(Lambda)で実現 Guard が適さない例 - AWS Config レコーダーが対応していないリソース - 複雑な処理が必要な評価 さいごに
31