Get all vpcs from my aws account

Hi everyone!
I have a problem when I try to get vpc from my aws account

data “aws_vpcs” “foo” {
tags = {
Env = “demo”
}
}

output “foo” {
value = “${data.aws_vpcs.foo.ids}”
}

I got:
data.aws_vpcs.foo: Refreshing state…

Error: no matching VPC found

on simplyWebServer.tf line 78, in data “aws_vpcs” “foo”:
78: data “aws_vpcs” “foo” {

but in my aws account vpc with tag Env = “demo” exist

terraform -v
Terraform v0.12.24

  • provider.aws v2.56.0

Can someone help me, please?

@VKhatrus I assume you have your provider block setup correct with the appropriate AWS region, right?
or have exported the correct AWS environment variables?

can you show the provider block? (mask out the sensitive information, if any) !!! :slightly_smiling_face:

Hi @shantanugadgil

my provider block is

provider “aws” {
region = “us-west-2”
}

Strange, but today I’v got success result.

Thank you for reply.

1 Like