I've faced an issue while creating tags for network interfaces, in AWS
I've created an aws_ec2_tag resource, and tagged each created network interface with nested names of availability zones however, the tags, does not behave as expected (shown in image).
AWS NETWORK INTERFACES

Current appearance:
UNMANAGED | EU-WEST-1A eu-west-1b
UNMANAGED | EU-WEST-1B eu-west-1c
UNMANAGED | EU-WEST-1C eu-west-1a
Expected appearance:
UNMANAGED | EU-WEST-1A eu-west-1a
UNMANAGED | EU-WEST-1B eu-west-1b
UNMANAGED | EU-WEST-1C eu-west-1c
Here is the main.tf
resource "aws_ec2_tag" "def_eni_sqs_private" {
count = length(var.availability_zones)
resource_id = element(flatten([for interface in aws_vpc_endpoint.sqs: interface.network_interface_ids]), count.index)
key = "Name"
value = join(" | ", [ UNMANAGED, upper(element(var.availability_zones, count.index)) ])
}
Please help me to resolve this logic
As requested here is the variable availability_zones
variable "availability_zones" {
type = list(string)
default = data.aws_availability_zones.network_zones.names
}
var.availability_zonesis ordered incorrectly. Can you please add the piece of code that definesvar.availability_zones?var.availability_zonesis a simple data statement, but in any case I've added the variable