Class: AWSCDK::LegacyStackSynthesizer

Inherits:
StackSynthesizer
  • Object
show all
Includes:
IBoundStackSynthesizer, IReusableStackSynthesizer
Defined in:
legacy_stack_synthesizer.rb

Overview

Use the CDK classic way of referencing assets.

This synthesizer will generate CloudFormation parameters for every referenced asset, and use the CLI's current credentials to deploy the stack.

  • It does not support cross-account deployment (the CLI must have credentials to the account you are trying to deploy to).
  • It cannot be used with CDK Pipelines. To deploy using CDK Pipelines, you must use the DefaultStackSynthesizer.
  • Each asset will take up a CloudFormation Parameter in your template. Keep in mind that there is a maximum of 200 parameters in a CloudFormation template. To use deterministic asset locations instead, use CliCredentialsStackSynthesizer.

Be aware that your CLI credentials must be valid for the duration of the entire deployment. If you are using session credentials, make sure the session lifetime is long enough.

This is the only StackSynthesizer that supports customizing asset behavior by overriding Stack.addFileAsset() and Stack.addDockerImageAsset().

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeLegacyStackSynthesizer

Returns a new instance of LegacyStackSynthesizer.



28
29
30
# File 'legacy_stack_synthesizer.rb', line 28

def initialize
  Jsii::Object.instance_method(:initialize).bind(self).call
end

Class Method Details

.jsii_overridable_methodsObject



32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
# File 'legacy_stack_synthesizer.rb', line 32

def self.jsii_overridable_methods
  {
    :bound_stack => { kind: :property, name: "boundStack", is_optional: false },
    :bootstrap_qualifier => { kind: :property, name: "bootstrapQualifier", is_optional: true },
    :cloud_formation_execution_role => { kind: :property, name: "cloudFormationExecutionRole", is_optional: true },
    :lookup_role => { kind: :property, name: "lookupRole", is_optional: true },
    :add_bootstrap_version_rule => { kind: :method, name: "addBootstrapVersionRule", is_optional: false },
    :add_docker_image_asset => { kind: :method, name: "addDockerImageAsset", is_optional: false },
    :add_file_asset => { kind: :method, name: "addFileAsset", is_optional: false },
    :bind => { kind: :method, name: "bind", is_optional: false },
    :cloud_formation_location_from_docker_image_asset => { kind: :method, name: "cloudFormationLocationFromDockerImageAsset", is_optional: false },
    :cloud_formation_location_from_file_asset => { kind: :method, name: "cloudFormationLocationFromFileAsset", is_optional: false },
    :emit_artifact => { kind: :method, name: "emitArtifact", is_optional: false },
    :emit_stack_artifact => { kind: :method, name: "emitStackArtifact", is_optional: false },
    :synthesize => { kind: :method, name: "synthesize", is_optional: false },
    :synthesize_stack_template => { kind: :method, name: "synthesizeStackTemplate", is_optional: false },
    :synthesize_template => { kind: :method, name: "synthesizeTemplate", is_optional: false },
    :reusable_bind => { kind: :method, name: "reusableBind", is_optional: false },
  }
end

Instance Method Details

#add_bootstrap_version_rule(required_version, bootstrap_stack_version_ssm_parameter) ⇒ void

This method returns an undefined value.

Add a CfnRule to the bound stack that checks whether an SSM parameter exceeds a given version.

This will modify the template, so must be called before the stack is synthesized.

Parameters:

  • required_version (Numeric)
  • bootstrap_stack_version_ssm_parameter (String)


90
91
92
93
94
# File 'legacy_stack_synthesizer.rb', line 90

def add_bootstrap_version_rule(required_version, bootstrap_stack_version_ssm_parameter)
  Jsii::Type.check_type(required_version, JSON.parse(Base64.strict_decode64("eyJwcmltaXRpdmUiOiJudW1iZXIifQ==")), "requiredVersion")
  Jsii::Type.check_type(bootstrap_stack_version_ssm_parameter, JSON.parse(Base64.strict_decode64("eyJwcmltaXRpdmUiOiJzdHJpbmcifQ==")), "bootstrapStackVersionSsmParameter")
  jsii_call_method("addBootstrapVersionRule", [required_version, bootstrap_stack_version_ssm_parameter])
