LegacyStackSynthesizer
- class aws_cdk.LegacyStackSynthesizer
Bases:
StackSynthesizer
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 determinstic 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()
andStack.addDockerImageAsset()
.- ExampleMetadata
fixture=_generated
Example:
# The code below shows an example of how to instantiate this type. # The values are placeholders you should change. import aws_cdk as cdk legacy_stack_synthesizer = cdk.LegacyStackSynthesizer()
Methods
- add_docker_image_asset(*, source_hash, directory_name=None, docker_build_args=None, docker_build_target=None, docker_file=None, docker_outputs=None, executable=None, network_mode=None, platform=None)
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 intructions 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
source_hash (
str
) – The hash of the contents of the docker build context. This hash is used throughout the system to identify this image and avoid duplicate work in case the source did not change. NOTE: this means that if you wish to update your docker image, you must make a modification to the source (e.g. add some metadata to your Dockerfile).directory_name (
Optional
[str
]) – The directory where the Dockerfile is stored, must be relative to the cloud assembly root. Default: - Exactly one ofdirectoryName
andexecutable
is requireddocker_build_args (
Optional
[Mapping
[str
,str
]]) – Build args to pass to thedocker build
command. Since Docker build arguments are resolved before deployment, keys and values cannot refer to unresolved tokens (such aslambda.functionArn
orqueue.queueUrl
). Only allowed whendirectoryName
is specified. Default: - no build args are passeddocker_build_target (
Optional
[str
]) – Docker target to build to. Only allowed whendirectoryName
is specified. Default: - no targetdocker_file (
Optional
[str
]) – Path to the Dockerfile (relative to the directory). Only allowed whendirectoryName
is specified. Default: - no filedocker_outputs (
Optional
[Sequence
[str
]]) – Outputs to pass to thedocker build
command. Default: - no build args are passedexecutable (
Optional
[Sequence
[str
]]) – An external command that will produce the packaged asset. The command should produce the name of a local Docker image onstdout
. Default: - Exactly one ofdirectoryName
andexecutable
is requirednetwork_mode (
Optional
[str
]) – Networking mode for the RUN commands during build. Requires Docker Engine API v1.25+. Specify this property to build images on a specific networking mode. Default: - no networking mode specifiedplatform (
Optional
[str
]) – Platform to build for. Requires Docker Buildx. Specify this property to build images on a specific platform. Default: - no platform specified (the current machine architecture will be used)
- Return type
- add_file_asset(*, source_hash, executable=None, file_name=None, packaging=None)
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 intructions 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
source_hash (
str
) – A hash on the content source. This hash is used to uniquely identify this asset throughout the system. If this value doesn’t change, the asset will not be rebuilt or republished.executable (
Optional
[Sequence
[str
]]) – An external command that will produce the packaged asset. The command should produce the location of a ZIP file onstdout
. Default: - Exactly one ofdirectory
andexecutable
is requiredfile_name (
Optional
[str
]) – The path, relative to the root of the cloud assembly, in which this asset source resides. This can be a path to a file or a directory, depending on the packaging type. Default: - Exactly one ofdirectory
andexecutable
is requiredpackaging (
Optional
[FileAssetPackaging
]) – Which type of packaging to perform. Default: - Required iffileName
is specified.
- Return type
- bind(stack)
Bind to the stack this environment is going to be used on.
Must be called before any of the other methods are called.
- Parameters
stack (
Stack
) –- Return type
None
- reusable_bind(stack)
Produce a bound Stack Synthesizer for the given stack.
This method may be called more than once on the same object.
- Parameters
stack (
Stack
) –- Return type
- synthesize(session)
Synthesize the associated stack to the session.
- Parameters
session (
ISynthesisSession
) –- Return type
None
Attributes
- bootstrap_qualifier
The qualifier used to bootstrap this stack.