【发布时间】:2021-12-16 14:04:52
【问题描述】:
我正在努力构建打包程序管道,该管道将使用市场 ami 来安装某些软件并创建一个 ami。我创建了运行良好的 json 模板,但根据打包程序的建议,我正在努力将其升级到 hcl2 模板。
当我运行 hcl2_upgrade 命令时。我看到一个 json 模板被转换为 .pkr.hcl 模板,但是在运行它时。我已经按照打包程序文档中的建议对模板进行了一些自定义。它给了我以下错误。
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: ************
【问题讨论】:
标签: amazon-web-services jenkins jenkins-pipeline terraform packer