I have created the resource with v0.11.14
main.tf
resource "aws_instance" "this" {
count = "${var.count}"
.......
}
output.tf
output "subnet_id" {
description = "List of IDs of VPC subnets of instances"
value = ["${aws_instance.this.*.subnet_id}"]
}
when I upgrade v0.12.6, and output.tf is the following content, it will report error.
main.tf
resource "aws_instance" "this" {
for_each = {
1: ""
}
.......
}
output.tf
output "subnet_id" {
description = "List of IDs of VPC subnets of instances"
value = {
for instance in aws_instance.this:
instance.id => instance.subnet_id
}
}
result:
Error: Attempt to get attribute from null value
on ../../modules/aws-ec2-instance/outputs.tf line 99, in output "subnet_id":
99: instance.id => instance.subnet_id
This value is null, so it does not have any attributes.
Error: Missing map element
on ../../modules/aws-ec2-instance/outputs.tf line 99, in output "subnet_id":
99: instance.id => instance.subnet_id
This map does not have an element with the key "id".
Error: Unsupported attribute
on ../../modules/aws-ec2-instance/outputs.tf line 99, in output "subnet_id":
99: instance.id => instance.subnet_id
This value does not have any attributes.
But if for_each is { 1: "", 2: "" }
(for_each length > 1), it is normal !
Why ? How to solve? This is a bug ?
Looking forward to your reply !
Thanks.