Class CustomRule
java.lang.Object
software.amazon.jsii.JsiiObject
software.constructs.Construct
software.amazon.awscdk.core.Construct
software.amazon.awscdk.core.Resource
software.amazon.awscdk.services.config.CustomRule
- All Implemented Interfaces:
IConstruct,IDependable,IResource,IRule,software.amazon.jsii.JsiiSerializable,software.constructs.IConstruct
@Generated(value="jsii-pacmak/1.84.0 (build 5404dcf)",
date="2023-06-19T16:30:48.615Z")
@Stability(Stable)
public class CustomRule
extends Resource
implements IRule
A new custom rule.
Example:
// Lambda function containing logic that evaluates compliance with the rule.
Function evalComplianceFn = Function.Builder.create(this, "CustomFunction")
.code(AssetCode.fromInline("exports.handler = (event) => console.log(event);"))
.handler("index.handler")
.runtime(Runtime.NODEJS_14_X)
.build();
// A custom rule that runs on configuration changes of EC2 instances
CustomRule customRule = CustomRule.Builder.create(this, "Custom")
.configurationChanges(true)
.lambdaFunction(evalComplianceFn)
.ruleScope(RuleScope.fromResource(ResourceType.EC2_INSTANCE))
.build();
// A rule to detect stack drifts
CloudFormationStackDriftDetectionCheck driftRule = new CloudFormationStackDriftDetectionCheck(this, "Drift");
// Topic to which compliance notification events will be published
Topic complianceTopic = new Topic(this, "ComplianceTopic");
// Send notification on compliance change events
driftRule.onComplianceChange("ComplianceChange", OnEventOptions.builder()
.target(new SnsTopic(complianceTopic))
.build());
-
Nested Class Summary
Nested ClassesNested classes/interfaces inherited from class software.amazon.jsii.JsiiObject
software.amazon.jsii.JsiiObject.InitializationModeNested classes/interfaces inherited from interface software.amazon.awscdk.core.IConstruct
IConstruct.Jsii$DefaultNested classes/interfaces inherited from interface software.constructs.IConstruct
software.constructs.IConstruct.Jsii$DefaultNested classes/interfaces inherited from interface software.amazon.awscdk.core.IResource
IResource.Jsii$DefaultNested classes/interfaces inherited from interface software.amazon.awscdk.services.config.IRule
IRule.Jsii$Default, IRule.Jsii$Proxy -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedCustomRule(software.amazon.jsii.JsiiObject.InitializationMode initializationMode) protectedCustomRule(software.amazon.jsii.JsiiObjectRef objRef) CustomRule(software.constructs.Construct scope, String id, CustomRuleProps props) -
Method Summary
Modifier and TypeMethodDescriptionstatic IRulefromConfigRuleName(software.constructs.Construct scope, String id, String configRuleName) Imports an existing rule.The arn of the rule.The compliance status of the rule.The id of the rule.The name of the rule.protected Booleanprotected Booleanprotected RuleScopeDefines an EventBridge event rule which triggers for rule compliance events.onComplianceChange(String id, OnEventOptions options) Defines an EventBridge event rule which triggers for rule compliance events.Defines an EventBridge event rule which triggers for rule events.onEvent(String id, OnEventOptions options) Defines an EventBridge event rule which triggers for rule events.Defines an EventBridge event rule which triggers for rule re-evaluation status events.onReEvaluationStatus(String id, OnEventOptions options) Defines an EventBridge event rule which triggers for rule re-evaluation status events.protected voidsetIsCustomWithChanges(Boolean value) protected voidsetIsManaged(Boolean value) protected voidsetRuleScope(RuleScope value) Methods inherited from class software.amazon.awscdk.core.Resource
applyRemovalPolicy, generatePhysicalName, getEnv, getPhysicalName, getResourceArnAttribute, getResourceNameAttribute, getStack, isResourceMethods inherited from class software.amazon.awscdk.core.Construct
getNode, isConstruct, onPrepare, onSynthesize, onValidate, prepare, synthesize, validateMethods inherited from class software.constructs.Construct
toStringMethods inherited from class software.amazon.jsii.JsiiObject
jsiiAsyncCall, jsiiAsyncCall, jsiiCall, jsiiCall, jsiiGet, jsiiGet, jsiiSet, jsiiStaticCall, jsiiStaticCall, jsiiStaticGet, jsiiStaticGet, jsiiStaticSet, jsiiStaticSetMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface software.amazon.awscdk.core.IConstruct
getNodeMethods inherited from interface software.amazon.awscdk.core.IResource
applyRemovalPolicy, getEnv, getStackMethods inherited from interface software.amazon.jsii.JsiiSerializable
$jsii$toJson
-
Constructor Details
-
CustomRule
protected CustomRule(software.amazon.jsii.JsiiObjectRef objRef) -
CustomRule
protected CustomRule(software.amazon.jsii.JsiiObject.InitializationMode initializationMode) -
CustomRule
@Stability(Stable) public CustomRule(@NotNull software.constructs.Construct scope, @NotNull String id, @NotNull CustomRuleProps props) - Parameters:
scope- This parameter is required.id- This parameter is required.props- This parameter is required.
-
-
Method Details
-
fromConfigRuleName
@Stability(Stable) @NotNull public static IRule fromConfigRuleName(@NotNull software.constructs.Construct scope, @NotNull String id, @NotNull String configRuleName) Imports an existing rule.- Parameters:
scope- This parameter is required.id- This parameter is required.configRuleName- the name of the rule. This parameter is required.
-
onComplianceChange
@Stability(Stable) @NotNull public Rule onComplianceChange(@NotNull String id, @Nullable OnEventOptions options) Defines an EventBridge event rule which triggers for rule compliance events.- Specified by:
onComplianceChangein interfaceIRule- Parameters:
id- This parameter is required.options-
-
onComplianceChange
Defines an EventBridge event rule which triggers for rule compliance events.- Specified by:
onComplianceChangein interfaceIRule- Parameters:
id- This parameter is required.
-
onEvent
@Stability(Stable) @NotNull public Rule onEvent(@NotNull String id, @Nullable OnEventOptions options) Defines an EventBridge event rule which triggers for rule events.Use
rule.addEventPattern(pattern)to specify a filter. -
onEvent
Defines an EventBridge event rule which triggers for rule events.Use
rule.addEventPattern(pattern)to specify a filter. -
onReEvaluationStatus
@Stability(Stable) @NotNull public Rule onReEvaluationStatus(@NotNull String id, @Nullable OnEventOptions options) Defines an EventBridge event rule which triggers for rule re-evaluation status events.- Specified by:
onReEvaluationStatusin interfaceIRule- Parameters:
id- This parameter is required.options-
-
onReEvaluationStatus
Defines an EventBridge event rule which triggers for rule re-evaluation status events.- Specified by:
onReEvaluationStatusin interfaceIRule- Parameters:
id- This parameter is required.
-
getConfigRuleArn
The arn of the rule. -
getConfigRuleComplianceType
The compliance status of the rule. -
getConfigRuleId
The id of the rule. -
getConfigRuleName
The name of the rule.- Specified by:
getConfigRuleNamein interfaceIRule
-
getIsCustomWithChanges
-
setIsCustomWithChanges
-
getIsManaged
-
setIsManaged
-
getRuleScope
-
setRuleScope
-