'This object does not have an attribute named "az"
I'm new to terraform and could use some help please. I had some basic config to build a VPC and two subnets with instances. This ran successfully when I did a 'terraform apply'. Now running a terraform destroy and getting the error in the title. Even running terraform plan to see if anything has changed just throws the same error. The full error says
each.value is object with no attributes
This object does not have an attribute named "az".
I'm guessing there's something relating to the 'for_each' function i've not done right. But then i'm not sure how it applied successfully. I've checked and the resources created from the apply are still there.
main.tf
resource "aws_subnet" "iperf_subnet" {
vpc_id = aws_vpc.ireland_vpc.id
for_each = var.private_subnets
cidr_block = each.value.subnet
availability_zone = each.value.az
}
variables.tf
variable "private_subnets" {
type = map(object({}))
}
exercise.tfvars
private_subnets = {
host_a = {
az = "eu-west-1a"
subnet = "172.30.1.0/25"
}
host_b = {
az = "eu-west-1b"
subnet = "172.30.1.128/25"
}
}
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
