@Generated(value="jsii-pacmak/1.74.0 (build 6d08790)", date="2023-03-22T19:35:34.904Z") 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 . |
IConstruct.Jsii$Default
Modifier | Constructor and Description |
---|---|
protected |
CfnRule(software.amazon.jsii.JsiiObject.InitializationMode initializationMode) |
protected |
CfnRule(software.amazon.jsii.JsiiObjectRef objRef) |
|
CfnRule(software.constructs.Construct scope,
java.lang.String id)
Creates and adds a rule.
|
|
CfnRule(software.constructs.Construct scope,
java.lang.String id,
CfnRuleProps props)
Creates and adds a rule.
|
Modifier and Type | Method and Description |
---|---|
void |
addAssertion(ICfnConditionExpression condition,
java.lang.String description)
Adds an assertion to the rule.
|
getRef
getCreationStack, getLogicalId, getStack, isCfnElement, overrideLogicalId
getNode, isConstruct, onPrepare, onSynthesize, onValidate, prepare, synthesize, validate
protected CfnRule(software.amazon.jsii.JsiiObjectRef objRef)
protected CfnRule(software.amazon.jsii.JsiiObject.InitializationMode initializationMode)
public CfnRule(software.constructs.Construct scope, java.lang.String id, CfnRuleProps props)
scope
- The parent construct. This parameter is required.id
- This parameter is required.props
- The rule props.public CfnRule(software.constructs.Construct scope, java.lang.String id)
scope
- The parent construct. This parameter is required.id
- This parameter is required.public void addAssertion(ICfnConditionExpression condition, java.lang.String description)
condition
- The expression to evaluation. This parameter is required.description
- The description of the assertion. This parameter is required.