是否可以将标签添加到使用 Packer 创建的包含过滤名称 source_ami 的 AWS AMI?
Is it possible to add a tag to AWS AMI created with Packer containing name of filtered source_ami?
我正在使用 Packer 构建 AWS AMI。源图像由过滤器 source_ami_filter
定义,源块看起来像
source "amazon-ebs" "test-image" {
ami_name = "Some AMI Name"
instance_type = "t2.micro"
region = "eu-central-1"
source_ami_filter {
filters = {
name = "ubuntu/images/hvm-ssd/ubuntu-focal-20.04-amd64-server-*"
root-device-type = "ebs"
virtualization-type = "hvm"
}
most_recent = true
owners = ["099720109477"]
}
tags = {
// source_ami_name = ... # how to get it?
}
ssh_username = "ubuntu"
}
如何从规范中获取使用的源 AMI 的名称?
还有一些shared information variables, for instance, SourceAMIName。
这意味着您可以获取源 AMI 名称并将其用作标签:
source_ami_name = "{{ .SourceAMIName }}"
这是一个完整的例子:https://www.packer.io/docs/builders/amazon/ebs#tag-example
我正在使用 Packer 构建 AWS AMI。源图像由过滤器 source_ami_filter
定义,源块看起来像
source "amazon-ebs" "test-image" {
ami_name = "Some AMI Name"
instance_type = "t2.micro"
region = "eu-central-1"
source_ami_filter {
filters = {
name = "ubuntu/images/hvm-ssd/ubuntu-focal-20.04-amd64-server-*"
root-device-type = "ebs"
virtualization-type = "hvm"
}
most_recent = true
owners = ["099720109477"]
}
tags = {
// source_ami_name = ... # how to get it?
}
ssh_username = "ubuntu"
}
如何从规范中获取使用的源 AMI 的名称?
还有一些shared information variables, for instance, SourceAMIName。
这意味着您可以获取源 AMI 名称并将其用作标签:
source_ami_name = "{{ .SourceAMIName }}"
这是一个完整的例子:https://www.packer.io/docs/builders/amazon/ebs#tag-example