gpt4 book ai didi

amazon-web-services - 是否可以将标签添加到使用 Packer 创建的包含已过滤 source_ami 名称的 AWS AMI?

转载 作者:行者123 更新时间:2023-12-05 01:30:40 25 4
gpt4 key购买 nike

我正在使用 Packer 构建 AWS AMI。源图像由过滤器 source_ami_filter 定义,源 block 看起来像

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 ,例如 SourceAMIName .

这意味着您可以获得源 AMI 名称并将其用作标签,方法是:

source_ami_name = "{{ .SourceAMIName }}"

这是一个完整的例子:https://www.packer.io/docs/builders/amazon/ebs#tag-example

关于amazon-web-services - 是否可以将标签添加到使用 Packer 创建的包含已过滤 source_ami 名称的 AWS AMI?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/66936517/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com