-
Notifications
You must be signed in to change notification settings - Fork 3.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
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*
- Loading branch information
1 parent
448b441
commit 516ecef
Showing
12 changed files
with
944 additions
and
2 deletions.
There are no files selected for viewing
19 changes: 19 additions & 0 deletions
19
...s-config/test/integ.rule-evaluation-mode.js.snapshot/ConfigRuleEvaluationMode.assets.json
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
201 changes: 201 additions & 0 deletions
201
...config/test/integ.rule-evaluation-mode.js.snapshot/ConfigRuleEvaluationMode.template.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,201 @@ | ||
{ | ||
"Resources": { | ||
"CustomFunctionServiceRoleD3F73B79": { | ||
"Type": "AWS::IAM::Role", | ||
"Properties": { | ||
"AssumeRolePolicyDocument": { | ||
"Statement": [ | ||
{ | ||
"Action": "sts:AssumeRole", | ||
"Effect": "Allow", | ||
"Principal": { | ||
"Service": "lambda.amazonaws.com" | ||
} | ||
} | ||
], | ||
"Version": "2012-10-17" | ||
}, | ||
"ManagedPolicyArns": [ | ||
{ | ||
"Fn::Join": [ | ||
"", | ||
[ | ||
"arn:", | ||
{ | ||
"Ref": "AWS::Partition" | ||
}, | ||
":iam::aws:policy/service-role/AWSLambdaBasicExecutionRole" | ||
] | ||
] | ||
}, | ||
{ | ||
"Fn::Join": [ | ||
"", | ||
[ | ||
"arn:", | ||
{ | ||
"Ref": "AWS::Partition" | ||
}, | ||
":iam::aws:policy/service-role/AWSConfigRulesExecutionRole" | ||
] | ||
] | ||
} | ||
] | ||
} | ||
}, | ||
"CustomFunctionBADD59E7": { | ||
"Type": "AWS::Lambda::Function", | ||
"Properties": { | ||
"Code": { | ||
"ZipFile": "exports.handler = (event) => console.log(event);" | ||
}, | ||
"Handler": "index.handler", | ||
"Role": { | ||
"Fn::GetAtt": [ | ||
"CustomFunctionServiceRoleD3F73B79", | ||
"Arn" | ||
] | ||
}, | ||
"Runtime": "nodejs18.x" | ||
}, | ||
"DependsOn": [ | ||
"CustomFunctionServiceRoleD3F73B79" | ||
] | ||
}, | ||
"CustomFunctionCustomRulePermissionbM1jVaicvRO9SDCiAbsQcYrOlESEtMwrrF9ZQQRvd5QED54A3F8": { | ||
"Type": "AWS::Lambda::Permission", | ||
"Properties": { | ||
"Action": "lambda:InvokeFunction", | ||
"FunctionName": { | ||
"Fn::GetAtt": [ | ||
"CustomFunctionBADD59E7", | ||
"Arn" | ||
] | ||
}, | ||
"Principal": "config.amazonaws.com", | ||
"SourceAccount": { | ||
"Ref": "AWS::AccountId" | ||
} | ||
} | ||
}, | ||
"CustomRuleB1CBBADE": { | ||
"Type": "AWS::Config::ConfigRule", | ||
"Properties": { | ||
"EvaluationModes": [ | ||
{ | ||
"Mode": "PROACTIVE" | ||
} | ||
], | ||
"Scope": { | ||
"ComplianceResourceTypes": [ | ||
"AWS::EC2::Instance" | ||
] | ||
}, | ||
"Source": { | ||
"Owner": "CUSTOM_LAMBDA", | ||
"SourceDetails": [ | ||
{ | ||
"EventSource": "aws.config", | ||
"MessageType": "ScheduledNotification" | ||
} | ||
], | ||
"SourceIdentifier": { | ||
"Fn::GetAtt": [ | ||
"CustomFunctionBADD59E7", | ||
"Arn" | ||
] | ||
} | ||
} | ||
}, | ||
"DependsOn": [ | ||
"CustomFunctionCustomRulePermissionbM1jVaicvRO9SDCiAbsQcYrOlESEtMwrrF9ZQQRvd5QED54A3F8", | ||
"CustomFunctionBADD59E7", | ||
"CustomFunctionServiceRoleD3F73B79" | ||
] | ||
}, | ||
"ManagedRule7126A2A0": { | ||
"Type": "AWS::Config::ConfigRule", | ||
"Properties": { | ||
"EvaluationModes": [ | ||
{ | ||
"Mode": "DETECTIVE" | ||
}, | ||
{ | ||
"Mode": "PROACTIVE" | ||
} | ||
], | ||
"Source": { | ||
"Owner": "AWS", | ||
"SourceIdentifier": "API_GW_XRAY_ENABLED" | ||
} | ||
} | ||
}, | ||
"CustomPolicy6CB3FDA5": { | ||
"Type": "AWS::Config::ConfigRule", | ||
"Properties": { | ||
"EvaluationModes": [ | ||
{ | ||
"Mode": "DETECTIVE" | ||
} | ||
], | ||
"Scope": { | ||
"ComplianceResourceTypes": [ | ||
"AWS::DynamoDB::Table" | ||
] | ||
}, | ||
"Source": { | ||
"CustomPolicyDetails": { | ||
"EnableDebugLogDelivery": true, | ||
"PolicyRuntime": "guard-2.x.x", | ||
"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" | ||
}, | ||
"Owner": "CUSTOM_POLICY", | ||
"SourceDetails": [ | ||
{ | ||
"EventSource": "aws.config", | ||
"MessageType": "ConfigurationItemChangeNotification" | ||
}, | ||
{ | ||
"EventSource": "aws.config", | ||
"MessageType": "OversizedConfigurationItemChangeNotification" | ||
} | ||
] | ||
} | ||
} | ||
} | ||
}, | ||
"Parameters": { | ||
"BootstrapVersion": { | ||
"Type": "AWS::SSM::Parameter::Value<String>", | ||
"Default": "/cdk-bootstrap/hnb659fds/version", | ||
"Description": "Version of the CDK Bootstrap resources in this environment, automatically retrieved from SSM Parameter Store. [cdk:skip]" | ||
} | ||
}, | ||
"Rules": { | ||
"CheckBootstrapVersion": { | ||
"Assertions": [ | ||
{ | ||
"Assert": { | ||
"Fn::Not": [ | ||
{ | ||
"Fn::Contains": [ | ||
[ | ||
"1", | ||
"2", | ||
"3", | ||
"4", | ||
"5" | ||
], | ||
{ | ||
"Ref": "BootstrapVersion" | ||
} | ||
] | ||
} | ||
] | ||
}, | ||
"AssertDescription": "CDK bootstrap stack version 6 required. Please run 'cdk bootstrap' with a recent version of the CDK CLI." | ||
} | ||
] | ||
} | ||
} | ||
} |
19 changes: 19 additions & 0 deletions
19
...-mode.js.snapshot/ConfigRuleEvaluationModeTestDefaultTestDeployAssert7587D529.assets.json
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
36 changes: 36 additions & 0 deletions
36
...ode.js.snapshot/ConfigRuleEvaluationModeTestDefaultTestDeployAssert7587D529.template.json
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
1 change: 1 addition & 0 deletions
1
...sting/framework-integ/test/aws-config/test/integ.rule-evaluation-mode.js.snapshot/cdk.out
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
12 changes: 12 additions & 0 deletions
12
...ng/framework-integ/test/aws-config/test/integ.rule-evaluation-mode.js.snapshot/integ.json
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Oops, something went wrong.