@Generated(value="jsii-pacmak/1.67.0 (build 2c027f5)", date="2022-09-19T20:26:37.739Z") @Stability(value=Stable) public class CustomRule extends Resource implements IRule
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());
| Modifier and Type | Class and Description |
|---|---|
static class |
CustomRule.Builder
A fluent builder for
CustomRule. |
software.amazon.jsii.JsiiObject.InitializationModeIRule.Jsii$Default, IRule.Jsii$Proxy| Modifier | Constructor and Description |
|---|---|
|
CustomRule(software.constructs.Construct scope,
String id,
CustomRuleProps props) |
protected |
CustomRule(software.amazon.jsii.JsiiObject.InitializationMode initializationMode) |
protected |
CustomRule(software.amazon.jsii.JsiiObjectRef objRef) |
| Modifier and Type | Method and Description |
|---|---|
static IRule |
fromConfigRuleName(software.constructs.Construct scope,
String id,
String configRuleName)
Imports an existing rule.
|
String |
getConfigRuleArn()
The arn of the rule.
|
String |
getConfigRuleComplianceType()
The compliance status of the rule.
|
String |
getConfigRuleId()
The id of the rule.
|
String |
getConfigRuleName()
The name of the rule.
|
protected Boolean |
getIsCustomWithChanges() |
protected Boolean |
getIsManaged() |
protected RuleScope |
getRuleScope() |
Rule |
onComplianceChange(String id)
Defines an EventBridge event rule which triggers for rule compliance events.
|
Rule |
onComplianceChange(String id,
OnEventOptions options)
Defines an EventBridge event rule which triggers for rule compliance events.
|
Rule |
onEvent(String id)
Defines an EventBridge event rule which triggers for rule events.
|
Rule |
onEvent(String id,
OnEventOptions options)
Defines an EventBridge event rule which triggers for rule events.
|
Rule |
onReEvaluationStatus(String id)
Defines an EventBridge event rule which triggers for rule re-evaluation status events.
|
Rule |
onReEvaluationStatus(String id,
OnEventOptions options)
Defines an EventBridge event rule which triggers for rule re-evaluation status events.
|
protected void |
setIsCustomWithChanges(Boolean value) |
protected void |
setIsManaged(Boolean value) |
protected void |
setRuleScope(RuleScope value) |
applyRemovalPolicy, generatePhysicalName, getEnv, getPhysicalName, getResourceArnAttribute, getResourceNameAttribute, getStack, isOwnedResource, isResourcejsiiAsyncCall, jsiiAsyncCall, jsiiCall, jsiiCall, jsiiGet, jsiiGet, jsiiSet, jsiiStaticCall, jsiiStaticCall, jsiiStaticGet, jsiiStaticGet, jsiiStaticSet, jsiiStaticSetclone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitapplyRemovalPolicy, getEnv, getStackprotected CustomRule(software.amazon.jsii.JsiiObjectRef objRef)
protected CustomRule(software.amazon.jsii.JsiiObject.InitializationMode initializationMode)
@Stability(value=Stable)
public CustomRule(@NotNull
software.constructs.Construct scope,
@NotNull
String id,
@NotNull
CustomRuleProps props)
scope - This parameter is required.id - This parameter is required.props - This parameter is required.@Stability(value=Stable) @NotNull public static IRule fromConfigRuleName(@NotNull software.constructs.Construct scope, @NotNull String id, @NotNull String configRuleName)
scope - This parameter is required.id - This parameter is required.configRuleName - the name of the rule. This parameter is required.@Stability(value=Stable) @NotNull public Rule onComplianceChange(@NotNull String id, @Nullable OnEventOptions options)
onComplianceChange in interface IRuleid - This parameter is required.options - @Stability(value=Stable) @NotNull public Rule onComplianceChange(@NotNull String id)
onComplianceChange in interface IRuleid - This parameter is required.@Stability(value=Stable) @NotNull public Rule onEvent(@NotNull String id, @Nullable OnEventOptions options)
Use
rule.addEventPattern(pattern) to specify a filter.
@Stability(value=Stable) @NotNull public Rule onEvent(@NotNull String id)
Use
rule.addEventPattern(pattern) to specify a filter.
@Stability(value=Stable) @NotNull public Rule onReEvaluationStatus(@NotNull String id, @Nullable OnEventOptions options)
onReEvaluationStatus in interface IRuleid - This parameter is required.options - @Stability(value=Stable) @NotNull public Rule onReEvaluationStatus(@NotNull String id)
onReEvaluationStatus in interface IRuleid - This parameter is required.@Stability(value=Stable) @NotNull public String getConfigRuleArn()
@Stability(value=Stable) @NotNull public String getConfigRuleComplianceType()
@Stability(value=Stable) @NotNull public String getConfigRuleId()
@Stability(value=Stable) @NotNull public String getConfigRuleName()
getConfigRuleName in interface IRule@Stability(value=Stable) @Nullable protected Boolean getIsCustomWithChanges()
@Stability(value=Stable)
protected void setIsCustomWithChanges(@Nullable
Boolean value)
@Stability(value=Stable) @Nullable protected Boolean getIsManaged()
@Stability(value=Stable)
protected void setIsManaged(@Nullable
Boolean value)
@Stability(value=Stable) @Nullable protected RuleScope getRuleScope()
@Stability(value=Stable)
protected void setRuleScope(@Nullable
RuleScope value)
Copyright © 2022. All rights reserved.