Class CfnRule

java.lang.Object
software.amazon.jsii.JsiiObject
All Implemented Interfaces:
IConstruct, IDependable, software.amazon.jsii.JsiiSerializable, software.constructs.IConstruct

@Generated(value="jsii-pacmak/1.84.0 (build 5404dcf)", date="2023-06-19T16:29:54.916Z") @Stability(Stable) public class CfnRule extends CfnRefElement
The Rules that define template constraints in an AWS Service Catalog portfolio describe when end users can use the template and which values they can specify for parameters that are declared in the AWS CloudFormation template used to create the product they are attempting to use.

Rules are useful for preventing end users from inadvertently specifying an incorrect value. For example, you can add a rule to verify whether end users specified a valid subnet in a given VPC or used m1.small instance types for test environments. AWS CloudFormation uses rules to validate parameter values before it creates the resources for the product.

A rule can include a RuleCondition property and must include an Assertions property. For each rule, you can define only one rule condition; you can define one or more asserts within the Assertions property. You define a rule condition and assertions by using rule-specific intrinsic functions.

Example:

 CfnInclude cfnTemplate;
 // mutating the rule
 CfnParameter myParameter;
 CfnRule rule = cfnTemplate.getRule("MyRule");
 rule.addAssertion(Fn.conditionContains(List.of("m1.small"), myParameter.getValueAsString()), "MyParameter has to be m1.small");
 
  • Nested Class Summary

    Nested Classes
    Modifier and Type
    Class
    Description
    static final class 
    A fluent builder for CfnRule.

    Nested classes/interfaces inherited from class software.amazon.jsii.JsiiObject

    software.amazon.jsii.JsiiObject.InitializationMode

    Nested classes/interfaces inherited from interface software.amazon.awscdk.core.IConstruct

    IConstruct.Jsii$Default

    Nested classes/interfaces inherited from interface software.constructs.IConstruct

    software.constructs.IConstruct.Jsii$Default
  • Constructor Summary

    Constructors
    Modifier
    Constructor
    Description
    protected
    CfnRule(software.amazon.jsii.JsiiObject.InitializationMode initializationMode)
     
    protected
    CfnRule(software.amazon.jsii.JsiiObjectRef objRef)
     
     
    CfnRule(software.constructs.Construct scope, String id)
    Creates and adds a rule.
     
    CfnRule(software.constructs.Construct scope, String id, CfnRuleProps props)
    Creates and adds a rule.
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    addAssertion(ICfnConditionExpression condition, String description)
    Adds an assertion to the rule.

    Methods inherited from class software.amazon.awscdk.core.CfnRefElement

    getRef

    Methods inherited from class software.amazon.awscdk.core.CfnElement

    getCreationStack, getLogicalId, getStack, isCfnElement, overrideLogicalId

    Methods inherited from class software.amazon.awscdk.core.Construct

    getNode, isConstruct, onPrepare, onSynthesize, onValidate, prepare, synthesize, validate

    Methods inherited from class software.constructs.Construct

    toString

    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
  • Constructor Details

    • CfnRule

      protected CfnRule(software.amazon.jsii.JsiiObjectRef objRef)
    • CfnRule

      protected CfnRule(software.amazon.jsii.JsiiObject.InitializationMode initializationMode)
    • CfnRule

      @Stability(Stable) public CfnRule(@NotNull software.constructs.Construct scope, @NotNull String id, @Nullable CfnRuleProps props)
      Creates and adds a rule.

      Parameters:
      scope - The parent construct. This parameter is required.
      id - This parameter is required.
      props - The rule props.
    • CfnRule

      @Stability(Stable) public CfnRule(@NotNull software.constructs.Construct scope, @NotNull String id)
      Creates and adds a rule.

      Parameters:
      scope - The parent construct. This parameter is required.
      id - This parameter is required.
  • Method Details

    • addAssertion

      @Stability(Stable) public void addAssertion(@NotNull ICfnConditionExpression condition, @NotNull String description)
      Adds an assertion to the rule.

      Parameters:
      condition - The expression to evaluation. This parameter is required.
      description - The description of the assertion. This parameter is required.