1
votes

Is there a way to create default AWS VPC using terraform?

aws_vpc resource doesn't have any attribute to mark VPC as default.

I know I can use aws-cli aws ec2 create-default-vpc, but that's outside of the terraform.

1
Have you deleted the default VPC for a region? Or are you just wanting to start managing it with Terraform?ydaetskcoR
Yes, I deleted the default one, which has been created with the aws account. Now without it I cannot create RDS instances.NarūnasK
Why do you need a default VPC instead of just any VPC?ydaetskcoR
Because of this other error: Error creating DB Instance: InvalidSubnet: No default subnet detected in VPC. To my best knowledge default subnet can only be created in the default VPC.NarūnasK
You should create an RDS subnet group in the non default VPC and tell AWS to use that subnet group.ydaetskcoR

1 Answers

1
votes

No it looks like you can't via TF, you can adopt an existing default VPC but not create it: https://www.terraform.io/docs/providers/aws/r/default_vpc.html.

So use the AWS cli to recreate it (if you can) and then use this new provider to adopt it.