class aws_cdk.core.AssetStaging(scope, id, *, source_path, extra_hash=None, asset_hash=None, asset_hash_type=None, bundling=None, exclude=None, follow=None)

Bases: aws_cdk.core.Construct

Stages a file or directory from a location on the file system into a staging directory.

This is controlled by the context key ‘aws:cdk:asset-staging’ and enabled by the CLI by default in order to ensure that when the CDK app exists, all assets are available for deployment. Otherwise, if an app references assets in temporary locations, those will not be available when it exists (see

The stagedPath property is a stringified token that represents the location of the file or directory after staging. It will be resolved only during the “prepare” stage and may be either the original path or the staged path depending on the context setting.

The file/directory are staged based on their content hash (fingerprint). This means that only if content was changed, copy will happen.

  • scope (Construct) –

  • id (str) –

  • source_path (str) – The source file or directory to copy from.

  • extra_hash (Optional[str]) – Extra information to encode into the fingerprint (e.g. build instructions and other inputs). Default: - hash is only based on source content

  • asset_hash (Optional[str]) – Specify a custom hash for this asset. If assetHashType is set it must be set to AssetHashType.CUSTOM. For consistency, this custom hash will be SHA256 hashed and encoded as hex. The resulting hash will be the asset hash. NOTE: the hash is used in order to identify a specific revision of the asset, and used for optimizing and caching deployment activities related to this asset such as packaging, uploading to Amazon S3, etc. If you chose to customize the hash, you will need to make sure it is updated every time the asset changes, or otherwise it is possible that some deployments will not be invalidated. Default: - based on assetHashType

  • asset_hash_type (Optional[AssetHashType]) – Specifies the type of hash to calculate for this asset. If assetHash is configured, this option must be undefined or AssetHashType.CUSTOM. Default: - the default is AssetHashType.SOURCE, but if assetHash is explicitly specified this value defaults to AssetHashType.CUSTOM.

  • bundling (Optional[BundlingOptions]) – (experimental) Bundle the asset by executing a command in a Docker container. The asset path will be mounted at /asset-input. The Docker container is responsible for putting content at /asset-output. The content at /asset-output will be zipped and used as the final asset. Default: - uploaded as-is to S3 if the asset is a regular file or a .zip file, archived into a .zip file and uploaded to S3 otherwise

  • exclude (Optional[List[str]]) – Glob patterns to exclude from the copy. Default: - nothing is excluded

  • follow (Optional[SymlinkFollowMode]) – A strategy for how to handle symlinks. Default: SymlinkFollowMode.NEVER



Returns a string representation of this construct.

Return type



BUNDLING_INPUT_DIR = '/asset-input'
BUNDLING_OUTPUT_DIR = '/asset-output'

A cryptographic hash of the asset.

Return type



The construct tree node associated with this construct.

Return type



(deprecated) A cryptographic hash of the asset.


see assetHash.



Return type



The path of the asset as it was referenced by the user.

Return type



The path to the asset (stringinfied token).

If asset staging is disabled, this will just be the original path. If asset staging is enabled it will be the staged path.

Return type


Static Methods

classmethod clear_asset_hash_cache()

Clears the asset hash cache.

Return type


classmethod is_construct(x)

Return whether the given object is a Construct.


x (Any) –

Return type