-
Notifications
You must be signed in to change notification settings - Fork 3.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Lambda Vpc placement #817
Comments
A subnet name selects all subnets created with that name in the Placing things in VPCs that weren't created using the CDK is not currently supported, although you can achieve the behavior by passing in matching parameters in the For example, if you have a public and private subnet and you want to place in the private subnet: const vpc = ec2.VpcNetworkRef.import(this, 'VPC', {
vpcId: 'vpc-12345',
availabilityZones: ['us-east-1a', 'us-east-1b']
publicSubnetIds: ['subnet-4381', 'subnet-123'],
privateSubnetIds: ['subnet-1425', 'subnet-86845'],
});
new lambda.Function(this, 'Lambda', {
vpc: vpc,
vpcPlacement: { subnetType: ec2.subnetType.Private }
}); Private is the default, btw, so you don't need to specify that. |
How does the
VpcPlacement
property ofFunction()
map toVpcConfig
in Lambda cloudformation resource?VpcConfig
accepts multiple subnets butVpcPlacement
accepts only a single subnet (inSubnetName
). May be I've got it wrong. Would be clearer if there's a cdk example of a Lambda placed in an Vpc. I think a fairly common scenario is placing a Lambda in an existing Vpc where the Vpc may not have been cloudformed (so the cdk cloudformation import will not work) . An example of that would be great.The text was updated successfully, but these errors were encountered: