Can't configure an RDS without Private subnets in a VPC
See original GitHub issueVia the AWS Management Console I created a VPC from scratch with two public subnets. Then I created a DB Instance in that VPC. Everything worked smoothly. When I replicated the same configuration in CDK I got the following error:
There are no ‘Private’ subnet groups in this VPC. Available types: Public
When I added two extra Private subnets (with natGateways=0) to the VPC, I got another error:
CommonVpc/CommonPrivateSubnetGroupSubnet2/DefaultRoute (CommonVpcCommonPrivateSubnetGroupSubnet2DefaultRoute30057064) Exactly one of [InstanceId, NetworkInterfaceId, EgressOnlyInternetGatewayId, VpcPeeringConnectionId, GatewayId, TransitGatewayId, NatGatewayId] must be specified and not empty
Reproduction Steps
const vpc = new Vpc(this, 'CommonVpc', {
enableDnsSupport: true,
natGateways: 0,
cidr: '10.0.0.0/16',
maxAzs: 2,
subnetConfiguration: [
{
cidrMask: 19,
name: 'CommonPublicSubnetGroup',
subnetType: SubnetType.PUBLIC,
},
// {
// cidrMask: 19,
// name: 'CommonPrivateSubnetGroup',
// subnetType: SubnetType.PRIVATE,
// },
]
});
const dbInstance = new DatabaseInstance(this, 'DbInstance', {
engine: DatabaseInstanceEngine.MYSQL,
masterUsername: 'root',
databaseName: 'RootDb',
instanceClass: InstanceType.of(InstanceClass.T2, InstanceSize.MICRO),
vpc,
allocatedStorage: 10,
vpcPlacement: {
subnetType: SubnetType.PUBLIC,
},
});
Environment
- CLI Version : 1.14.0
- Framework Version: 1.14.0
- OS : Windows 10
- Language : TS
This is 🐛 Bug Report
Issue Analytics
- State:
- Created 4 years ago
- Comments:8 (4 by maintainers)
Top Results From Across the Web
Troubleshoot connectivity to an Amazon RDS instance using ...
Amazon RDS databases can be launched in the public or private subnet of a VPC. Connection problems can be caused by an incorrect...
Read more >(AWS) Can't launch RDS in my chosen VPC - Stack Overflow
I'm following AWS's instructions Scenario 2: VPC with Public and Private Subnets and am having issues at the point ...
Read more >EC2 cannot connect to RDS on VPC. Subnet issues?
Only your ELB and your NAT instance/NAT gateway need to be public subnets, everything else should be in private subnets.
Read more >Tutorial: Create a VPC for use with a DB instance (IPv4 only)
Your DB instance needs to be available only to your web server, and not to the public internet. Thus, you create a VPC...
Read more >How can I move an Amazon RDS DB instance from a public ...
Your browser can't play this video. ... how to move an Amazon RDS DB instance from a public subnet to private subnet within...
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
If you want to connect to your RDS instance from your PC it will need to be routable from the internet.
That means it is itself in a public subnet with a public IP address, or it has a publicly routable computer in front of it (typically a load balancer in the form of an ALB with a TCP connection or an NLB).
vpcSubnets
selector must be provided to fix the errorThere are no 'Private' subnet groups in this VPC. Available types: Public
like that (java):