Replies: 3 comments
-
Let me reproduce the VPC as yours. |
Beta Was this translation helpful? Give feedback.
-
Hi If you create your vpc like below, you can list all the public subnet IDs like this: const vpc = new ec2.Vpc(this, 'Vpc', {
ipAddresses: ec2.IpAddresses.cidr('192.168.0.0/16'),
maxAzs: 2,
enableDnsHostnames: true,
enableDnsSupport: true,
natGateways: 1,
subnetConfiguration: [
{ name: 'public-subnet-1', subnetType: ec2.SubnetType.PUBLIC, cidrMask: 20, },
{ name: 'isolated-subnet-1', subnetType: ec2.SubnetType.PRIVATE_ISOLATED, cidrMask: 18, },
],
});
const mysubnets = vpc.selectSubnets({ subnetType: ec2.SubnetType.PUBLIC }).subnetIds.join(',')
new CfnOutput(this, 'SubnetIDs', { value: mysubnets }) In my case, I got the output indicating 2 public subnets selected.
So I would be confident that Can you check your vpc selection and make sure it turns 2 subnets? |
Beta Was this translation helpful? Give feedback.
-
For whoever arrives here with the same issue as me, the problem I had is I set |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Describe the bug
Expected Behavior
DatabaseCluster can init successful
Current Behavior
Cluster requires at least 2 subnets, got 1

Reproduction Steps
in First Stack i create a VPC
this.mainVpc = new Vpc(this, mainVpcName, { ipAddresses: IpAddresses.cidr('192.168.0.0/16'), vpcName: mainVpcName, maxAzs: 2, enableDnsHostnames: true, enableDnsSupport: true, natGateways: 1, subnetConfiguration: [ { name: 'public-subnet-1', subnetType: SubnetType.PUBLIC, cidrMask: 20, }, { name: 'isolated-subnet-1', subnetType: SubnetType.PRIVATE_ISOLATED, cidrMask: 18, }, ], });
and Next stack I use fromLookup to retrieve that VPC
const mainVpc: IVpc = Vpc.fromLookup(this, mainVpcName, { vpcName: mainVpcName, region: props.env?.region, });
and then create a DatabaseCluster like above
Possible Solution
No response
Additional Information/Context
No response
CDK CLI Version
2.64.0
Framework Version
No response
Node.js Version
16.17
OS
Window
Language
Typescript
Language Version
3.9.7
Other information
"aws-cdk": "2.64.0",

"aws-cdk-lib": "2.64.0",
"constructs": "10.1.246",
Beta Was this translation helpful? Give feedback.
All reactions