end

#add_docker_image_asset(asset) ⇒ AWSCDK::DockerImageAssetLocation

Register a Docker Image Asset.

Returns the parameters that can be used to refer to the asset inside the template.

The synthesizer must rely on some out-of-band mechanism to make sure the given files are actually placed in the returned location before the deployment happens. This can be by writing the instructions to the asset manifest (for use by the cdk-assets tool), by relying on the CLI to upload files (legacy behavior), or some other operator controlled mechanism.



108
109
110
111
112
# File 'legacy_stack_synthesizer.rb', line 108

def add_docker_image_asset(asset)
  asset = asset.is_a?(Hash) ? ::AWSCDK::DockerImageAssetSource.new(**asset.transform_keys(&:to_sym)) : asset
  Jsii::Type.check_type(asset, JSON.parse(Base64.strict_decode64("eyJmcW4iOiJhd3MtY2RrLWxpYi5Eb2NrZXJJbWFnZUFzc2V0U291cmNlIn0=")), "asset")
  jsii_call_method("addDockerImageAsset", [asset])
end

#add_file_asset(asset) ⇒ AWSCDK::FileAssetLocation

Register a File Asset.

Returns the parameters that can be used to refer to the asset inside the template.

The synthesizer must rely on some out-of-band mechanism to make sure the given files are actually placed in the returned location before the deployment happens. This can be by writing the instructions to the asset manifest (for use by the cdk-assets tool), by relying on the CLI to upload files (legacy behavior), or some other operator controlled mechanism.

Parameters:

Returns:



126
127
128
129
130
# File 'legacy_stack_synthesizer.rb', line 126

def add_file_asset(asset)
  asset = asset.is_a?(Hash) ? ::AWSCDK::FileAssetSource.new(**asset.transform_keys(&:to_sym)) : asset
  Jsii::Type.check_type(asset, JSON.parse(Base64.strict_decode64("eyJmcW4iOiJhd3MtY2RrLWxpYi5GaWxlQXNzZXRTb3VyY2UifQ==")), "asset")
  jsii_call_method("addFileAsset", [asset])
end

#bind(stack) ⇒ void

This method returns an undefined value.

Bind to the stack this environment is going to be used on.

Must be called before any of the other methods are called.

Parameters:



138
139
140
141
# File 'legacy_stack_synthesizer.rb', line 138

def bind(stack)
  Jsii::Type.check_type(stack, JSON.parse(Base64.strict_decode64("eyJmcW4iOiJhd3MtY2RrLWxpYi5TdGFjayJ9")), "stack")
  jsii_call_method("bind", [stack])
end

#bootstrap_qualifierString?

The qualifier used to bootstrap this stack.

Returns:

  • (String, nil)


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

def bootstrap_qualifier()
  jsii_get_property("bootstrapQualifier")
end

#bound_stackAWSCDK::Stack

Retrieve the bound stack.

Fails if the stack hasn't been bound yet.

Returns:



58
59
60
# File 'legacy_stack_synthesizer.rb', line 58

def bound_stack()
  jsii_get_property("boundStack")
end

#cloud_formation_execution_roleString?

The role that is passed to CloudFormation to execute the change set.

Returns:

  • (String, nil)


72
73
74
# File 'legacy_stack_synthesizer.rb', line 72

def cloud_formation_execution_role()
  jsii_get_property("cloudFormationExecutionRole")
end

#cloud_formation_location_from_docker_image_asset(dest) ⇒ AWSCDK::DockerImageAssetLocation

Turn a docker asset location into a CloudFormation representation of that location.

If any of the fields contain placeholders, the result will be wrapped in a Fn.sub.



149
150
151
152
153
# File 'legacy_stack_synthesizer.rb', line 149

def cloud_formation_location_from_docker_image_asset(dest)
  dest = dest.is_a?(Hash) ? ::AWSCDK::CloudAssemblySchema::DockerImageDestination.new(**dest.transform_keys(&:to_sym)) : dest
  Jsii::Type.check_type(dest, JSON.parse(Base64.strict_decode64("eyJmcW4iOiJhd3MtY2RrLWxpYi5jbG91ZF9hc3NlbWJseV9zY2hlbWEuRG9ja2VySW1hZ2VEZXN0aW5hdGlvbiJ9")), "dest")
  jsii_call_method("cloudFormationLocationFromDockerImageAsset", [dest])
