问题描述
我在安装了 packer 1.7.7 的本地系统中创建了一个 packer json 模板.然后我升级到 hcl2 模板.但是,当我尝试在具有打包程序版本 1.6.1 的詹金斯节点上运行打包程序管道时.它给了我 bwloe 错误
I am created a packer json template in my local system having packer 1.7.7 installed. Then I upgraded to hcl2 template. However, when I try to run The packer pipeline over the jenkins node having packer version 1.6.1. It gives me bwloe error
Blocks of type "data" are not expected here.
Error: Unsupported block type
经过研究,我意识到打包器版本 1.6.1 不支持其模板中的数据块,但支持 hcl2 模板,谁能建议我如何用打包器 1 中支持的东西替换下面模板中的数据块.
After researching I realized that packer version 1.6.1 doesnt support data blocks in its templates but support hcl2 templates can anyone suggest me how do I replace the data block in below template with something supported in packer 1.
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-***********"
}
推荐答案
这样的旧版本不支持它.来自 docs:
Its not supported in such an old version. From docs:
注意:数据源是 Packer 1.7 及更高版本中包含的一项功能
这篇关于hcl2 模板中的 Packer 版本 1.6.1 不支持数据块的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!