Class CfnConfigRule
- All Implemented Interfaces:
IInspectable
,software.amazon.jsii.JsiiSerializable
,software.constructs.IConstruct
,software.constructs.IDependable
You must first create and start the AWS Config configuration recorder in order to create AWS Config managed rules with AWS CloudFormation .
For more information, see Managing the Configuration Recorder .
Adds or updates an AWS Config rule to evaluate if your AWS resources comply with your desired configurations. For information on how many AWS Config rules you can have per account, see Service Limits in the AWS Config Developer Guide .
There are two types of rules: AWS Config Managed Rules and AWS Config Custom Rules . You can use the ConfigRule
resource to create both AWS Config Managed Rules and AWS Config Custom Rules.
AWS Config Managed Rules are predefined, customizable rules created by AWS Config . For a list of managed rules, see List of AWS Config Managed Rules . If you are adding an AWS Config managed rule, you must specify the rule's identifier for the SourceIdentifier
key.
AWS Config Custom Rules are rules that you create from scratch. There are two ways to create AWS Config custom rules: with Lambda functions ( AWS Lambda Developer Guide ) and with Guard ( Guard GitHub Repository ), a policy-as-code language. AWS Config custom rules created with AWS Lambda are called AWS Config Custom Lambda Rules and AWS Config custom rules created with Guard are called AWS Config Custom Policy Rules .
If you are adding a new AWS Config Custom Lambda rule, you first need to create an AWS Lambda function that the rule invokes to evaluate your resources. When you use the ConfigRule
resource to add a Custom Lambda rule to AWS Config , you must specify the Amazon Resource Name (ARN) that AWS Lambda assigns to the function. You specify the ARN in the SourceIdentifier
key. This key is part of the Source
object, which is part of the ConfigRule
object.
For any new AWS Config rule that you add, specify the ConfigRuleName
in the ConfigRule
object. Do not specify the ConfigRuleArn
or the ConfigRuleId
. These values are generated by AWS Config for new rules.
If you are updating a rule that you added previously, you can specify the rule by ConfigRuleName
, ConfigRuleId
, or ConfigRuleArn
in the ConfigRule
data type that you use in this request.
For more information about developing and using AWS Config rules, see Evaluating Resources with AWS Config Rules in the AWS Config Developer Guide .
Example:
// The code below shows an example of how to instantiate this type. // The values are placeholders you should change. import software.amazon.awscdk.services.config.*; Object inputParameters; CfnConfigRule cfnConfigRule = CfnConfigRule.Builder.create(this, "MyCfnConfigRule") .source(SourceProperty.builder() .owner("owner") // the properties below are optional .customPolicyDetails(CustomPolicyDetailsProperty.builder() .enableDebugLogDelivery(false) .policyRuntime("policyRuntime") .policyText("policyText") .build()) .sourceDetails(List.of(SourceDetailProperty.builder() .eventSource("eventSource") .messageType("messageType") // the properties below are optional .maximumExecutionFrequency("maximumExecutionFrequency") .build())) .sourceIdentifier("sourceIdentifier") .build()) // the properties below are optional .compliance(ComplianceProperty.builder() .type("type") .build()) .configRuleName("configRuleName") .description("description") .evaluationModes(List.of(EvaluationModeConfigurationProperty.builder() .mode("mode") .build())) .inputParameters(inputParameters) .maximumExecutionFrequency("maximumExecutionFrequency") .scope(ScopeProperty.builder() .complianceResourceId("complianceResourceId") .complianceResourceTypes(List.of("complianceResourceTypes")) .tagKey("tagKey") .tagValue("tagValue") .build()) .build();
- See Also:
-
Nested Class Summary
Modifier and TypeClassDescriptionstatic final class
A fluent builder forCfnConfigRule
.static interface
Indicates whether an AWS resource or AWS Config rule is compliant and provides the number of contributors that affect the compliance.static interface
Provides the CustomPolicyDetails, the rule owner (AWS
for managed rules,CUSTOM_POLICY
for Custom Policy rules, andCUSTOM_LAMBDA
for Custom Lambda rules), the rule identifier, and the events that cause the evaluation of your AWS resources.static interface
The configuration object for AWS Config rule evaluation mode.static interface
Defines which resources trigger an evaluation for an AWS Config rule.static interface
Provides the source and the message types that trigger AWS Config to evaluate your AWS resources against a rule.static interface
Provides the CustomPolicyDetails, the rule owner (AWS
for managed rules,CUSTOM_POLICY
for Custom Policy rules, andCUSTOM_LAMBDA
for Custom Lambda rules), the rule identifier, and the events that cause the evaluation of your AWS resources.Nested classes/interfaces inherited from class software.amazon.jsii.JsiiObject
software.amazon.jsii.JsiiObject.InitializationMode
Nested classes/interfaces inherited from interface software.constructs.IConstruct
software.constructs.IConstruct.Jsii$Default
Nested classes/interfaces inherited from interface software.amazon.awscdk.IInspectable
IInspectable.Jsii$Default, IInspectable.Jsii$Proxy
-
Field Summary
Modifier and TypeFieldDescriptionstatic final String
The CloudFormation resource type name for this resource class. -
Constructor Summary
ModifierConstructorDescriptionprotected
CfnConfigRule
(software.amazon.jsii.JsiiObject.InitializationMode initializationMode) protected
CfnConfigRule
(software.amazon.jsii.JsiiObjectRef objRef) CfnConfigRule
(software.constructs.Construct scope, String id, CfnConfigRuleProps props) -
Method Summary
Modifier and TypeMethodDescriptionThe Amazon Resource Name (ARN) of the AWS Config rule, such asarn:aws:config:us-east-1:123456789012:config-rule/config-rule-a1bzhi
.Compliance type determined by the Config rule.The ID of the AWS Config rule, such asconfig-rule-a1bzhi
.Indicates whether an AWS resource or AWS Config rule is compliant and provides the number of contributors that affect the compliance.A name for the AWS Config rule.The description that you provide for the AWS Config rule.The modes the AWS Config rule can be evaluated in.A string, in JSON format, that is passed to the AWS Config rule Lambda function.The maximum frequency with which AWS Config runs evaluations for a rule.getScope()
Defines which resources can trigger an evaluation for the rule.Provides the rule owner (AWS
for managed rules,CUSTOM_POLICY
for Custom Policy rules, andCUSTOM_LAMBDA
for Custom Lambda rules), the rule identifier, and the notifications that cause the function to evaluate your AWS resources.void
inspect
(TreeInspector inspector) Examines the CloudFormation resource and discloses attributes.renderProperties
(Map<String, Object> props) void
setCompliance
(IResolvable value) Indicates whether an AWS resource or AWS Config rule is compliant and provides the number of contributors that affect the compliance.void
Indicates whether an AWS resource or AWS Config rule is compliant and provides the number of contributors that affect the compliance.void
setConfigRuleName
(String value) A name for the AWS Config rule.void
setDescription
(String value) The description that you provide for the AWS Config rule.void
setEvaluationModes
(List<Object> value) The modes the AWS Config rule can be evaluated in.void
setEvaluationModes
(IResolvable value) The modes the AWS Config rule can be evaluated in.void
setInputParameters
(Object value) A string, in JSON format, that is passed to the AWS Config rule Lambda function.void
The maximum frequency with which AWS Config runs evaluations for a rule.void
setScope
(IResolvable value) Defines which resources can trigger an evaluation for the rule.void
Defines which resources can trigger an evaluation for the rule.void
setSource
(IResolvable value) Provides the rule owner (AWS
for managed rules,CUSTOM_POLICY
for Custom Policy rules, andCUSTOM_LAMBDA
for Custom Lambda rules), the rule identifier, and the notifications that cause the function to evaluate your AWS resources.void
Provides the rule owner (AWS
for managed rules,CUSTOM_POLICY
for Custom Policy rules, andCUSTOM_LAMBDA
for Custom Lambda rules), the rule identifier, and the notifications that cause the function to evaluate your AWS resources.Methods inherited from class software.amazon.awscdk.CfnResource
addDeletionOverride, addDependency, addDependsOn, addMetadata, addOverride, addPropertyDeletionOverride, addPropertyOverride, applyRemovalPolicy, applyRemovalPolicy, applyRemovalPolicy, getAtt, getAtt, getCfnOptions, getCfnResourceType, getMetadata, getUpdatedProperites, getUpdatedProperties, isCfnResource, obtainDependencies, obtainResourceDependencies, removeDependency, replaceDependency, shouldSynthesize, toString, validateProperties
Methods inherited from class software.amazon.awscdk.CfnRefElement
getRef
Methods inherited from class software.amazon.awscdk.CfnElement
getCreationStack, getLogicalId, getStack, isCfnElement, overrideLogicalId
Methods inherited from class software.constructs.Construct
getNode, isConstruct
Methods inherited from class software.amazon.jsii.JsiiObject
jsiiAsyncCall, jsiiAsyncCall, jsiiCall, jsiiCall, jsiiGet, jsiiGet, jsiiSet, jsiiStaticCall, jsiiStaticCall, jsiiStaticGet, jsiiStaticGet, jsiiStaticSet, jsiiStaticSet
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
Methods inherited from interface software.amazon.jsii.JsiiSerializable
$jsii$toJson
-
Field Details
-
CFN_RESOURCE_TYPE_NAME
The CloudFormation resource type name for this resource class.
-
-
Constructor Details
-
CfnConfigRule
protected CfnConfigRule(software.amazon.jsii.JsiiObjectRef objRef) -
CfnConfigRule
protected CfnConfigRule(software.amazon.jsii.JsiiObject.InitializationMode initializationMode) -
CfnConfigRule
@Stability(Stable) public CfnConfigRule(@NotNull software.constructs.Construct scope, @NotNull String id, @NotNull CfnConfigRuleProps props) - Parameters:
scope
- Scope in which this resource is defined. This parameter is required.id
- Construct identifier for this resource (unique in its scope). This parameter is required.props
- Resource properties. This parameter is required.
-
-
Method Details
-
inspect
Examines the CloudFormation resource and discloses attributes.- Specified by:
inspect
in interfaceIInspectable
- Parameters:
inspector
- tree inspector to collect and process attributes. This parameter is required.
-
renderProperties
@Stability(Stable) @NotNull protected Map<String,Object> renderProperties(@NotNull Map<String, Object> props) - Overrides:
renderProperties
in classCfnResource
- Parameters:
props
- This parameter is required.
-
getAttrArn
The Amazon Resource Name (ARN) of the AWS Config rule, such asarn:aws:config:us-east-1:123456789012:config-rule/config-rule-a1bzhi
. -
getAttrComplianceType
Compliance type determined by the Config rule. -
getAttrConfigRuleId
The ID of the AWS Config rule, such asconfig-rule-a1bzhi
. -
getCfnProperties
- Overrides:
getCfnProperties
in classCfnResource
-
getSource
Provides the rule owner (AWS
for managed rules,CUSTOM_POLICY
for Custom Policy rules, andCUSTOM_LAMBDA
for Custom Lambda rules), the rule identifier, and the notifications that cause the function to evaluate your AWS resources. -
setSource
Provides the rule owner (AWS
for managed rules,CUSTOM_POLICY
for Custom Policy rules, andCUSTOM_LAMBDA
for Custom Lambda rules), the rule identifier, and the notifications that cause the function to evaluate your AWS resources. -
setSource
Provides the rule owner (AWS
for managed rules,CUSTOM_POLICY
for Custom Policy rules, andCUSTOM_LAMBDA
for Custom Lambda rules), the rule identifier, and the notifications that cause the function to evaluate your AWS resources. -
getCompliance
Indicates whether an AWS resource or AWS Config rule is compliant and provides the number of contributors that affect the compliance. -
setCompliance
Indicates whether an AWS resource or AWS Config rule is compliant and provides the number of contributors that affect the compliance. -
setCompliance
Indicates whether an AWS resource or AWS Config rule is compliant and provides the number of contributors that affect the compliance. -
getConfigRuleName
A name for the AWS Config rule. -
setConfigRuleName
A name for the AWS Config rule. -
getDescription
The description that you provide for the AWS Config rule. -
setDescription
The description that you provide for the AWS Config rule. -
getEvaluationModes
The modes the AWS Config rule can be evaluated in. -
setEvaluationModes
The modes the AWS Config rule can be evaluated in. -
setEvaluationModes
The modes the AWS Config rule can be evaluated in. -
getInputParameters
A string, in JSON format, that is passed to the AWS Config rule Lambda function. -
setInputParameters
A string, in JSON format, that is passed to the AWS Config rule Lambda function. -
getMaximumExecutionFrequency
The maximum frequency with which AWS Config runs evaluations for a rule. -
setMaximumExecutionFrequency
The maximum frequency with which AWS Config runs evaluations for a rule. -
getScope
Defines which resources can trigger an evaluation for the rule. -
setScope
Defines which resources can trigger an evaluation for the rule. -
setScope
Defines which resources can trigger an evaluation for the rule.
-