We use Packer to build AMIs with our software preinstalled, and among other things, we tag those AMIs with the software version number. When we deploy those systems, we need that version number for a couple of things, such as a matching tag on the EC2 instance.
For development purposes, I'm trying to find the absolute latest AMI, more or less
data "aws_ami" "foo" {
filter {
name = "name"
values = ["foo-*-ubuntu1604"]
}
owners = ["${module.aws.account_id}"]
most_recent = true
}
This works fine, and I can provision a system with
${aws_ami.foo.id}. I'm actually trying to find a tag with key "Version"...and
aws_ami_foo.tags is a list of maps where each map has keys "key" and "value". Reading the interpolations page I can't find any way to interact with this data structure at all. (I could do something awful like using template_file to make a group of data sources with the keys, and a second one with the values, but this feels overwrought for what should be a simple lookup.)
Any hints as to an expression that would produce this?