v0.8.5-dev
resource "random_id" "tag_key" {
byte_length = "16"
}
resource "random_id" "tag_value" {
byte_length = "32"
}
resource "aws_instance" "server" {
count = "${var.servers}"
ami = "${data.aws_ami.ubuntu-1404.id}"
instance_type = "r3.large"
key_name = "${aws_key_pair.lab.id}"
subnet_id = "${element(aws_subnet.lab.*.id, count.index)}"
vpc_security_group_ids = ["${aws_security_group.lab.id}"]
tags {
"${random_id.tag_key.hex}" = "${random_id.tag_value.hex}"
}
}
Instance should be created with tags from the values of random_id.
The tag is created as (literally) ${random_id.tag_key.hex}, and the value is empty.
terraform apply
Hey @sethvargo!
Agreed that this ought to work the way you wrote it, but I think you should be able to work around it by using some more awkward syntax:
tags = "${map(random_id.tag_key.hex, random_id.tag_value.hex)}"
I didn't actually test this so maybe there's something else that'll break there but I think that should work.
This is fixed in Terraform 0.12 (beta) slash HCL2
I'm going to lock this issue because it has been closed for _30 days_ โณ. This helps our maintainers find and focus on the active issues.
If you have found a problem that seems similar to this, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.
Most helpful comment
This is fixed in Terraform 0.12 (beta) slash HCL2