Class: AWSCDK::CloudFormationInclude::CfnInclude

Inherits:
AWSCDK::CfnElement
  • Object
show all
Defined in:
cloud_formation_include/cfn_include.rb

Overview

Construct to import an existing CloudFormation template file into a CDK application.

All resources defined in the template file can be retrieved by calling the get_resource method. Any modifications made on the returned resource objects will be reflected in the resulting CDK template.

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(scope, id, props) ⇒ CfnInclude

Returns a new instance of CfnInclude.

Parameters:



14
15
16
17
18
19
20
# File 'cloud_formation_include/cfn_include.rb', line 14

def initialize(scope, id, props)
  props = props.is_a?(Hash) ? ::AWSCDK::CloudFormationInclude::CfnIncludeProps.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("eyJmcW4iOiJhd3MtY2RrLWxpYi5jbG91ZGZvcm1hdGlvbl9pbmNsdWRlLkNmbkluY2x1ZGVQcm9wcyJ9")), "props")
  Jsii::Object.instance_method(:initialize).bind(self).call(scope, id, props)
end

Class Method Details

.jsii_overridable_methodsObject



22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
# File 'cloud_formation_include/cfn_include.rb', line 22

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 },
    :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 },
    :get_condition => { kind: :method, name: "getCondition", is_optional: false },
    :get_hook => { kind: :method, name: "getHook", is_optional: false },
    :get_mapping => { kind: :method, name: "getMapping", is_optional: false },
    :get_nested_stack => { kind: :method, name: "getNestedStack", is_optional: false },
    :get_output => { kind: :method, name: "getOutput", is_optional: false },
    :get_parameter => { kind: :method, name: "getParameter", is_optional: false },
    :get_resource => { kind: :method, name: "getResource", is_optional: false },
    :get_rule => { kind: :method, name: "getRule", is_optional: false },
    :load_nested_stack => { kind: :method, name: "loadNestedStack", is_optional: false },
  }
end

Instance Method Details

#creation_stackArray<String>

Returns:

  • (Array<String>)


51
52
53
# File 'cloud_formation_include/cfn_include.rb', line 51

def creation_stack()
  jsii_get_property("creationStack")
end

#get_condition(condition_name) ⇒ AWSCDK::CfnCondition

Returns the CfnCondition object from the 'Conditions' section of the CloudFormation template with the given name.

Any modifications performed on that object will be reflected in the resulting CDK template.

If a Condition with the given name is not present in the template, throws an exception.

Parameters:

  • condition_name (String)

    the name of the Condition in the CloudFormation template file.

Returns:



117
118
119
120
# File 'cloud_formation_include/cfn_include.rb', line 117

def get_condition(condition_name)
  Jsii::Type.check_type(condition_name, JSON.parse(Base64.strict_decode64("eyJwcmltaXRpdmUiOiJzdHJpbmcifQ==")), "conditionName")
  jsii_call_method("getCondition", [condition_name])
end

#get_hook(hook_logical_id) ⇒ AWSCDK::CfnHook

Returns the CfnHook object from the 'Hooks' section of the included CloudFormation template with the given logical ID.

Any modifications performed on the returned object will be reflected in the resulting CDK template.

If a Hook with the given logical ID is not present in the template, an exception will be thrown.

Parameters:

  • hook_logical_id (String)

    the logical ID of the Hook in the included CloudFormation template's 'Hooks' section.

Returns:



131
132
133
134
# File 'cloud_formation_include/cfn_include.rb', line 131

def get_hook(hook_logical_id)
  Jsii::Type.check_type(hook_logical_id, JSON.parse(Base64.strict_decode64("eyJwcmltaXRpdmUiOiJzdHJpbmcifQ==")), "hookLogicalId")
  jsii_call_method("getHook", [hook_logical_id])
end

#get_mapping(mapping_name) ⇒ AWSCDK::CfnMapping

Returns the CfnMapping object from the 'Mappings' section of the included template.

Any modifications performed on that object will be reflected in the resulting CDK template.

If a Mapping with the given name is not present in the template, an exception will be thrown.

Parameters:

  • mapping_name (String)

    the name of the Mapping in the template to retrieve.

Returns:



145
146
147
148
# File 'cloud_formation_include/cfn_include.rb', line 145

def get_mapping(mapping_name)
  Jsii::Type.check_type(mapping_name, JSON.parse(Base64.strict_decode64("eyJwcmltaXRpdmUiOiJzdHJpbmcifQ==")), "mappingName")
  jsii_call_method("getMapping", [mapping_name])
end

#get_nested_stack(logical_id) ⇒ AWSCDK::CloudFormationInclude::IncludedNestedStack

Returns a loaded NestedStack with name logicalId.

For a nested stack to be returned by this method, it must be specified either in the CfnIncludeProps.loadNestedStacks property, or through the load_nested_stack method.

Parameters:

  • logical_id (String)

    the ID of the stack to retrieve, as it appears in the template.

Returns:



158
159
160
161
# File 'cloud_formation_include/cfn_include.rb', line 158

def get_nested_stack(logical_id)
  Jsii::Type.check_type(logical_id, JSON.parse(Base64.strict_decode64("eyJwcmltaXRpdmUiOiJzdHJpbmcifQ==")), "logicalId")
  jsii_call_method("getNestedStack", [logical_id])
end

#get_output(logical_id) ⇒ AWSCDK::CfnOutput

