Unable to use deploy-time parameters for privateSubnetIds for Vpc.fromVpcAttributes
See original GitHub issueUnable to pass CommaDelimitedList
CfnParameter
to VPC.fromVpcAttributes
privateSubnetIds
Reproduction Steps
When trying to use existing VPC
for a lambda function
const vpcSubnetId = new CfnParameter(this, 'VPCSubnetId', {
description: 'VPC Subnet Id',
type: 'CommaDelimitedList',
});
const vpc = Vpc.fromVpcAttributes(this, 'GeoVPC', {
vpcId: vpcId.valueAsString,
availabilityZones: ['eu-west-2a', 'eu-west-2b', 'eu-west-2c'],
privateSubnetIds: vpcSubnetId.valueAsList,
});
When runing npn run build
npx synth
for a stack with the above in it it will declare the following error:
Number of privateSubnetIds (1) must be a multiple of availability zones (3).
Environment
- **CLI Version 😗*1.8.0
- **Framework Version:**1.8.0
- **OS 😗*MacOs 10.14.6
- **Language 😗*typescript
Issue Analytics
- State:
- Created 4 years ago
- Reactions:1
- Comments:13 (5 by maintainers)
Top Results From Across the Web
Vpc — AWS Cloud Development Kit 1.184.0 documentation
Import a VPC by supplying all attributes directly. NOTE: using fromVpcAttributes() with deploy-time parameters (like a Fn.importValue() or CfnParameter ...
Read more >awslabs/aws-cdk - Gitter
Hi all,. I am trying to import an existing VPC created by a different stack into my current stack. From what I have...
Read more >Importing VPC IDs into a stack with CDK - DEV Community
When we want to import a VPC ID from another stack using CDK, ... NOTE: using `fromVpcAttributes()` with deploy-time parameters (like a ...
Read more >AWS CDK, CfnParameter valueAsList: how to pass lists in cmd ...
You are passing the values correctly. CDK shows a single entry but during deployment cloudformation will handle it.
Read more >Hey CDK, how can I reference existing resources?
If the needed values are available as CloudFormation exports, it's easy to build the VPC Construct: const vpc = Vpc.fromVpcAttributes(this ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Here is another nice workaround
Hi,
we faced this issue multiple times, as a workaround we wrap the subnetIds with select statements:
This will create a list with three tokens, which will be resolved in cfn later.