@Generated(value="jsii-pacmak/1.67.0 (build 2c027f5)", date="2022-09-28T18:14:31.877Z") @Stability(value=Stable) public class CfnRule extends CfnRefElement
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");
Modifier and Type | Class and Description |
---|---|
static class |
CfnRule.Builder
A fluent builder for
CfnRule . |
software.amazon.jsii.JsiiObject.InitializationMode
IConstruct.Jsii$Default
Modifier | Constructor and Description |
---|---|
|
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.
|
protected |
CfnRule(software.amazon.jsii.JsiiObject.InitializationMode initializationMode) |
protected |
CfnRule(software.amazon.jsii.JsiiObjectRef objRef) |
Modifier and Type | Method and Description |
---|---|
void |
addAssertion(ICfnConditionExpression condition,
String description)
Adds an assertion to the rule.
|
getRef
getCreationStack, getLogicalId, getStack, isCfnElement, overrideLogicalId
getNode, isConstruct, onPrepare, onSynthesize, onValidate, prepare, synthesize, validate
jsiiAsyncCall, jsiiAsyncCall, jsiiCall, jsiiCall, jsiiGet, jsiiGet, jsiiSet, jsiiStaticCall, jsiiStaticCall, jsiiStaticGet, jsiiStaticGet, jsiiStaticSet, jsiiStaticSet
protected CfnRule(software.amazon.jsii.JsiiObjectRef objRef)
protected CfnRule(software.amazon.jsii.JsiiObject.InitializationMode initializationMode)
@Stability(value=Stable) public CfnRule(@NotNull software.constructs.Construct scope, @NotNull String id, @Nullable CfnRuleProps props)
scope
- The parent construct. This parameter is required.id
- This parameter is required.props
- The rule props.@Stability(value=Stable) public CfnRule(@NotNull software.constructs.Construct scope, @NotNull String id)
scope
- The parent construct. This parameter is required.id
- This parameter is required.@Stability(value=Stable) public void addAssertion(@NotNull ICfnConditionExpression condition, @NotNull String description)
condition
- The expression to evaluation. This parameter is required.description
- The description of the assertion. This parameter is required.Copyright © 2022. All rights reserved.