TheDocumentation Index
Fetch the complete documentation index at: https://tfts.mintlify.app/llms.txt
Use this file to discover all available pages before exploring further.
TerraformAsset class allows you to include local files or directories in your Terraform configuration. This is particularly useful for Lambda function code, configuration files, or static website content.
Defining an Asset
To create an asset, specify the local path and the type of asset.Asset Types
AssetType.FILE: A single file.AssetType.DIRECTORY: An entire directory.AssetType.ARCHIVE: A directory that will be automatically zipped.
Properties
asset.path: The path to the asset in the output directory after synthesis.asset.sourcePath: The original path to the asset on your local machine.asset.assetHash: A unique hash based on the content of the asset, useful for triggering redeployments when the code changes.
Example: Lambda Deployment
Assets are commonly used with AWS Lambda to upload function code.asset.path, you ensure that Terraform points to the correct file location within the synthesized cdktf.out directory. The asset.assetHash ensures that the S3 object key changes whenever the source code is modified, forcing Terraform to update the Lambda function.