Cdk throws runtime error "no 'Public' subnet groups in this VPC" while creating an rds cluster.

0

I created a VPC through aws cdk python library. It contains 3 public and 3 private subnet along with Internet Gateway attached and route table association set up. There is also a NAT gateway set up and attached for one of the private subnets. I used aws_ec2.CfnSubnet for configuring this, since normally while declaring subnet configuration inside VPC doesn't let us specify CIDR block. And also CfnSubnet doesn't have a subnet type parameter which can be set to avoid this issue. Now I am trying to setup an rds cluster in that vpc but cdk throws an error saying "There are no 'Public' subnet groups in this VPC. Available Types:". In fact the available types shown are also empty. I don't know how that can be. So what is the solution for this? Why can't I create the rds cluster within existing subnets?

This might be solved if I am able to:

  • specify subnet type inside CfnSubnet
  • specify subnet type later on in the code
  • setup rds cluster with existing private/public subnet

Public Route Table: Enter image description here

Private Route Table: Enter image description here

已提問 10 個月前檢視次數 1279 次
2 個答案
0

Did you ensure the public subnets' route table has a route for 0.0.0.0/0 targeting the IGW? Should be a similar setup for the private subnets with the 0.0.0.0/0 route targeting the NAT GW.

profile pictureAWS
已回答 10 個月前
  • Yes Christian, I have setup both. I updated the question with supporting screenshots.

0

So there's a development, I think I found a solution. Previously I was setting up the database cluster in the same cdk stack where I was creating VPC, subnets, route tables, etc. I was creating the cluster after these resource creations, but it was throwing the above mentioned error. The error thrown there also didn't list any available subnet types. So I deployed the stack without the cluster creation code. I created a new stack and put the code there and it got deployed smoothly. Thus it seems I can't put the DB Cluster creation code in the same stack where I'm creating the VPC for the same. Can somebody explain why that's the case?

已回答 10 個月前
  • I am having the same issue. It's like you can't force the AWS CDK to make one resource first. Even the dependencies don't work.

您尚未登入。 登入 去張貼答案。

一個好的回答可以清楚地回答問題並提供建設性的意見回饋,同時有助於提問者的專業成長。

回答問題指南