Open joshghent opened 4 years ago
I have the same problem with
Terraform v0.12.28
+ provider.aws v2.70.0
I'm having the same issue. I can locate my VPC (which I created myself in another stack with the same role) with the CLI:
$ aws ec2 describe-vpcs --filter Name=tag:Name,Values=my-vpc-name
{
"Vpcs": [
{
"CidrBlock": "10.0.0.0/16",
"DhcpOptionsId": "dopt-********",
"State": "available",
"VpcId": "vpc-*****************",
"OwnerId": "************",
"InstanceTenancy": "default",
"CidrBlockAssociationSet": [
{
"AssociationId": "vpc-cidr-assoc-*****************",
"CidrBlock": "10.0.0.0/16",
"CidrBlockState": {
"State": "associated"
}
}
],
"IsDefault": false,
"Tags": [
{
"Key": "Name",
"Value": "my-vpc-name"
}
]
}
]
}
But my equivalent tf doesn't find the it.
data "aws_vpc" "my_vpc" {
filter {
name = "tag:Name"
values = [local.vpc_name]
}
}
Error: no matching VPC found
Just like op, I am in an account where the VPC was created separately by another terraform. I used the same role to create that VPC and attempt this particular script as well. Otherwise, I'm not seeing anything out of the ordinary.
One strange thing to note, it seems like changing the tag I filter upon causes things to work magically without complaint. 🤷♂️
Terraform v0.12.29
+ provider.aws v2.70.0
This has been open since 2019. Is this a bug or are we not using it the right way?
This is no longer an issue on TF 0.14
This is what I am using and I am getting above error . I am using TF 0.15
data "aws_vpc" "peer" {
provider = aws.core-peer
filter {
name = "tag:Name"
values = ["${var.CORE_VPC_NAME}"]
}
}
provider "aws" {
region = "${var.AWS_REGION}"
}
provider "aws" {
alias = "core-peer"
region = "${var.AWS_REGION_CORE}"
}
I can confirm this is working now. The issue was with the way I was passing variable in filter values
data "aws_vpc" "peer" {
provider = aws.core-peer
filter {
name = "tag:Name"
values = [var.CORE_VPC_NAME]
}
}
I seeing this error "no matching VPC found" even though vpc tagging is correct. any suggestion here data "aws_vpc" "ingeni" { tags = { Application = "CRE-ORA-RDS" environment = "${var.environment}" } }
Hey y'all 👋 Thank you for taking the time to file this issue and for the continued discussion around it. Given that there's been a number of AWS provider releases since the last update, and the mixed results as far as whether this is an issue still or not, can anyone confirm whether you're still experiencing this behavior?
Facing the same issue. Using terraform image in pipeline "cmdlabs/terraform-utils:10.0.0". AWS provider version 3.33.0
Using below syntax
data "aws_vpc" "main" { tags = { Name = local.workspace["vpc_name"] } }
I was running into this issue with aws_vpc, however it turned out in my case that I needed to ensure that I was assuming the correct role in AWS so that it would find the vpc... in my main.tf file I added:
provider "aws" {
assume_role {
role_arn = var.deployer_role
}
}
then my aws_vpc lookup worked:
data "aws_vpc" "vpc" {
tags = {
"Name" = "${terraform.workspace}"
}
}
Hi all, I'm still facing this issue (with aws_vpc AND aws_route53_zone)
here is my code
data "aws_vpc" "my_vpc" {
filter {
name = "tag:Name"
values = [var.vpc_info.name]
}
}
data "aws_route53_zone" "main_zone" {
name = var.r53_zone.name
private_zone = var.r53_zone.is_private
}
and my tf version:
I have even tried giving the user I'm deploying with 'AmazonVPCFullAccess' & 'Route53FullAccess', but it doesn't work any better...
Is this still an issue for some of you or am I missing something ?
thanks in advance ;)
Community Note
First off, thank you for an amazing free tool! Seriously, it's awesome.
Terraform Version
Affected Resource(s)
Terraform Configuration Files
Debug Output
Used
TF_LOG=DEBUG
. The gist is encrypted with the Terraform Public Key from Keybase https://gist.github.com/joshghent/33217f5dab592d20c698b82cbde72c1cPanic Output
No panic output
Expected Behavior
It should have found both the VPC and the Route53 Zone
Actual Behavior
It didn't do those things and errors with
Steps to Reproduce
terraform plan
Important Factoids
Nothing of note, the AWS account that I have configured locally has full admin access and the Route53 Full Access policy directly attached so it should find the resources correctly. They can both be viewed in the AWS Console. For the VPC I have tried filtering by both tag and name to no avail.
When running
aws route53 list-hosted-zones
I can see the route53 zone's in the output When runningaws ec2 describe-vpcs
I can also see the VPC'sOnly slight weirdness is that this module (where the error occurs) is called from another module. It is referenced 33 times from the other module, each time with a different
tenant
variable passed through.References
Reviewed all the articles, issues and stackoverflow comments I could find on this. 99% of the time it was because the person did not have access to the route53/VPC in question, for myself that isn't the case. Maybe I've missed something and am being dumb but feel I've exhausted all options at this point.