Class CustomRule

java.lang.Object
software.amazon.jsii.JsiiObject
software.constructs.Construct
software.amazon.awscdk.Resource
software.amazon.awscdk.services.config.CustomRule
All Implemented Interfaces:
IResource, IRule, software.amazon.jsii.JsiiSerializable, software.constructs.IConstruct, software.constructs.IDependable

@Generated(value="jsii-pacmak/1.98.0 (build 00b106d)", date="2024-05-17T05:10:07.898Z") @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_18_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();
 
  • 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:
      onComplianceChange in interface IRule
      Parameters:
      id - This parameter is required.
      options -
    • onComplianceChange

      @Stability(Stable) @NotNull public Rule onComplianceChange(@NotNull String id)
      Defines an EventBridge event rule which triggers for rule compliance events.

      Specified by:
      onComplianceChange in interface IRule
      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.

      Specified by:
      onEvent in interface IRule
      Parameters:
      id - This parameter is required.
      options -
    • onEvent

      @Stability(Stable) @NotNull public Rule onEvent(@NotNull String id)
      Defines an EventBridge event rule which triggers for rule events.

      Use rule.addEventPattern(pattern) to specify a filter.

      Specified by:
      onEvent in interface IRule
      Parameters:
      id - This parameter is required.
    • 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:
      onReEvaluationStatus in interface IRule
      Parameters:
      id - This parameter is required.
      options -
    • onReEvaluationStatus

      @Stability(Stable) @NotNull public Rule onReEvaluationStatus(@NotNull String id)
      Defines an EventBridge event rule which triggers for rule re-evaluation status events.

      Specified by:
      onReEvaluationStatus in interface IRule
      Parameters:
      id - This parameter is required.
    • getConfigRuleArn

      @Stability(Stable) @NotNull public String getConfigRuleArn()
      The arn of the rule.
    • getConfigRuleComplianceType

      @Stability(Stable) @NotNull public String getConfigRuleComplianceType()
      The compliance status of the rule.
    • getConfigRuleId

      @Stability(Stable) @NotNull public String getConfigRuleId()
      The id of the rule.
    • getConfigRuleName

      @Stability(Stable) @NotNull public String getConfigRuleName()
      The name of the rule.
      Specified by:
      getConfigRuleName in interface IRule
    • getIsCustomWithChanges

      @Stability(Stable) @Nullable protected Boolean getIsCustomWithChanges()
    • setIsCustomWithChanges

      @Stability(Stable) protected void setIsCustomWithChanges(@Nullable Boolean value)
    • getIsManaged

      @Stability(Stable) @Nullable protected Boolean getIsManaged()
    • setIsManaged

      @Stability(Stable) protected void setIsManaged(@Nullable Boolean value)
    • getRuleScope

      @Stability(Stable) @Nullable protected RuleScope getRuleScope()
    • setRuleScope

      @Stability(Stable) protected void setRuleScope(@Nullable RuleScope value)