@Generated(value="jsii-pacmak/1.74.0 (build 6d08790)", date="2023-03-22T19:35:50.786Z") 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 . |
IRule.Jsii$Default, IRule.Jsii$Proxy
Modifier | Constructor and Description |
---|---|
protected |
CustomRule(software.amazon.jsii.JsiiObject.InitializationMode initializationMode) |
protected |
CustomRule(software.amazon.jsii.JsiiObjectRef objRef) |
|
CustomRule(software.constructs.Construct scope,
java.lang.String id,
CustomRuleProps props) |
Modifier and Type | Method and Description |
---|---|
static IRule |
fromConfigRuleName(software.constructs.Construct scope,
java.lang.String id,
java.lang.String configRuleName)
Imports an existing rule.
|
java.lang.String |
getConfigRuleArn()
The arn of the rule.
|
java.lang.String |
getConfigRuleComplianceType()
The compliance status of the rule.
|
java.lang.String |
getConfigRuleId()
The id of the rule.
|
java.lang.String |
getConfigRuleName()
The name of the rule.
|
protected java.lang.Boolean |
getIsCustomWithChanges() |
protected java.lang.Boolean |
getIsManaged() |
protected RuleScope |
getRuleScope() |
Rule |
onComplianceChange(java.lang.String id)
Defines an EventBridge event rule which triggers for rule compliance events.
|
Rule |
onComplianceChange(java.lang.String id,
OnEventOptions options)
Defines an EventBridge event rule which triggers for rule compliance events.
|
Rule |
onEvent(java.lang.String id)
Defines an EventBridge event rule which triggers for rule events.
|
Rule |
onEvent(java.lang.String id,
OnEventOptions options)
Defines an EventBridge event rule which triggers for rule events.
|
Rule |
onReEvaluationStatus(java.lang.String id)
Defines an EventBridge event rule which triggers for rule re-evaluation status events.
|
Rule |
onReEvaluationStatus(java.lang.String id,
OnEventOptions options)
Defines an EventBridge event rule which triggers for rule re-evaluation status events.
|
protected void |
setIsCustomWithChanges(java.lang.Boolean value) |
protected void |
setIsManaged(java.lang.Boolean value) |
protected void |
setRuleScope(RuleScope value) |
applyRemovalPolicy, generatePhysicalName, getEnv, getPhysicalName, getResourceArnAttribute, getResourceNameAttribute, getStack, isResource
getNode, isConstruct, onPrepare, onSynthesize, onValidate, prepare, synthesize, validate
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
applyRemovalPolicy, getEnv, getStack
getNode
protected CustomRule(software.amazon.jsii.JsiiObjectRef objRef)
protected CustomRule(software.amazon.jsii.JsiiObject.InitializationMode initializationMode)
public CustomRule(software.constructs.Construct scope, java.lang.String id, CustomRuleProps props)
scope
- This parameter is required.id
- This parameter is required.props
- This parameter is required.public static IRule fromConfigRuleName(software.constructs.Construct scope, java.lang.String id, java.lang.String configRuleName)
scope
- This parameter is required.id
- This parameter is required.configRuleName
- the name of the rule. This parameter is required.public Rule onComplianceChange(java.lang.String id, OnEventOptions options)
onComplianceChange
in interface IRule
id
- This parameter is required.options
- public Rule onComplianceChange(java.lang.String id)
onComplianceChange
in interface IRule
id
- This parameter is required.public Rule onEvent(java.lang.String id, OnEventOptions options)
Use
rule.addEventPattern(pattern)
to specify a filter.
public Rule onEvent(java.lang.String id)
Use
rule.addEventPattern(pattern)
to specify a filter.
public Rule onReEvaluationStatus(java.lang.String id, OnEventOptions options)
onReEvaluationStatus
in interface IRule
id
- This parameter is required.options
- public Rule onReEvaluationStatus(java.lang.String id)
onReEvaluationStatus
in interface IRule
id
- This parameter is required.public java.lang.String getConfigRuleArn()
public java.lang.String getConfigRuleComplianceType()
public java.lang.String getConfigRuleId()
public java.lang.String getConfigRuleName()
getConfigRuleName
in interface IRule
protected java.lang.Boolean getIsCustomWithChanges()
protected void setIsCustomWithChanges(java.lang.Boolean value)
protected java.lang.Boolean getIsManaged()
protected void setIsManaged(java.lang.Boolean value)
protected RuleScope getRuleScope()
protected void setRuleScope(RuleScope value)