Skip to content
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

aws_default_vpc failing with Default VPC does not exist #21241

Closed
xorxsan opened this issue Oct 11, 2021 · 5 comments · Fixed by #22776
Closed

aws_default_vpc failing with Default VPC does not exist #21241

xorxsan opened this issue Oct 11, 2021 · 5 comments · Fixed by #22776
Labels
service/ec2 Issues and PRs that pertain to the ec2 service.
Milestone

Comments

@xorxsan
Copy link

xorxsan commented Oct 11, 2021

Community Note

  • Please vote on this issue by adding a 👍 reaction to the original issue to help the community and maintainers prioritize this request
  • Please do not leave "+1" or other comments that do not add relevant new information or questions, they generate extra noise for issue followers and do not help prioritize the request
  • If you are interested in working on this issue or have submitted a pull request, please leave a comment

Hi all,

I'm having an error when trying to use the aws_default_vpc resource.

According to documentation https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/default_vpc:

For AWS accounts created after 2013-12-04, each region comes with a Default VPC. This is an advanced resource, and has special caveats to be aware of when using it. Please read this document in its entirety before using this resource.

However, when I try to import this resource, it fails with a No default VPC found in this region (I tried several regions).

I'm not really sure this is a bug on the documentation or on the resource itself.

Thanks!

Terraform CLI and Terraform AWS Provider Version

$ terraform -v
Terraform v1.0.8
on windows_amd64
+ provider registry.terraform.io/hashicorp/aws v3.62.0

Affected Resource(s)

  • aws_default_vpc

Terraform Configuration Files

provider "aws" {
  region  = "eu-west-2"
}

resource "aws_default_vpc" "default" {}
terraform {
  required_providers {
    aws = {
      source = "hashicorp/aws"
    }
  }
  required_version = ">= 0.13"
}

Also tried with

resource "aws_default_vpc" "default" {
  tags = {
    Name = "Default VPC"
  }
}

Debug Output

https://gist.github.com/xorxsan/91cc8e28cf3fe627653f35444294ac51

Panic Output

None

Expected Behavior

The default vpc for any region should be imported (according to documentation).

Actual Behavior

The following error was thrown:

│ Error: No default VPC found in this region.
│
│   with aws_default_vpc.default,
│   on main.tf line 5, in resource "aws_default_vpc" "default":
│    5: resource "aws_default_vpc" "default" {}

Steps to Reproduce

  1. terraform apply

Important Factoids

Account was created on 2020.

References

@github-actions github-actions bot added needs-triage Waiting for first response or review from a maintainer. service/ec2 Issues and PRs that pertain to the ec2 service. labels Oct 11, 2021
@ewbankkit ewbankkit added waiting-response Maintainers are waiting on response from community or contributor. and removed needs-triage Waiting for first response or review from a maintainer. labels Oct 12, 2021
@ewbankkit
Copy link
Contributor

@xorxsan Thanks for raising this issue.
Currently the aws_default_vpc resource does not create a default VPC in a region if one does not exist, instead "importing" the existing default VPC for the region - and failing if the default VPC has been deleted.
We plan to alter this behavior in the future - #4959.

@xorxsan
Copy link
Author

xorxsan commented Oct 14, 2021

@ewbankkit thanks for the response. However what I don't understand is that I did not remove the default VPC for any region. It looks like it has never been created in the first place by AWS.
Could it be that the default VPC for a given region is only created, behind the scenes, by AWS when an EC2 instance is launched without a VPC?

@github-actions github-actions bot removed the waiting-response Maintainers are waiting on response from community or contributor. label Oct 14, 2021
@anGie44 anGie44 added this to the v4.0.0 milestone Jan 26, 2022
@anGie44
Copy link
Contributor

anGie44 commented Jan 26, 2022

Hi @xorxsan , this issue has been addressed with the merge of #22253 (to be released in v4.0 of the provider) such that if no default VPC exists in the current AWS Region, one is now created. Reach out if you have any additional questions!

@github-actions
Copy link

This functionality has been released in v4.0.0 of the Terraform AWS Provider. Please see the Terraform documentation on provider versioning or reach out if you need any assistance upgrading.

For further feature requests or bug reports with this functionality, please create a new GitHub issue following the template. Thank you!

@github-actions
Copy link

I'm going to lock this issue because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues.
If you have found a problem that seems similar to this, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators May 15, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
service/ec2 Issues and PRs that pertain to the ec2 service.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants