aws-cdk-lib.DefaultStackSynthesizer

class DefaultStackSynthesizer

LanguageType name
.NETAmazon.CDK.DefaultStackSynthesizer
Gogithub.com/aws/aws-cdk-go/awscdk/v2#DefaultStackSynthesizer
Javasoftware.amazon.awscdk.DefaultStackSynthesizer
Pythonaws_cdk.DefaultStackSynthesizer
TypeScript (source)aws-cdk-lib » DefaultStackSynthesizer

Implements IStackSynthesizer, IReusableStackSynthesizer, IBoundStackSynthesizer

Extends StackSynthesizer

Uses conventionally named roles and asset storage locations.

This synthesizer:

  • Supports cross-account deployments (the CLI can have credentials to one account, and you can still deploy to another account by assuming roles with well-known names in the other account).
  • Supports the CDK Pipelines library.

Requires the environment to have been bootstrapped with Bootstrap Stack V2 (also known as "modern bootstrap stack"). The synthesizer adds a version check to the template, to make sure the bootstrap stack is recent enough to support all features expected by this synthesizer.

Example

new MyStack(app, 'MyStack', {
  synthesizer: new DefaultStackSynthesizer({
    fileAssetsBucketName: 'my-orgs-asset-bucket',
  }),
});

Initializer

new DefaultStackSynthesizer(props?: DefaultStackSynthesizerProps)

Parameters

  • props DefaultStackSynthesizerProps

Properties

NameTypeDescription
cloudFormationExecutionRoleArnstringReturns the ARN of the CFN execution Role.
deployRoleArnstringReturns the ARN of the deploy Role.
bootstrapQualifier?stringThe qualifier used to bootstrap this stack.
lookupRole?stringThe role used to lookup for this stack.
stack?⚠️StackReturn the currently bound stack.
static DEFAULT_BOOTSTRAP_STACK_VERSION_SSM_PARAMETERstringDefault bootstrap stack version SSM parameter.
static DEFAULT_CLOUDFORMATION_ROLE_ARNstringDefault CloudFormation role ARN.
static DEFAULT_DEPLOY_ROLE_ARNstringDefault deploy role ARN.
static DEFAULT_DOCKER_ASSET_PREFIXstringDefault Docker asset prefix.
static DEFAULT_FILE_ASSETS_BUCKET_NAMEstringDefault file assets bucket name.
static DEFAULT_FILE_ASSET_KEY_ARN_EXPORT_NAMEstringName of the CloudFormation Export with the asset key name.
static DEFAULT_FILE_ASSET_PREFIXstringDefault file asset prefix.
static DEFAULT_FILE_ASSET_PUBLISHING_ROLE_ARNstringDefault asset publishing role ARN for file (S3) assets.
static DEFAULT_IMAGE_ASSETS_REPOSITORY_NAMEstringDefault image assets repository name.
static DEFAULT_IMAGE_ASSET_PUBLISHING_ROLE_ARNstringDefault asset publishing role ARN for image (ECR) assets.
static DEFAULT_LOOKUP_ROLE_ARNstringDefault lookup role ARN for missing values.
static DEFAULT_QUALIFIERstringDefault ARN qualifier.

cloudFormationExecutionRoleArn

Type: string

Returns the ARN of the CFN execution Role.


deployRoleArn

Type: string

Returns the ARN of the deploy Role.


bootstrapQualifier?

Type: string (optional)

The qualifier used to bootstrap this stack.


lookupRole?

Type: string (optional)

The role used to lookup for this stack.


stack?⚠️

⚠️ Deprecated: Use boundStack instead.

Type: Stack (optional)

Return the currently bound stack.


static DEFAULT_BOOTSTRAP_STACK_VERSION_SSM_PARAMETER

Type: string

Default bootstrap stack version SSM parameter.


static DEFAULT_CLOUDFORMATION_ROLE_ARN

Type: string

Default CloudFormation role ARN.


static DEFAULT_DEPLOY_ROLE_ARN

Type: string

Default deploy role ARN.


static DEFAULT_DOCKER_ASSET_PREFIX

Type: string

Default Docker asset prefix.


static DEFAULT_FILE_ASSETS_BUCKET_NAME

Type: string

Default file assets bucket name.


static DEFAULT_FILE_ASSET_KEY_ARN_EXPORT_NAME

Type: string

Name of the CloudFormation Export with the asset key name.


static DEFAULT_FILE_ASSET_PREFIX

Type: string

Default file asset prefix.


static DEFAULT_FILE_ASSET_PUBLISHING_ROLE_ARN

Type: string

Default asset publishing role ARN for file (S3) assets.


static DEFAULT_IMAGE_ASSETS_REPOSITORY_NAME

Type: string

Default image assets repository name.


static DEFAULT_IMAGE_ASSET_PUBLISHING_ROLE_ARN

Type: string

Default asset publishing role ARN for image (ECR) assets.


static DEFAULT_LOOKUP_ROLE_ARN

Type: string

Default lookup role ARN for missing values.


static DEFAULT_QUALIFIER

Type: string

Default ARN qualifier.

Methods

NameDescription
addDockerImageAsset(asset)Register a Docker Image Asset.
addFileAsset(asset)Register a File Asset.
bind(stack)Bind to the stack this environment is going to be used on.
reusableBind(stack)Produce a bound Stack Synthesizer for the given stack.
synthesize(session)Synthesize the associated stack to the session.
protected synthesizeStackTemplate(stack, session)Synthesize the stack template to the given session, passing the configured lookup role ARN.

addDockerImageAsset(asset)

public addDockerImageAsset(asset: DockerImageAssetSource): DockerImageAssetLocation

Parameters

  • asset DockerImageAssetSource

Returns

  • 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.


addFileAsset(asset)

public addFileAsset(asset: FileAssetSource): FileAssetLocation

Parameters

  • asset FileAssetSource

Returns

  • 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.


bind(stack)

public bind(stack: Stack): void

Parameters

  • stack Stack

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

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


reusableBind(stack)

public reusableBind(stack: Stack): IBoundStackSynthesizer

Parameters

  • stack Stack

Returns

  • IBoundStackSynthesizer

Produce a bound Stack Synthesizer for the given stack.

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


synthesize(session)

public synthesize(session: ISynthesisSession): void

Parameters

  • session ISynthesisSession

Synthesize the associated stack to the session.


protected synthesizeStackTemplate(stack, session)

protected synthesizeStackTemplate(stack: Stack, session: ISynthesisSession): void

Parameters

  • stack Stack
  • session ISynthesisSession

Synthesize the stack template to the given session, passing the configured lookup role ARN.