TemplateRule

class aws_cdk.aws_servicecatalog.TemplateRule(*, assertions, rule_name, condition=None)

Bases: object

Defines the provisioning template constraints.

Parameters:
  • assertions (Sequence[Union[TemplateRuleAssertion, Dict[str, Any]]]) – A list of assertions that make up the rule.

  • rule_name (str) – Name of the rule.

  • condition (Optional[ICfnRuleConditionExpression]) – Specify when to apply rule with a rule-specific intrinsic function. Default: - no rule condition provided

ExampleMetadata:

infused

Example:

import aws_cdk.core as cdk

# portfolio: servicecatalog.Portfolio
# product: servicecatalog.CloudFormationProduct


portfolio.constrain_cloud_formation_parameters(product,
    rule=servicecatalog.TemplateRule(
        rule_name="testInstanceType",
        condition=cdk.Fn.condition_equals(cdk.Fn.ref("Environment"), "test"),
        assertions=[servicecatalog.TemplateRuleAssertion(
            assert=cdk.Fn.condition_contains(["t2.micro", "t2.small"], cdk.Fn.ref("InstanceType")),
            description="For test environment, the instance type should be small"
        )]
    )
)

Attributes

assertions

A list of assertions that make up the rule.

condition

Specify when to apply rule with a rule-specific intrinsic function.

Default:
  • no rule condition provided

rule_name

Name of the rule.