Skip to content
v2.276.0

WebFunctionCodeCopyOptions Struct Added in v2.276.0 ​

Configuration for the Lambda function that copies staged code into its destination bucket.

The function is a stack-level singleton: every copy whose options resolve to the same configuration shares one function. Supplying different options produces a separate function, since a single Lambda cannot hold two conflicting configurations.

Example ​

ts
import * as ec2 from 'aws-cdk-lib/aws-ec2';

declare const vpc: ec2.IVpc;

lambda.WebFunctionCode.fromAssetToManagedBucket(path.join(__dirname, 'my-app'), {
  copyOptions: {
    vpc,
    vpcSubnets: { subnetType: ec2.SubnetType.PRIVATE_WITH_EGRESS },
  },
});

Properties ​

logGroupoptionalILogGroupReflog_groupoptionalILogGroupReflogGroupoptionalILogGroupRefLogGroupoptionalILogGroupRefLogGroupoptionalILogGroupRef#
The log group the Lambda function sends logs to.

Default: a log group is created in the stack, shared by every copy that uses the same function

roleoptionalIRoleroleoptionalIRoleroleoptionalIRoleRoleoptionalIRoleRoleoptionalIRole#
Execution role for the Lambda function that performs the copy.

Default: a role is created with permissions to read the source object and write the destination object

securityGroupsoptionalISecurityGroup[]security_groupsoptionaltyping.List[ISecurityGroup]securityGroupsoptionalList<ISecurityGroup>SecurityGroupsoptionalISecurityGroup[]SecurityGroupsoptional*[]ISecurityGroup#
Security groups for the Lambda function.

Default: a dedicated security group is created

Only used if vpc is supplied.

vpcoptionalIVpcvpcoptionalIVpcvpcoptionalIVpcVpcoptionalIVpcVpcoptionalIVpc#
The VPC to run the Lambda function in.

Default: the function is not placed in a VPC

Only needed if your organization requires all functions to run inside a VPC. The function calls S3, so the VPC needs either a NAT gateway or an S3 VPC endpoint.

vpcSubnetsoptionalSubnetSelectionvpc_subnetsoptionalSubnetSelectionvpcSubnetsoptionalSubnetSelectionVpcSubnetsoptionalSubnetSelectionVpcSubnetsoptionalSubnetSelection#
Which subnets to place the Lambda function in.

Default: the VPC's private subnets

Only used if vpc is supplied.