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

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.

로그인하지 않았습니다. 로그인해야 답변을 게시할 수 있습니다.

좋은 답변은 질문에 명확하게 답하고 건설적인 피드백을 제공하며 질문자의 전문적인 성장을 장려합니다.

질문 답변하기에 대한 가이드라인

관련 콘텐츠