Reputation: 413
Simply I'm trying to adopt some project tags to an existing internet gateway, by using data statements
data "aws_internet_gateway" "internet_gateway" {
filter {
name = "attachment.vpc-id"
values = [ aws_default_vpc.network[0].id ]
}
tags = var.tags
}
I've also checked with aws cli, here is the output
aws ec2 describe-internet-gateways
{
"InternetGateways": [
{
"Attachments": [
{
"State": "available",
"VpcId": "vpc-***"
}
],
"InternetGatewayId": "igw-***",
"OwnerId": "***",
"Tags": []
}
]
}
The filter I've used were in the example of terraform official documentation web page https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/internet_gateway
Upvotes: 1
Views: 6326
Reputation: 200722
You should remove the tags
section from the Terraform data lookup. You are instructing Terraform to search for an internet gateway that has those tags, but as you can see in the CLI output the internet gateway doesn't have any tags assigned to it.
On a Terraform resource
element, specifying tags
would cause it to assign those tags to the resource, but on a data
element specifying tags
causes Terraform to use the tag values as part of the search it performs.
If it still doesn't work, you will need to verify that the value of aws_default_vpc.network[0].id
is what you are expecting, i.e. the same value as VpcId
in the CLI output.
Upvotes: 1