Skip to content
v2.277.0

DeployTimeSubstitutedFileProps Struct ​

Example ​

ts
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,
});
python
import aws_cdk.aws_lambda as lambda_

# my_lambda_function: lambda.Function
# destination_bucket: s3.Bucket
# (Optional) if provided, the resulting processed file would be uploaded to the destinationBucket under the destinationKey name.
# destination_key: str
# role: iam.Role


s3deploy.DeployTimeSubstitutedFile(self, "MyFile",
    source="my-file.yaml",
    destination_key=destination_key,
    destination_bucket=destination_bucket,
    substitutions={
        "variable_name": my_lambda_function.function_name
    },
    role=role
)
java
import software.amazon.awscdk.services.lambda.*;

Function myLambdaFunction;
Bucket destinationBucket;
//(Optional) if provided, the resulting processed file would be uploaded to the destinationBucket under the destinationKey name.
String destinationKey;
Role role;


DeployTimeSubstitutedFile.Builder.create(this, "MyFile")
        .source("my-file.yaml")
        .destinationKey(destinationKey)
        .destinationBucket(destinationBucket)
        .substitutions(Map.of(
                "variableName", myLambdaFunction.getFunctionName()))
        .role(role)
        .build();
csharp
// Install: dotnet add package Amazon.CDK.Lib
using Amazon.CDK.AWS.Lambda;

Function myLambdaFunction;
Bucket destinationBucket;
//(Optional) if provided, the resulting processed file would be uploaded to the destinationBucket under the destinationKey name.
string destinationKey;
Role role;


new DeployTimeSubstitutedFile(this, "MyFile", new DeployTimeSubstitutedFileProps {
    Source = "my-file.yaml",
    DestinationKey = destinationKey,
    DestinationBucket = destinationBucket,
    Substitutions = new Dictionary<string, string> {
        { "variableName", myLambdaFunction.FunctionName }
    },
    Role = role
});
go
// Install: go get github.com/aws/aws-cdk-go/awscdk/v2
import lambda "github.com/aws/aws-cdk-go/awscdk"

var myLambdaFunction Function
var destinationBucket Bucket
//(Optional) if provided, the resulting processed file would be uploaded to the destinationBucket under the destinationKey name.
var destinationKey string
var role Role


s3deploy.NewDeployTimeSubstitutedFile(this, jsii.String("MyFile"), &DeployTimeSubstitutedFileProps{
	Source: jsii.String("my-file.yaml"),
	DestinationKey: destinationKey,
	DestinationBucket: destinationBucket,
	Substitutions: map[string]*string{
		"variableName": myLambdaFunction.functionName,
	},
	Role: role,
})

Properties ​

destinationBucketIBucketdestination_bucketIBucketdestinationBucketIBucketDestinationBucketIBucketDestinationBucketIBucket required #
The S3 bucket to sync the contents of the zip file to.
destinationKeyoptionalstringdestination_keyoptionalstrdestinationKeyoptionalStringDestinationKeyoptionalstringDestinationKeyoptional*string #
The object key in the destination bucket where the processed file would be written to.

Default: Fingerprint of the file content would be used as object key

roleoptionalIRoleroleoptionalIRoleroleoptionalIRoleRoleoptionalIRoleRoleoptionalIRole #
Execution role associated with this function.

Default: A role is automatically created

sourcestringsourcestrsourceStringSourcestringSource*string required #
Path to the user's local file.
substitutions{ [key: string]: string }substitutionstyping.Mapping[str, str]substitutionsMap<String, String>SubstitutionsIDictionary<string, string>Substitutions*map[string]*string required #
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.