Class: AWSCDK::CfnRule

Inherits:
CfnRefElement
  • Object
show all
Defined in:
cfn_rule.rb

Overview

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.

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(scope, id, props = nil) ⇒ CfnRule

Creates and adds a rule.

Parameters:

  • scope (Constructs::Construct)

    The parent construct.

  • id (String)
  • props (AWSCDK::CfnRuleProps, nil) (defaults to: nil)

    The rule props.



23
24
25
26
27
28
29
# File 'cfn_rule.rb', line 23

def initialize(scope, id, props = nil)
  props = props.is_a?(Hash) ? ::AWSCDK::CfnRuleProps.new(**props.transform_keys(&:to_sym)) : props
  Jsii::Type.check_type(scope, JSON.parse(Base64.strict_decode64("eyJmcW4iOiJjb25zdHJ1Y3RzLkNvbnN0cnVjdCJ9")), "scope")
  Jsii::Type.check_type(id, JSON.parse(Base64.strict_decode64("eyJwcmltaXRpdmUiOiJzdHJpbmcifQ==")), "id")
  Jsii::Type.check_type(props, JSON.parse(Base64.strict_decode64("eyJmcW4iOiJhd3MtY2RrLWxpYi5DZm5SdWxlUHJvcHMifQ==")), "props") unless props.nil?
  Jsii::Object.instance_method(:initialize).bind(self).call(scope, id, props)
end

Class Method Details

.jsii_overridable_methodsObject



31
32
33
34
35
36
37
38
39
40
41
42
43
# File 'cfn_rule.rb', line 31

def self.jsii_overridable_methods
  {
    :node => { kind: :property, name: "node", is_optional: false },
    :creation_stack => { kind: :property, name: "creationStack", is_optional: false },
    :logical_id => { kind: :property, name: "logicalId", is_optional: false },
    :stack => { kind: :property, name: "stack", is_optional: false },
    :ref => { kind: :property, name: "ref", is_optional: false },
    :to_string => { kind: :method, name: "toString", is_optional: false },
    :with => { kind: :method, name: "with", is_optional: false },
    :override_logical_id => { kind: :method, name: "overrideLogicalId", is_optional: false },
    :add_assertion => { kind: :method, name: "addAssertion", is_optional: false },
  }
end

Instance Method Details

#add_assertion(condition, description) ⇒ void

This method returns an undefined value.

Adds an assertion to the rule.

Parameters:



125
126
127
128
129
# File 'cfn_rule.rb', line 125

def add_assertion(condition, description)
  Jsii::Type.check_type(condition, JSON.parse(Base64.strict_decode64("eyJmcW4iOiJhd3MtY2RrLWxpYi5JQ2ZuQ29uZGl0aW9uRXhwcmVzc2lvbiJ9")), "condition")
  Jsii::Type.check_type(description, JSON.parse(Base64.strict_decode64("eyJwcmltaXRpdmUiOiJzdHJpbmcifQ==")), "description")
  jsii_call_method("addAssertion", [condition, description])
end

#creation_stackArray<String>

Returns:

  • (Array<String>)


53
54
55
# File 'cfn_rule.rb', line 53

def creation_stack()
  jsii_get_property("creationStack")
end

#logical_idString

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 override_logical_id(new_logical_id).

Returns:

  • (String)


65
66
67
# File 'cfn_rule.rb', line 65

def logical_id()
  jsii_get_property("logicalId")
end

#nodeConstructs::Node

The tree node.

Returns:

  • (Constructs::Node)


48
49
50
# File 'cfn_rule.rb', line 48

def node()
  jsii_get_property("node")
end

#override_logical_id(new_logical_id) ⇒ void

This method returns an undefined value.

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

Parameters:

  • new_logical_id (String)

    The new logical ID to use for this stack element.



115
116
117
118
# File 'cfn_rule.rb', line 115

def override_logical_id(new_logical_id)
  Jsii::Type.check_type(new_logical_id, JSON.parse(Base64.strict_decode64("eyJwcmltaXRpdmUiOiJzdHJpbmcifQ==")), "newLogicalId")
  jsii_call_method("overrideLogicalId", [new_logical_id])
end

#refString

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 }).

Returns:

  • (String)


84
85
86
# File 'cfn_rule.rb', line 84

def ref()
  jsii_get_property("ref")
end

#stackAWSCDK::Stack

The stack in which this element is defined.

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

Returns:



74
75
76
# File 'cfn_rule.rb', line 74

def stack()
  jsii_get_property("stack")
end

#to_stringString

Returns a string representation of this construct.

Returns:

  • (String)


91
92
93
# File 'cfn_rule.rb', line 91

def to_string()
  jsii_call_method("toString", [])
end

#with(*mixins) ⇒ Constructs::IConstruct

Applies one or more mixins to this construct.

Mixins are applied in order. The list of constructs is captured at the start of the call, so constructs added by a mixin will not be visited. Use multiple with() calls if subsequent mixins should apply to added constructs.

Parameters:

  • mixins (Array<Constructs::IMixin>)

Returns:

  • (Constructs::IConstruct)


104
105
106
107
108
109
# File 'cfn_rule.rb', line 104

def with(*mixins)
  mixins.each_with_index do |item, index|
    Jsii::Type.check_type(item, JSON.parse(Base64.strict_decode64("eyJmcW4iOiJjb25zdHJ1Y3RzLklNaXhpbiJ9")), "mixins[#{index}]")
  end
  jsii_call_method("with", [*mixins])
end