aws-cdk-lib.aws_s3_deployment.DeployTimeSubstitutedFile

class DeployTimeSubstitutedFile (construct)

LanguageType name
.NETAmazon.CDK.AWS.S3.Deployment.DeployTimeSubstitutedFile
Gogithub.com/aws/aws-cdk-go/awscdk/v2/awss3deployment#DeployTimeSubstitutedFile
Javasoftware.amazon.awscdk.services.s3.deployment.DeployTimeSubstitutedFile
Pythonaws_cdk.aws_s3_deployment.DeployTimeSubstitutedFile
TypeScript (source)aws-cdk-lib » aws_s3_deployment » DeployTimeSubstitutedFile

Implements IConstruct, IDependable

DeployTimeSubstitutedFile is an extension of BucketDeployment that allows users to upload individual files and specify to make substitutions in the file.

Example

import * as lambda from 'aws-cdk-lib/aws-lambda';

declare const myLambdaFunction: lambda.Function;

new s3deploy.DeployTimeSubstitutedFile(this, 'MyFile', {
  source: 'my-file.yaml',
  destinationBucket: destinationBucket,
  substitutions: {
    variable-name: myLambdaFunction.functionName,
  },
});

Initializer

new DeployTimeSubstitutedFile(scope: Construct, id: string, props: DeployTimeSubstitutedFileProps)

Parameters

  • scope Construct
  • id string
  • props DeployTimeSubstitutedFileProps

Construct Props

NameTypeDescription
destinationBucketIBucketThe S3 bucket to sync the contents of the zip file to.
sourcestringPath to the user's local file.
substitutions{ [string]: string }User-defined substitutions to make in the file.

destinationBucket

Type: IBucket

The S3 bucket to sync the contents of the zip file to.


source

Type: string

Path to the user's local file.


substitutions

Type: { [string]: string }

User-defined substitutions to make in the file.

Placeholders in the user's local file must be specified with double curly brackets and spaces. For example, if you use the key 'xxxx' in the file, it must be written as: {{ xxxx }} to be recognized by the construct as a substitution.

Properties

NameTypeDescription
bucketIBucket
deployedBucketIBucketThe bucket after the deployment.
nodeNodeThe tree node.
objectKeystring
objectKeysstring[]The object keys for the sources deployed to the S3 bucket.

bucket

Type: IBucket


deployedBucket

Type: IBucket

The bucket after the deployment.

If you want to reference the destination bucket in another construct and make sure the bucket deployment has happened before the next operation is started, pass the other construct a reference to deployment.deployedBucket.

Note that this only returns an immutable reference to the destination bucket. If sequenced access to the original destination bucket is required, you may add a dependency on the bucket deployment instead: otherResource.node.addDependency(deployment)


node

Type: Node

The tree node.


objectKey

Type: string


objectKeys

Type: string[]

The object keys for the sources deployed to the S3 bucket.

This returns a list of tokenized object keys for source files that are deployed to the bucket.

This can be useful when using BucketDeployment with extract set to false and you need to reference the object key that resides in the bucket for that zip source file somewhere else in your CDK application, such as in a CFN output.

For example, use Fn.select(0, myBucketDeployment.objectKeys) to reference the object key of the first source file in your bucket deployment.

Methods

NameDescription
addSource(source)Add an additional source to the bucket deployment.
toString()Returns a string representation of this construct.

addSource(source)

public addSource(source: ISource): void

Parameters

  • source ISource

Add an additional source to the bucket deployment. Example

declare const websiteBucket: s3.IBucket;
const deployment = new s3deploy.BucketDeployment(this, 'Deployment', {
  sources: [s3deploy.Source.asset('./website-dist')],
  destinationBucket: websiteBucket,
});

deployment.addSource(s3deploy.Source.asset('./another-asset'));

toString()

public toString(): string

Returns

  • string

Returns a string representation of this construct.