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

Data source aws_vpcs should not fail if no VPCs are found #13951

Closed
ghost opened this issue Jun 25, 2020 · 7 comments · Fixed by #22776
Closed

Data source aws_vpcs should not fail if no VPCs are found #13951

ghost opened this issue Jun 25, 2020 · 7 comments · Fixed by #22776
Labels
enhancement Requests to existing resources that expand the functionality or scope. service/ec2 Issues and PRs that pertain to the ec2 service.
Milestone

Comments

@ghost
Copy link

ghost commented Jun 25, 2020

This issue was originally opened by @swetli as hashicorp/terraform#25141. It was migrated here as a result of the provider split. The original body of the issue is below.


Current Terraform Version

Terraform v0.12.25
+ provider.aws v2.64.0

Use-cases

I have a module which utilizes for_each to enable VPC flow logs on all VPCs found in a region, however if I run the module on account/region with empty VPC list the data source returns an error:
data "aws_vpcs" "all" {}

  on modules/vpc_logs/main.tf line 2, in data "aws_vpcs" "all":
   2: data "aws_vpcs" "all" {

Error: no matching VPC found

Proposal

data source "aws_vpcs" should return an empty list, like the aws cli:

aws--region=eu-west-1 ec2 describe-vpcs
{
    "Vpcs": []
}

References

@ghost ghost added the service/ec2 Issues and PRs that pertain to the ec2 service. label Jun 25, 2020
@github-actions github-actions bot added the needs-triage Waiting for first response or review from a maintainer. label Jun 25, 2020
@bcatubig
Copy link
Contributor

This request makes sense in theory but in practice the aws_vpc data source is specifically used for returning data about a single vpc.

Looking at the code, it doesn't appear that this data source was designed to handle more than 1 vpc.

@swetli
Copy link

swetli commented Jun 26, 2020

May be you should look at aws_vpcS then 😀

@bcatubig
Copy link
Contributor

Gah! I totally missed that. I'm working on a PR to implement this.

@breathingdust breathingdust added enhancement Requests to existing resources that expand the functionality or scope. and removed needs-triage Waiting for first response or review from a maintainer. labels Jul 10, 2020
@ewbankkit
Copy link
Contributor

@anGie44
Copy link
Contributor

anGie44 commented Jan 26, 2022

Fixed with #22253

@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 14, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
enhancement Requests to existing resources that expand the functionality or scope. service/ec2 Issues and PRs that pertain to the ec2 service.
Projects
None yet
5 participants