AppStagingSynthesizer

class aws_cdk.app_staging_synthesizer_alpha.AppStagingSynthesizer

Bases: StackSynthesizer

(experimental) App Staging Synthesizer.

Stability:

experimental

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.app_staging_synthesizer_alpha as app_staging_synthesizer_alpha

# deployment_identities: app_staging_synthesizer_alpha.DeploymentIdentities
# staging_resources_factory: app_staging_synthesizer_alpha.IStagingResourcesFactory

app_staging_synthesizer = app_staging_synthesizer_alpha.AppStagingSynthesizer.custom_factory(
    factory=staging_resources_factory,

    # the properties below are optional
    bootstrap_qualifier="bootstrapQualifier",
    deployment_identities=deployment_identities,
    once_per_env=False
)

Methods

add_docker_image_asset(*, source_hash, asset_name=None, directory_name=None, docker_build_args=None, docker_build_secrets=None, docker_build_ssh=None, docker_build_target=None, docker_cache_disabled=None, docker_cache_from=None, docker_cache_to=None, docker_file=None, docker_outputs=None, executable=None, network_mode=None, platform=None)

(experimental) Implemented for legacy purposes;

this will never be called.

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

  • asset_name (Optional[str]) – Unique identifier of the docker image asset and its potential revisions. Required if using AppScopedStagingSynthesizer. Default: - no asset name

  • directory_name (Optional[str]) – The directory where the Dockerfile is stored, must be relative to the cloud assembly root. Default: - Exactly one of directoryName and executable is required

  • docker_build_args (Optional[Mapping[str, str]]) – Build args to pass to the docker build command. Since Docker build arguments are resolved before deployment, keys and values cannot refer to unresolved tokens (such as lambda.functionArn or queue.queueUrl). Only allowed when directoryName is specified. Default: - no build args are passed

  • docker_build_secrets (Optional[Mapping[str, str]]) – Build secrets to pass to the docker build command. Since Docker build secrets are resolved before deployment, keys and values cannot refer to unresolved tokens (such as lambda.functionArn or queue.queueUrl). Only allowed when directoryName is specified. Default: - no build secrets are passed

  • docker_build_ssh (Optional[str]) – SSH agent socket or keys to pass to the docker buildx command. Default: - no ssh arg is passed

  • docker_build_target (Optional[str]) – Docker target to build to. Only allowed when directoryName is specified. Default: - no target

  • docker_cache_disabled (Optional[bool]) – Disable the cache and pass --no-cache to the docker build command. Default: - cache is used

  • docker_cache_from (Optional[Sequence[Union[DockerCacheOption, Dict[str, Any]]]]) – Cache from options to pass to the docker build command. Default: - no cache from args are passed

  • docker_cache_to (Union[DockerCacheOption, Dict[str, Any], None]) – Cache to options to pass to the docker build command. Default: - no cache to args are passed

  • docker_file (Optional[str]) – Path to the Dockerfile (relative to the directory). Only allowed when directoryName is specified. Default: - no file

  • docker_outputs (Optional[Sequence[str]]) – Outputs to pass to the docker build command. Default: - no build args are passed

  • executable (Optional[Sequence[str]]) – An external command that will produce the packaged asset. The command should produce the name of a local Docker image on stdout. Default: - Exactly one of directoryName and executable is required

  • network_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 specified

  • platform (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)

Stability:

experimental

Return type:

DockerImageAssetLocation

add_file_asset(*, source_hash, deploy_time=None, executable=None, file_name=None, packaging=None)

(experimental) Implemented for legacy purposes;

this will never be called.

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.

  • deploy_time (Optional[bool]) – Whether or not the asset needs to exist beyond deployment time; i.e. are copied over to a different location and not needed afterwards. Setting this property to true has an impact on the lifecycle of the asset, because we will assume that it is safe to delete after the CloudFormation deployment succeeds. For example, Lambda Function assets are copied over to Lambda during deployment. Therefore, it is not necessary to store the asset in S3, so we consider those deployTime assets. Default: false

  • executable (Optional[Sequence[str]]) – An external command that will produce the packaged asset. The command should produce the location of a ZIP file on stdout. Default: - Exactly one of fileName and executable is required

  • file_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 of fileName and executable is required

  • packaging (Optional[FileAssetPackaging]) – Which type of packaging to perform. Default: - Required if fileName is specified.

Stability:

experimental

Return type:

FileAssetLocation

bind(_stack)

(experimental) Implemented for legacy purposes;

this will never be called.

Parameters:

_stack (Stack) –

Stability:

experimental

Return type:

None

reusable_bind(stack)

(experimental) Returns a version of the synthesizer bound to a stack.

Parameters:

stack (Stack) –

Stability:

experimental

Return type:

IBoundStackSynthesizer

synthesize(_session)

(experimental) Implemented for legacy purposes;

this will never be called.

Parameters:

_session (ISynthesisSession) –

Stability:

experimental

Return type:

None

Attributes

DEFAULT_CLOUDFORMATION_ROLE_ARN = 'arn:${AWS::Partition}:iam::${AWS::AccountId}:role/cdk-${Qualifier}-cfn-exec-role-${AWS::AccountId}-${AWS::Region}'
DEFAULT_DEPLOY_ROLE_ARN = 'arn:${AWS::Partition}:iam::${AWS::AccountId}:role/cdk-${Qualifier}-deploy-role-${AWS::AccountId}-${AWS::Region}'
DEFAULT_LOOKUP_ROLE_ARN = 'arn:${AWS::Partition}:iam::${AWS::AccountId}:role/cdk-${Qualifier}-lookup-role-${AWS::AccountId}-${AWS::Region}'
DEFAULT_QUALIFIER = 'hnb659fds'
bootstrap_qualifier

The qualifier used to bootstrap this stack.

lookup_role

The role used to lookup for this stack.

Static Methods

classmethod custom_factory(*, factory, once_per_env=None, bootstrap_qualifier=None, deployment_identities=None)

(experimental) Supply your own stagingStackFactory method for creating an IStagingStack when a stack is bound to the synthesizer.

By default, oncePerEnv = true, which means that a new instance of the IStagingStack will be created in new environments. Set oncePerEnv = false to turn off that behavior.

Parameters:
  • factory (IStagingResourcesFactory) – (experimental) The factory that will be used to return staging resources for each stack.

  • once_per_env (Optional[bool]) – (experimental) Reuse the answer from the factory for stacks in the same environment. Default: true

  • bootstrap_qualifier (Optional[str]) – (experimental) Qualifier to disambiguate multiple bootstrapped environments in the same account. This qualifier is only used to reference bootstrapped resources. It will not be used in the creation of app-specific staging resources: appId is used for that instead. Default: - Value of context key @aws-cdk/core:bootstrapQualifier’ if set, otherwise DEFAULT_QUALIFIER

  • deployment_identities (Optional[DeploymentIdentities]) – (experimental) What roles to use to deploy applications. These are the roles that have permissions to interact with CloudFormation on your behalf. By default these are the standard bootstrapped CDK roles, but you can customize them or turn them off and use the CLI credentials to deploy. Default: - The standard bootstrapped CDK roles

Stability:

experimental

Return type:

AppStagingSynthesizer

classmethod custom_resources(*, resources, bootstrap_qualifier=None, deployment_identities=None)

(experimental) Use these exact staging resources for every stack that this synthesizer is used for.

Parameters:
  • resources (IStagingResources) – (experimental) Use these exact staging resources for every stack that this synthesizer is used for.

  • bootstrap_qualifier (Optional[str]) – (experimental) Qualifier to disambiguate multiple bootstrapped environments in the same account. This qualifier is only used to reference bootstrapped resources. It will not be used in the creation of app-specific staging resources: appId is used for that instead. Default: - Value of context key @aws-cdk/core:bootstrapQualifier’ if set, otherwise DEFAULT_QUALIFIER

  • deployment_identities (Optional[DeploymentIdentities]) – (experimental) What roles to use to deploy applications. These are the roles that have permissions to interact with CloudFormation on your behalf. By default these are the standard bootstrapped CDK roles, but you can customize them or turn them off and use the CLI credentials to deploy. Default: - The standard bootstrapped CDK roles

Stability:

experimental

Return type:

AppStagingSynthesizer

classmethod default_resources(*, bootstrap_qualifier=None, deployment_identities=None, app_id, staging_bucket_encryption, auto_delete_staging_assets=None, deploy_time_file_asset_lifetime=None, file_asset_publishing_role=None, image_asset_publishing_role=None, image_asset_version_count=None, staging_bucket_name=None, staging_stack_name_prefix=None)

(experimental) Use the Default Staging Resources, creating a single stack per environment this app is deployed in.

Parameters:
  • bootstrap_qualifier (Optional[str]) – (experimental) Qualifier to disambiguate multiple bootstrapped environments in the same account. This qualifier is only used to reference bootstrapped resources. It will not be used in the creation of app-specific staging resources: appId is used for that instead. Default: - Value of context key @aws-cdk/core:bootstrapQualifier’ if set, otherwise DEFAULT_QUALIFIER

  • deployment_identities (Optional[DeploymentIdentities]) – (experimental) What roles to use to deploy applications. These are the roles that have permissions to interact with CloudFormation on your behalf. By default these are the standard bootstrapped CDK roles, but you can customize them or turn them off and use the CLI credentials to deploy. Default: - The standard bootstrapped CDK roles

  • app_id (str) – (experimental) A unique identifier for the application that the staging stack belongs to. This identifier will be used in the name of staging resources created for this application, and should be unique across CDK apps. The identifier should include lowercase characters and dashes (‘-’) only and have a maximum of 20 characters.

  • staging_bucket_encryption (BucketEncryption) – (experimental) Encryption type for staging bucket. In future versions of this package, the default will be BucketEncryption.S3_MANAGED. In previous versions of this package, the default was to use KMS encryption for the staging bucket. KMS keys cost $1/month, which could result in unexpected costs for users who are not aware of this. As we stabilize this module we intend to make the default S3-managed encryption, which is free. However, the migration path from KMS to S3 managed encryption for existing buckets is not straightforward. Therefore, for now, this property is required. If you have an existing staging bucket encrypted with a KMS key, you will likely want to set this property to BucketEncryption.KMS. If you are creating a new staging bucket, you can set this property to BucketEncryption.S3_MANAGED to avoid the cost of a KMS key.

  • auto_delete_staging_assets (Optional[bool]) – (experimental) Auto deletes objects in the staging S3 bucket and images in the staging ECR repositories. Default: true

  • deploy_time_file_asset_lifetime (Optional[Duration]) – (experimental) The lifetime for deploy time file assets. Assets that are only necessary at deployment time (for instance, CloudFormation templates and Lambda source code bundles) will be automatically deleted after this many days. Assets that may be read from the staging bucket during your application’s run time will not be deleted. Set this to the length of time you wish to be able to roll back to previous versions of your application without having to do a new cdk synth and re-upload of assets. Default: - Duration.days(30)

  • file_asset_publishing_role (Optional[BootstrapRole]) – (experimental) Pass in an existing role to be used as the file publishing role. Default: - a new role will be created

  • image_asset_publishing_role (Optional[BootstrapRole]) – (experimental) Pass in an existing role to be used as the image publishing role. Default: - a new role will be created

  • image_asset_version_count (Union[int, float, None]) – (experimental) The maximum number of image versions to store in a repository. Previous versions of an image can be stored for rollback purposes. Once a repository has more than 3 image versions stored, the oldest version will be discarded. This allows for sensible garbage collection while maintaining a few previous versions for rollback scenarios. Default: - up to 3 versions stored

  • staging_bucket_name (Optional[str]) – (experimental) Explicit name for the staging bucket. Default: - a well-known name unique to this app/env.

  • staging_stack_name_prefix (Optional[str]) – (experimental) Specify a custom prefix to be used as the staging stack name and construct ID. The prefix will be appended before the appId, which is required to be part of the stack name and construct ID to ensure uniqueness. Default: ‘StagingStack’

Stability:

experimental

Return type:

AppStagingSynthesizer