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;
declare const destinationBucket: s3.Bucket;
//(Optional) if provided, the resulting processed file would be uploaded to the destinationBucket under the destinationKey name.
declare const destinationKey: string;
declare const role: iam.Role;
new s3deploy.DeployTimeSubstitutedFile(this, 'MyFile', {
source: 'my-file.yaml',
destinationKey: destinationKey,
destinationBucket: destinationBucket,
substitutions: {
variableName: myLambdaFunction.functionName,
},
role: role,
});
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. |
destination | string | The object key in the destination bucket where the processed file would be written to. |
role? | IRole | Execution role associated with this function. |
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.
destinationKey?
Type:
string
(optional, default: Fingerprint of the file content would be used as object key)
The object key in the destination bucket where the processed file would be written to.
role?
Type:
IRole
(optional, default: A role is automatically created)
Execution role associated with this function.
Properties
Name | Type | Description |
---|---|---|
bucket | IBucket | |
deployed | IBucket | The bucket after the deployment. |
handler | IRole | Execution role of the Lambda function behind the custom CloudFormation resource of type Custom::CDKBucketDeployment . |
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)
handlerRole
Type:
IRole
Execution role of the Lambda function behind the custom CloudFormation resource of type Custom::CDKBucketDeployment
.
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. |
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.