Returns the CfnOutput object from the 'Outputs' section of the included template.

Any modifications performed on that object will be reflected in the resulting CDK template.

If an Output with the given name is not present in the template, throws an exception.

Parameters:

  • logical_id (String)

    the name of the output to retrieve.

Returns:



172
173
174
175
# File 'cloud_formation_include/cfn_include.rb', line 172

def get_output(logical_id)
  Jsii::Type.check_type(logical_id, JSON.parse(Base64.strict_decode64("eyJwcmltaXRpdmUiOiJzdHJpbmcifQ==")), "logicalId")
  jsii_call_method("getOutput", [logical_id])
end

#get_parameter(parameter_name) ⇒ AWSCDK::CfnParameter

Returns the CfnParameter object from the 'Parameters' section of the included template.

Any modifications performed on that object will be reflected in the resulting CDK template.

If a Parameter with the given name is not present in the template, throws an exception.

Parameters:

  • parameter_name (String)

    the name of the parameter to retrieve.

Returns:



186
187
188
189
# File 'cloud_formation_include/cfn_include.rb', line 186

def get_parameter(parameter_name)
  Jsii::Type.check_type(parameter_name, JSON.parse(Base64.strict_decode64("eyJwcmltaXRpdmUiOiJzdHJpbmcifQ==")), "parameterName")
  jsii_call_method("getParameter", [parameter_name])
end

#get_resource(logical_id) ⇒ AWSCDK::CfnResource

Returns the low-level CfnResource from the template with the given logical ID.

Any modifications performed on that resource will be reflected in the resulting CDK template.

The returned object will be of the proper underlying class; you can always cast it to the correct type in your code:

// assume the template contains an AWS::S3::Bucket with logical ID 'Bucket'
const cfnBucket = cfnTemplate.getResource('Bucket') as s3.CfnBucket;
// cfnBucket is of type s3.CfnBucket

If the template does not contain a resource with the given logical ID, an exception will be thrown.

Parameters:

  • logical_id (String)

    the logical ID of the resource in the CloudFormation template file.

Returns:



209
210
211
212
# File 'cloud_formation_include/cfn_include.rb', line 209

def get_resource(logical_id)
  Jsii::Type.check_type(logical_id, JSON.parse(Base64.strict_decode64("eyJwcmltaXRpdmUiOiJzdHJpbmcifQ==")), "logicalId")
  jsii_call_method("getResource", [logical_id])
end

#get_rule(rule_name) ⇒ AWSCDK::CfnRule

Returns the CfnRule object from the 'Rules' section of the CloudFormation template with the given name.

Any modifications performed on that object will be reflected in the resulting CDK template.

If a Rule with the given name is not present in the template, an exception will be thrown.

Parameters:

  • rule_name (String)

    the name of the Rule in the CloudFormation template.

Returns:



223
224
225
226
# File 'cloud_formation_include/cfn_include.rb', line 223

def get_rule(rule_name)
  Jsii::Type.check_type(rule_name, JSON.parse(Base64.strict_decode64("eyJwcmltaXRpdmUiOiJzdHJpbmcifQ==")), "ruleName")
  jsii_call_method("getRule", [rule_name])
end

#load_nested_stack(logical_id, nested_stack_props) ⇒ AWSCDK::CloudFormationInclude::IncludedNestedStack

Includes a template for a child stack inside of this parent template.

A child with this logical ID must exist in the template, and be of type AWS::CloudFormation::Stack. This is equivalent to specifying the value in the CfnIncludeProps.loadNestedStacks property on object construction.

Parameters:

Returns:



238
239
240
241
242
243
# File 'cloud_formation_include/cfn_include.rb', line 238

def load_nested_stack(logical_id, nested_stack_props)
  Jsii::Type.check_type(logical_id, JSON.parse(Base64.strict_decode64("eyJwcmltaXRpdmUiOiJzdHJpbmcifQ==")), "logicalId")
  nested_stack_props = nested_stack_props.is_a?(Hash) ? ::AWSCDK::CloudFormationInclude::CfnIncludeProps.new(**nested_stack_props.transform_keys(&:to_sym)) : nested_stack_props
  Jsii::Type.check_type(nested_stack_props, JSON.parse(Base64.strict_decode64("eyJmcW4iOiJhd3MtY2RrLWxpYi5jbG91ZGZvcm1hdGlvbl9pbmNsdWRlLkNmbkluY2x1ZGVQcm9wcyJ9")), "nestedStackProps")
  jsii_call_method("loadNestedStack", [logical_id, nested_stack_props])
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)


63
64
65
# File 'cloud_formation_include/cfn_include.rb', line 63

def logical_id()
  jsii_get_property("logicalId")
end

#nodeConstructs::Node

The tree node.

Returns:

  • (Constructs::Node)


46
47
48
# File 'cloud_formation_include/cfn_include.rb', line 46

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.



103
104
105
106
# File 'cloud_formation_include/cfn_include.rb', line 103

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

#stackAWSCDK::Stack

The stack in which this element is defined.

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

Returns:



72
73
74
# File 'cloud_formation_include/cfn_include.rb', line 72

def stack()
  jsii_get_property("stack")
end

#to_stringString

Returns a string representation of this construct.

Returns:

  • (String)


79
80
81
# File 'cloud_formation_include/cfn_include.rb', line 79

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)


92
93
94
95
96
97
# File 'cloud_formation_include/cfn_include.rb', line 92

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