Skip to content

Commit 516ecef

Browse files
feat(config): proactive evaluation mode (#30174)
### Issue # (if applicable) Closes #30172. ### Reason for this change AWS Config supports for proactive evaluation mode but L2 construct cannot configure it. ### Description of changes - Define `EvaluationMode` class - Add `evaluationModes` prop to `RuleProps` ```ts new config.ManagedRule(stack, 'ManagedRule', { identifier: config.ManagedRuleIdentifiers.API_GW_XRAY_ENABLED, evaluationModes: config.EvaluationMode.DETECTIVE_AND_PROACTIVE, // add }); ``` ### Description of how you validated changes Add both unit and integ tests. ### Checklist - [x] My code adheres to the [CONTRIBUTING GUIDE](https://github.com/aws/aws-cdk/blob/main/CONTRIBUTING.md) and [DESIGN GUIDELINES](https://github.com/aws/aws-cdk/blob/main/docs/DESIGN_GUIDELINES.md) ---- *By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
1 parent 448b441 commit 516ecef

12 files changed

+944
-2
lines changed

packages/@aws-cdk-testing/framework-integ/test/aws-config/test/integ.rule-evaluation-mode.js.snapshot/ConfigRuleEvaluationMode.assets.json

Lines changed: 19 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,201 @@
1+
{
2+
"Resources": {
3+
"CustomFunctionServiceRoleD3F73B79": {
4+
"Type": "AWS::IAM::Role",
5+
"Properties": {
6+
"AssumeRolePolicyDocument": {
7+
"Statement": [
8+
{
9+
"Action": "sts:AssumeRole",
10+
"Effect": "Allow",
11+
"Principal": {
12+
"Service": "lambda.amazonaws.com"
13+
}
14+
}
15+
],
16+
"Version": "2012-10-17"
17+
},
18+
"ManagedPolicyArns": [
19+
{
20+
"Fn::Join": [
21+
"",
22+
[
23+
"arn:",
24+
{
25+
"Ref": "AWS::Partition"
26+
},
27+
":iam::aws:policy/service-role/AWSLambdaBasicExecutionRole"
28+
]
29+
]
30+
},
31+
{
32+
"Fn::Join": [
33+
"",
34+
[
35+
"arn:",
36+
{
37+
"Ref": "AWS::Partition"
38+
},
39+
":iam::aws:policy/service-role/AWSConfigRulesExecutionRole"
40+
]
41+
]
42+
}
43+
]
44+
}
45+
},
46+
"CustomFunctionBADD59E7": {
47+
"Type": "AWS::Lambda::Function",
48+
"Properties": {
49+
"Code": {
50+
"ZipFile": "exports.handler = (event) => console.log(event);"
51+
},
52+
"Handler": "index.handler",
53+
"Role": {
54+
"Fn::GetAtt": [
55+
"CustomFunctionServiceRoleD3F73B79",
56+
"Arn"
57+
]
58+
},
59+
"Runtime": "nodejs18.x"
60+
},
61+
"DependsOn": [
62+
"CustomFunctionServiceRoleD3F73B79"
63+
]
64+
},
65+
"CustomFunctionCustomRulePermissionbM1jVaicvRO9SDCiAbsQcYrOlESEtMwrrF9ZQQRvd5QED54A3F8": {
66+
"Type": "AWS::Lambda::Permission",
67+
"Properties": {
68+
"Action": "lambda:InvokeFunction",
69+
"FunctionName": {
70+
"Fn::GetAtt": [
71+
"CustomFunctionBADD59E7",
72+
"Arn"
73+
]
74+
},
75+
"Principal": "config.amazonaws.com",
76+
"SourceAccount": {
77+
"Ref": "AWS::AccountId"
78+
}
79+
}
80+
},
81+
"CustomRuleB1CBBADE": {
82+
"Type": "AWS::Config::ConfigRule",
83+
"Properties": {
84+
"EvaluationModes": [
85+
{
86+
"Mode": "PROACTIVE"
87+
}
88+
],
89+
"Scope": {
90+
"ComplianceResourceTypes": [
91+
"AWS::EC2::Instance"
92+
]
93+
},
94+
"Source": {
95+
"Owner": "CUSTOM_LAMBDA",
96+
"SourceDetails": [
97+
{
98+
"EventSource": "aws.config",
99+
"MessageType": "ScheduledNotification"
100+
}
101+
],
102+
"SourceIdentifier": {
103+
"Fn::GetAtt": [
104+
"CustomFunctionBADD59E7",
105+
"Arn"
106+
]
107+
}
108+
}
109+
},
110+
"DependsOn": [
111+
"CustomFunctionCustomRulePermissionbM1jVaicvRO9SDCiAbsQcYrOlESEtMwrrF9ZQQRvd5QED54A3F8",
112+
"CustomFunctionBADD59E7",
113+
"CustomFunctionServiceRoleD3F73B79"
114+
]
115+
},
116+
"ManagedRule7126A2A0": {
117+
"Type": "AWS::Config::ConfigRule",
118+
"Properties": {
119+
"EvaluationModes": [
120+
{
121+
"Mode": "DETECTIVE"
122+
},
123+
{
124+
"Mode": "PROACTIVE"
125+
}
126+
],
127+
"Source": {
128+
"Owner": "AWS",
129+
"SourceIdentifier": "API_GW_XRAY_ENABLED"
130+
}
131+
}
132+
},
133+
"CustomPolicy6CB3FDA5": {
134+
"Type": "AWS::Config::ConfigRule",
135+
"Properties": {
136+
"EvaluationModes": [
137+
{
138+
"Mode": "DETECTIVE"
139+
}
140+
],
141+
"Scope": {
142+
"ComplianceResourceTypes": [
143+
"AWS::DynamoDB::Table"
144+
]
145+
},
146+
"Source": {
147+
"CustomPolicyDetails": {
148+
"EnableDebugLogDelivery": true,
149+
"PolicyRuntime": "guard-2.x.x",
150+
"PolicyText": "\n# This rule checks if point in time recovery (PITR) is enabled on active Amazon DynamoDB tables\nlet status = ['ACTIVE']\n\nrule tableisactive when\n resourceType == \"AWS::DynamoDB::Table\" {\n configuration.tableStatus == %status\n}\n\nrule checkcompliance when\n resourceType == \"AWS::DynamoDB::Table\"\n tableisactive {\n let pitr = supplementaryConfiguration.ContinuousBackupsDescription.pointInTimeRecoveryDescription.pointInTimeRecoveryStatus\n %pitr == \"ENABLED\"\n}\n"
151+
},
152+
"Owner": "CUSTOM_POLICY",
153+
"SourceDetails": [
154+
{
155+
"EventSource": "aws.config",
156+
"MessageType": "ConfigurationItemChangeNotification"
157+
},
158+
{
159+
"EventSource": "aws.config",
160+
"MessageType": "OversizedConfigurationItemChangeNotification"
161+
}
162+
]
163+
}
164+
}
165+
}
166+
},
167+
"Parameters": {
168+
"BootstrapVersion": {
169+
"Type": "AWS::SSM::Parameter::Value<String>",
170+
"Default": "/cdk-bootstrap/hnb659fds/version",
171+
"Description": "Version of the CDK Bootstrap resources in this environment, automatically retrieved from SSM Parameter Store. [cdk:skip]"
172+
}
173+
},
174+
"Rules": {
175+
"CheckBootstrapVersion": {
176+
"Assertions": [
177+
{
178+
"Assert": {
179+
"Fn::Not": [
180+
{
181+
"Fn::Contains": [
182+
[
183+
"1",
184+
"2",
185+
"3",
186+
"4",
187+
"5"
188+
],
189+
{
190+
"Ref": "BootstrapVersion"
191+
}
192+
]
193+
}
194+
]
195+
},
196+
"AssertDescription": "CDK bootstrap stack version 6 required. Please run 'cdk bootstrap' with a recent version of the CDK CLI."
197+
}
198+
]
199+
}
200+
}
201+
}

packages/@aws-cdk-testing/framework-integ/test/aws-config/test/integ.rule-evaluation-mode.js.snapshot/ConfigRuleEvaluationModeTestDefaultTestDeployAssert7587D529.assets.json

Lines changed: 19 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/@aws-cdk-testing/framework-integ/test/aws-config/test/integ.rule-evaluation-mode.js.snapshot/ConfigRuleEvaluationModeTestDefaultTestDeployAssert7587D529.template.json

Lines changed: 36 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/@aws-cdk-testing/framework-integ/test/aws-config/test/integ.rule-evaluation-mode.js.snapshot/cdk.out

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/@aws-cdk-testing/framework-integ/test/aws-config/test/integ.rule-evaluation-mode.js.snapshot/integ.json

Lines changed: 12 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)