CfnRule

class aws_cdk.core.CfnRule(scope, id, *, assertions=None, rule_condition=None)

Bases: aws_cdk.core.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.

link: :link:: https://docs.aws.amazon.com/servicecatalog/latest/adminguide/reference-template_constraint_rules.html

__init__(scope, id, *, assertions=None, rule_condition=None)

Creates and adds a rule.

Parameters
  • scope (Construct) – The parent construct.

  • id (str) –

  • props – The rule props.

  • assertions (Optional[List[CfnRuleAssertion]]) – Assertions which define the rule. Default: - No assertions for the rule.

  • rule_condition (Optional[ICfnConditionExpression]) – If the rule condition evaluates to false, the rule doesn’t take effect. If the function in the rule condition evaluates to true, expressions in each assert are evaluated and applied. Default: - Rule’s assertions will always take effect.

Return type

None

Methods

add_assertion(condition, description)

Adds an assertion to the rule.

Parameters
  • condition (ICfnConditionExpression) – The expression to evaluation.

  • description (str) – The description of the assertion.

Return type

None

override_logical_id(new_logical_id)

Overrides the auto-generated logical ID with a specific ID.

Parameters

new_logical_id (str) – The new logical ID to use for this stack element.

Return type

None

to_string()

Returns a string representation of this construct.

Return type

str

Attributes

creation_stack

return :rtype: List[str] :return:

the stack trace of the point where this Resource was created from, sourced from the +metadata+ entry typed +aws:cdk:logicalId+, and with the bottom-most node +internal+ entries filtered.

logical_id

The logical ID for this CloudFormation stack element.

The logical ID of the element is calculated from the path of the resource node in the construct tree.

To override this value, use overrideLogicalId(newLogicalId).

return :rtype: str :return:

the logical ID as a stringified token. This value will only get resolved during synthesis.

node

Construct tree node which offers APIs for interacting with the construct tree.

Return type

ConstructNode

ref

Return a string that will be resolved to a CloudFormation { Ref } for this element.

If, by any chance, the intrinsic reference of a resource is not a string, you could coerce it to an IResolvable through Lazy.any({ produce: resource.ref }).

Return type

str

stack

The stack in which this element is defined.

CfnElements must be defined within a stack scope (directly or indirectly).

Return type

Stack

Static Methods

classmethod is_cfn_element(x)

Returns true if a construct is a stack element (i.e. part of the synthesized cloudformation template).

Uses duck-typing instead of instanceof to allow stack elements from different versions of this library to be included in the same stack.

Parameters

x (Any) –

return :rtype: bool :return: The construct as a stack element or undefined if it is not a stack element.

classmethod is_construct(x)

Return whether the given object is a Construct.

Parameters

x (Any) –

Return type

bool