使用 hcl2 创建 ami 时出现 Packer 错误:"Error querying AMI: InvalidAMIID.Malformed: Invalid id:"
Packer Error while creating ami using hcl2: "Error querying AMI: InvalidAMIID.Malformed: Invalid id:"
我正在努力构建打包程序管道,它将使用 ami 市场来安装某些软件并创建 ami。我已经创建了工作正常的 json 模板,但根据打包程序的建议,我正在努力将其升级到 hcl2 模板。
当我运行 hcl2_upgrade 命令。我看到 json 模板已转换为 .pkr.hcl 模板,但 运行 正在转换它。我根据加壳器中的推荐对模板进行了一些自定义 documentation.It 给我以下错误。
data "amazon-ami" "autogenerated_1"{
access_key = "${var.aws_access_key}"
filters = {
root-device-type = "ebs"
virtualization-type = "hvm"
name = "**** Linux *"
}
most_recent = true
region = "${var.aws_region}"
owners = ["${var.owner_id}"]
secret_key = "${var.aws_secret_key}"
}
when I am trying to consume this ami id in the source block It gives me error.
ami_name = "${var.ami_name}"
associate_public_ip_address = false
force_deregister = true
iam_instance_profile = "abc"
instance_type = "****"
region = "${var.aws_region}"
source_ami = "{data.amazon-ami.autogenerated_1.id}"
ssh_interface = "private_ip"
ssh_username = "user"
subnet_id = "subnet-********"
vpc_id = "vpc-***********"
}
错误详情如下:
amazon-ebs.pqr_ami: status code: 400, request id: *********
Build 'amazon-ebs.pqr_ami' errored after 1 second 49 milliseconds: Error querying AMI: InvalidAMIID.Malformed: Invalid id: "{data.amazon-ami.autogenerated_1.id}" (expecting "ami-...")
status code: 400, request id: ************
您的 AMI 实际上是一个字符串 source_ami = "{data.amazon-ami.autogenerated_1.id}"
。应该是:
source_ami = "${data.amazon-ami.autogenerated_1.id}"
或 HCL2:
source_ami = data.amazon-ami.autogenerated_1.id
我正在努力构建打包程序管道,它将使用 ami 市场来安装某些软件并创建 ami。我已经创建了工作正常的 json 模板,但根据打包程序的建议,我正在努力将其升级到 hcl2 模板。
当我运行 hcl2_upgrade 命令。我看到 json 模板已转换为 .pkr.hcl 模板,但 运行 正在转换它。我根据加壳器中的推荐对模板进行了一些自定义 documentation.It 给我以下错误。
data "amazon-ami" "autogenerated_1"{
access_key = "${var.aws_access_key}"
filters = {
root-device-type = "ebs"
virtualization-type = "hvm"
name = "**** Linux *"
}
most_recent = true
region = "${var.aws_region}"
owners = ["${var.owner_id}"]
secret_key = "${var.aws_secret_key}"
}
when I am trying to consume this ami id in the source block It gives me error.
ami_name = "${var.ami_name}"
associate_public_ip_address = false
force_deregister = true
iam_instance_profile = "abc"
instance_type = "****"
region = "${var.aws_region}"
source_ami = "{data.amazon-ami.autogenerated_1.id}"
ssh_interface = "private_ip"
ssh_username = "user"
subnet_id = "subnet-********"
vpc_id = "vpc-***********"
}
错误详情如下:
amazon-ebs.pqr_ami: status code: 400, request id: *********
Build 'amazon-ebs.pqr_ami' errored after 1 second 49 milliseconds: Error querying AMI: InvalidAMIID.Malformed: Invalid id: "{data.amazon-ami.autogenerated_1.id}" (expecting "ami-...")
status code: 400, request id: ************
您的 AMI 实际上是一个字符串 source_ami = "{data.amazon-ami.autogenerated_1.id}"
。应该是:
source_ami = "${data.amazon-ami.autogenerated_1.id}"
或 HCL2:
source_ami = data.amazon-ami.autogenerated_1.id