Closed azr closed 4 years ago
Also in the meantime I recommend using the dynamic block stanza to achieve this:
dynamic "tag" {
for_each = ${merge(
local.common_tags,
map(
"${var.awesome-tag-something}.${var.something_something.name}", "awesome-tag-example"
)
)}
content {
name = tag.key
value = tag.value
}
}
@azr I followed your suggestion, and looks like I run into another bug...
.SourceAMI
returns <no-value>
from the example below:
dynamic "tag" {
for_each = merge(
var.common_tags,
{
Name = "${var.ami_name} {{ isotime \"2006-01-02-15-04\" }}",
source-ami = "{{ .SourceAMI }}"
}
)
content {
name = tag.key
value = tag.value
}
}
Packer logs:
==> amazon-ebs: Creating AMI tags
amazon-ebs: Adding tag: "Name": "CentOS AMI 2020-04-08-18-48"
amazon-ebs: Adding tag: "source-ami": "<no value>"
Hey @zmingxie we recently merged a fix for this ( original issue ) and I just tagged a nightly that should contain it; please tell us if that works for you.
For your second issue I just opened #9062 which will be addressing this.
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.
Currently tags can only be used this way :
But this prevents from setting these tags from variables; so instead I would like users to be able to use something like this:
The difference seems trivial but the second option allows to do things like this:
This is going to be a breaking change. Note that with HCL v1 these stanzas were interchangeable.
Hopefully this should simply be a type change here:
https://github.com/hashicorp/packer/blob/094b837ed2bb0d19214516b5e10192624acc6a37/cmd/mapstructure-to-hcl2/mapstructure-to-hcl2.go#L262-L267