class DeployTimeSubstitutedFile (construct)
Language | Type name |
---|---|
![]() | Amazon.CDK.AWS.S3.Deployment.DeployTimeSubstitutedFile |
![]() | github.com/aws/aws-cdk-go/awscdk/v2/awss3deployment#DeployTimeSubstitutedFile |
![]() | software.amazon.awscdk.services.s3.deployment.DeployTimeSubstitutedFile |
![]() | aws_cdk.aws_s3_deployment.DeployTimeSubstitutedFile |
![]() | 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
Deploy
Time Substituted File Props
Construct Props
Name | Type | Description |
---|---|---|
destination | IBucket | The S3 bucket to sync the contents of the zip file to. |
source | string | Path 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
Name | Type | Description |
---|---|---|
bucket | IBucket | |
deployed | IBucket | The bucket after the deployment. |
node | Node | The tree node. |
object | string | |
object | string[] | 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
Name | Description |
---|---|
add | Add an additional source to the bucket deployment. |
to | Returns a string representation of this construct. |
Source(source)
addpublic 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'));
String()
topublic toString(): string
Returns
string
Returns a string representation of this construct.