【问题标题】:packer unable use filter to pick the correct image-id (amzn-Linux2)打包程序无法使用过滤器来选择正确的图像 ID (amzn-Linux2)
【发布时间】:2022-10-05 16:39:07
【问题描述】:

我正在尝试使用打包程序创建一个新的 AMI。我想将基本映像用作“ami-03ededff12e34e59e”(Amazon Linux 2)

我正在使用以下过滤器:

data \"amazon-ami\"  \"amzn2\" {
   owners = [\"099720109477\"]
   most_recent=true
   region = \"us-east-1\"
   filters = {
     virtualization-type = \"hvm\"
     architecture = \"x86_64\"
     root-device-type = \"ebs\"
     owner-alias = \"amazon\"
     name = \"amzn2-ami-hvm-*\"
    }
 }

但是,我收到以下错误:

Error: Datasource.Execute failed: No AMI was found matching filters: {

关于我在哪里犯错的任何想法?

    标签: amazon-ec2 terraform-provider-aws amazon-ami hashicorp hashicorp-packer


    【解决方案1】:

    我相信问题出在owner 属性上。对于 Amazon Linux 2,它应该是 amazon

    我倾向于使用以下语法来获取最新的 AMI:

    data "aws_ami" "amazon_linux" {
      most_recent = true
      owners      = ["amazon"]
    
      filter {
        name   = "name"
        values = ["amzn2-ami-hvm-*-x86_64-gp2"]
      }
    }
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2021-05-12
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-10-29
      • 1970-01-01
      • 2014-09-20
      • 1970-01-01
      相关资源
      最近更新 更多