New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

The VPC associated with the default subnet group does not exist #4318

lapots opened this Issue Apr 23, 2018 · 3 comments


None yet
4 participants
Copy link

lapots commented Apr 23, 2018

Hi there,

I've got terraform file that looks like this

terraform {
  backend "s3" {
    bucket = "s3-terraform-state-backend"
    region = "eu-central-1"
    key = "app/terraform.tfstate"

provider "aws" {
  region = "eu-central-1"

resource "aws_db_instance" "default" {
  availability_zone = "eu-central-1a"
  allocated_storage = 10
  storage_type = "gp2"
  engine = "postgres"
  instance_class = "db.t2.micro"
  name = "core"
  port = 5432
  engine_version = "10"
  skip_final_snapshot = true
  final_snapshot_identifier = "snap-1"
  username = "${var.username}"
  password = "${var.password}"

resource "aws_instance" "default" {
  ami = "ami-ac442ac3"
  availability_zone = "eu-central-1a"
  instance_type = "t2.micro"
  associate_public_ip_address = true

variable "username" {}
variable "password" {}

But when I try to apply it I get this error

 aws_db_instance.default: 1 error(s) occurred:

aws_db_instance.default: Error creating DB Instance: InvalidVPCNetworkStateFault: The VPC vpc-4648d12d associated with the default subnet group does not exist. Please delete the default subnet group or specify another subnet group.
        status code: 400, request id: f16c0152-187e-4aff-b510-a9dfe4a80438

EC2 is being created successfully though.
What is the problem?


This comment has been minimized.

Copy link

ewbankkit commented Apr 24, 2018

@lapots Has the default VPC in the eu-central-1 region been deleted?
Each region gets a default RDS DB subnet group that includes the default subnets in the default VPC for that region. If no db_subnet_group_name attribute is specified when an RDS DB Instance is created then this default subnet group is used.
I guess that if the default VPC for the region is deleted then this default RDS DB subnet group is NOT deleted and you are left with a dangling reference to the non-existent default VPC.

I suggest adding a new RDS DB subnet group or using an existing non-default one and specifying that subnet group's name in the db_subnet_group_name attribute.


This comment has been minimized.

Copy link

lapots commented Apr 25, 2018

@ewbankkit well, yeah it seems there was a conflict with my subnet groups. I once create RDS in the past, then deleted but it seems subnet groups used old VPC id. I recreated everything and it started to work.

@lapots lapots closed this Apr 26, 2018


This comment has been minimized.

Copy link

DigaoParceiro commented Jul 19, 2018

I know it's closed, but to help someone searching on google, I've deleted a vpc and created a new default vpc and I got this problem, to solve this, I go to Amazon RDS > Subnet groups > and I deleted the subnet group, and worked

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment