aws / aws/aws-cdk

Unable to use deploy-time parameters for privateSubnetIds for Vpc.fromVpcAttributes

Open
#4,118 13 comments 4 reactions 0 assignees View on GitHub
@aws-cdk/aws-ec2 bug effort/medium p2
Dominant language
TypeScript
Stars
12.9k
Forks
4.6k
Avg merge
1d 19h
Merged PRs (30d)
74

Description

Unable 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

Contributor guide

Open the contributing guide

Research direction

Start by reproducing the issue with the TypeScript example and run `npm run build` followed by `npx synth`. Then inspect `Vpc.fromVpcAttributes` handling of `privateSubnetIds` from `valueAsList` and the availability-zone count. Done means deploy-time subnet parameters synthesize without the false multiple-of-availability-zones error.

Written by the indexing model from the issue text.

Assessment

Tech stack
aws, typescript
Domain
cloud, infrastructure
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.