AssetStaging

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 https://github.com/aws/aws-cdk/issues/1716).

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.

__init__(scope, id, *, source_path, extra_hash=None, asset_hash=None, asset_hash_type=None, bundling=None, exclude=None, follow=None)
Parameters
  • 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]) – 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

Return type

None

Methods

to_string()

Returns a string representation of this construct.

Return type

str

Attributes

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

A cryptographic hash of the asset.

Return type

str

node

The construct tree node associated with this construct.

Return type

ConstructNode

source_hash

A cryptographic hash of the asset.

deprecated :deprecated: see assetHash.

stability :stability: deprecated

Return type

str

source_path

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

Return type

str

staged_path

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

str

Static Methods

classmethod is_construct(x)

Return whether the given object is a Construct.

Parameters

x (Any) –

Return type

bool