class Asset (construct)
An asset represents a local file or directory, which is automatically uploaded to S3 and then can be referenced within a CDK application.
new Asset(scope: Construct, id: string, props: Asset<wbr>Props)
|path||The disk location of the asset.|
|exclude?||Glob patterns to exclude from the copy.|
|follow?||A strategy for how to handle symlinks.|
|readers?||A list of principals that should be able to read this asset from S3. You can use |
The disk location of the asset.
The path should refer to one of the following:
- A regular file or a .zip file, in which case the file will be uploaded as-is to S3.
- A directory, in which case it will be archived into a .zip file and uploaded to S3.
(optional, default: nothing is excluded)
Glob patterns to exclude from the copy.
(optional, default: Never)
A strategy for how to handle symlinks.
(optional, default: No principals that can read file asset.)
A list of principals that should be able to read this asset from S3. You can use
asset.grantRead(principal) to grant read permissions later.
|asset||The path to the asset (stringinfied token).|
|bucket||The S3 bucket in which this asset resides.|
|is||Indicates if this asset is a zip archive.|
|node||Construct tree node which offers APIs for interacting with the construct tree.|
|s3||Attribute that represents the name of the bucket this asset exists in.|
|s3||Attribute which represents the S3 object key of this asset.|
|s3||Attribute which represents the S3 URL of this asset.|
|source||A hash of the source of this asset, which is available at construction time.|
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.
The S3 bucket in which this asset resides.
Indicates if this asset is a zip archive.
Allows constructs to ensure that the correct file type was used.
Construct tree node which offers APIs for interacting with the construct tree.
Attribute that represents the name of the bucket this asset exists in.
Attribute which represents the S3 object key of this asset.
Attribute which represents the S3 URL of this asset.
A hash of the source of this asset, which is available at construction time.
As this is a plain string, it can be used in construct IDs in order to enforce creation of a new resource when the content hash has changed.
|add||Adds CloudFormation template metadata to the specified resource with information that indicates which resource property is mapped to this local asset.|
|grant||Grants read permissions to the principal on the asset's S3 object.|
|to||Returns a string representation of this construct.|
Resource Metadata(resource, resourceProperty)
public addResourceMetadata(resource: Cfn<wbr>Resource, resourceProperty: string): void
Cfn— The CloudFormation resource which is using this asset [disable-awslint:ref-via-interface].
string— The property name where this asset is referenced (e.g. "Code" for AWS::Lambda::Function).
Adds CloudFormation template metadata to the specified resource with information that indicates which resource property is mapped to this local asset.
This can be used by tools such as SAM CLI to provide local experience such as local invocation and debugging of Lambda functions.
Asset metadata will only be included if the stack is synthesized with the "aws:cdk:enable-asset-metadata" context key defined, which is the default behavior when synthesizing via the CDK Toolkit.
public grantRead(grantee: IGrantable): void
Grants read permissions to the principal on the asset's S3 object.
public toString(): string
Returns a string representation of this construct.