end

#cloud_formation_location_from_file_asset(location) ⇒ AWSCDK::FileAssetLocation

Turn a file asset location into a CloudFormation representation of that location.

If any of the fields contain placeholders, the result will be wrapped in a Fn.sub.



161
162
163
164
165
# File 'legacy_stack_synthesizer.rb', line 161

def cloud_formation_location_from_file_asset(location)
  location = location.is_a?(Hash) ? ::AWSCDK::CloudAssemblySchema::FileDestination.new(**location.transform_keys(&:to_sym)) : location
  Jsii::Type.check_type(location, JSON.parse(Base64.strict_decode64("eyJmcW4iOiJhd3MtY2RrLWxpYi5jbG91ZF9hc3NlbWJseV9zY2hlbWEuRmlsZURlc3RpbmF0aW9uIn0=")), "location")
  jsii_call_method("cloudFormationLocationFromFileAsset", [location])
end

#emit_artifact(session, options = nil) ⇒ void

This method returns an undefined value.

Write the CloudFormation stack artifact to the session.

Use default settings to add a CloudFormationStackArtifact artifact to the given synthesis session. The Stack artifact will control the settings for the CloudFormation deployment.

Parameters:



176
177
178
179
180
181
# File 'legacy_stack_synthesizer.rb', line 176

def emit_artifact(session, options = nil)
  Jsii::Type.check_type(session, JSON.parse(Base64.strict_decode64("eyJmcW4iOiJhd3MtY2RrLWxpYi5JU3ludGhlc2lzU2Vzc2lvbiJ9")), "session")
  options = options.is_a?(Hash) ? ::AWSCDK::SynthesizeStackArtifactOptions.new(**options.transform_keys(&:to_sym)) : options
  Jsii::Type.check_type(options, JSON.parse(Base64.strict_decode64("eyJmcW4iOiJhd3MtY2RrLWxpYi5TeW50aGVzaXplU3RhY2tBcnRpZmFjdE9wdGlvbnMifQ==")), "options") unless options.nil?
  jsii_call_method("emitArtifact", [session, options])
end

#emit_stack_artifact(stack, session, options = nil) ⇒ void

Deprecated.

Use emitArtifact instead

This method returns an undefined value.

Write the stack artifact to the session.

Use default settings to add a CloudFormationStackArtifact artifact to the given synthesis session.

Parameters:



193
194
195
196
197
198
199
# File 'legacy_stack_synthesizer.rb', line 193

def emit_stack_artifact(stack, session, options = nil)
  Jsii::Type.check_type(stack, JSON.parse(Base64.strict_decode64("eyJmcW4iOiJhd3MtY2RrLWxpYi5TdGFjayJ9")), "stack")
  Jsii::Type.check_type(session, JSON.parse(Base64.strict_decode64("eyJmcW4iOiJhd3MtY2RrLWxpYi5JU3ludGhlc2lzU2Vzc2lvbiJ9")), "session")
  options = options.is_a?(Hash) ? ::AWSCDK::SynthesizeStackArtifactOptions.new(**options.transform_keys(&:to_sym)) : options
  Jsii::Type.check_type(options, JSON.parse(Base64.strict_decode64("eyJmcW4iOiJhd3MtY2RrLWxpYi5TeW50aGVzaXplU3RhY2tBcnRpZmFjdE9wdGlvbnMifQ==")), "options") unless options.nil?
  jsii_call_method("emitStackArtifact", [stack, session, options])
end

#lookup_roleString?

The role used to lookup for this stack.

Returns:

  • (String, nil)


79
80
81
# File 'legacy_stack_synthesizer.rb', line 79

def lookup_role()
  jsii_get_property("lookupRole")
end

#reusable_bind(stack) ⇒ AWSCDK::IBoundStackSynthesizer

Produce a bound Stack Synthesizer for the given stack.

This method may be called more than once on the same object.

Parameters:

Returns:



257
258
259
260
# File 'legacy_stack_synthesizer.rb', line 257

