[英]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 的名稱?
有一些共享信息變量,例如SourceAMIName 。
這意味着您可以通過執行以下操作獲取源 AMI 名稱並將其用作標簽:
source_ami_name = "{{ .SourceAMIName }}"
這是一個完整的例子: https://www.packer.io/docs/builders/amazon/ebs#tag-example
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.