def reusable_bind(stack)
  Jsii::Type.check_type(stack, JSON.parse(Base64.strict_decode64("eyJmcW4iOiJhd3MtY2RrLWxpYi5TdGFjayJ9")), "stack")
  jsii_call_method("reusableBind", [stack])
end

#synthesize(session) ⇒ void

This method returns an undefined value.

Synthesize the associated stack to the session.

Parameters:



205
206
207
208
# File 'legacy_stack_synthesizer.rb', line 205

def synthesize(session)
  Jsii::Type.check_type(session, JSON.parse(Base64.strict_decode64("eyJmcW4iOiJhd3MtY2RrLWxpYi5JU3ludGhlc2lzU2Vzc2lvbiJ9")), "session")
  jsii_call_method("synthesize", [session])
end

#synthesize_stack_template(stack, session) ⇒ void

Deprecated.

Use synthesizeTemplate instead

This method returns an undefined value.

Have the stack write out its template.

Parameters:



216
217
218
219
220
# File 'legacy_stack_synthesizer.rb', line 216

def synthesize_stack_template(stack, session)
  Jsii::Type.check_type(stack, JSON.parse(Base64.strict_decode64("eyJmcW4iOiJhd3MtY2RrLWxpYi5TdGFjayJ9")), "stack")
  Jsii::Type.check_type(session, JSON.parse(Base64.strict_decode64("eyJmcW4iOiJhd3MtY2RrLWxpYi5JU3ludGhlc2lzU2Vzc2lvbiJ9")), "session")
  jsii_call_method("synthesizeStackTemplate", [stack, session])
end

#synthesize_template(session, lookup_role_arn = nil, lookup_role_external_id = nil, lookup_role_additional_options = nil) ⇒ AWSCDK::FileAssetSource

Write the stack template to the given session.

Return a descriptor that represents the stack template as a file asset source, for adding to an asset manifest (if desired). This can be used to have the asset manifest system (cdk-assets) upload the template to S3 using the appropriate role, so that afterwards only a CloudFormation deployment is necessary.

If the template is uploaded as an asset, the stack_template_asset_object_url property should be set when calling emitArtifact.

If the template is NOT uploaded as an asset first and the template turns out to be >50KB, it will need to be uploaded to S3 anyway. At that point the credentials will be the same identity that is doing the UpdateStack call, which may not have the right permissions to write to S3.

Parameters:

  • session (AWSCDK::ISynthesisSession)
  • lookup_role_arn (String, nil) (defaults to: nil)
  • lookup_role_external_id (String, nil) (defaults to: nil)
  • lookup_role_additional_options (Hash{String => Object}, nil) (defaults to: nil)

Returns:



243
244
245
246
247
248
249
# File 'legacy_stack_synthesizer.rb', line 243

def synthesize_template(session, lookup_role_arn = nil, lookup_role_external_id = nil, lookup_role_additional_options = nil)
  Jsii::Type.check_type(session, JSON.parse(Base64.strict_decode64("eyJmcW4iOiJhd3MtY2RrLWxpYi5JU3ludGhlc2lzU2Vzc2lvbiJ9")), "session")
  Jsii::Type.check_type(lookup_role_arn, JSON.parse(Base64.strict_decode64("eyJwcmltaXRpdmUiOiJzdHJpbmcifQ==")), "lookupRoleArn") unless lookup_role_arn.nil?
  Jsii::Type.check_type(lookup_role_external_id, JSON.parse(Base64.strict_decode64("eyJwcmltaXRpdmUiOiJzdHJpbmcifQ==")), "lookupRoleExternalId") unless lookup_role_external_id.nil?
  Jsii::Type.check_type(lookup_role_additional_options, JSON.parse(Base64.strict_decode64("eyJjb2xsZWN0aW9uIjp7ImVsZW1lbnR0eXBlIjp7InByaW1pdGl2ZSI6ImFueSJ9LCJraW5kIjoibWFwIn19")), "lookupRoleAdditionalOptions") unless lookup_role_additional_options.nil?
  jsii_call_method("synthesizeTemplate", [session, lookup_role_arn, lookup_role_external_id, lookup_role_additional_options])
end