我在试着用封隔器。
我为ubuntu 16.04创建了一个图像
"source_ami_filter": {
"filters": {
"virtualization-type": "hvm",
"name": "ubuntu/images/*ubuntu-xenial-16.04-amd64-server-*",
"root-device-type": "ebs"
},但是当它通过修改16.04到18.04来尝试相同的文件时
"source_ami_filter": {
"filters": {
"virtualization-type": "hvm",
"name": "ubuntu/images/*ubuntu-xenial-18.04-amd64-server-*",
"root-device-type": "ebs"
},我得到了以下错误。
==> amazon-ebs: Prevalidating any provided VPC information
==> amazon-ebs: Prevalidating AMI Name: packer-example 1592389575
==> amazon-ebs: No AMI was found matching filters: {
==> amazon-ebs: Filters: [{
==> amazon-ebs: Name: "virtualization-type",
==> amazon-ebs: Values: ["hvm"]
==> amazon-ebs: },{
==> amazon-ebs: Name: "name",
==> amazon-ebs: Values: ["ubuntu/images/*ubuntu-xenial-18.04-amd64-server-*"]
==> amazon-ebs: },{
==> amazon-ebs: Name: "root-device-type",
==> amazon-ebs: Values: ["ebs"]
==> amazon-ebs: }],
==> amazon-ebs: Owners: ["099720109477"]
==> amazon-ebs: }
Build 'amazon-ebs' errored: No AMI was found matching filters: {
Filters: [{
Name: "virtualization-type",
Values: ["hvm"]
},{
Name: "name",
Values: ["ubuntu/images/*ubuntu-xenial-18.04-amd64-server-*"]
},{
Name: "root-device-type",
Values: ["ebs"]
}],
Owners: ["099720109477"]
}
==> Some builds didn't complete successfully and had errors:
--> amazon-ebs: No AMI was found matching filters: {
Filters: [{
Name: "virtualization-type",
Values: ["hvm"]
},{
Name: "name",
Values: ["ubuntu/images/*ubuntu-xenial-18.04-amd64-server-*"]
},{
Name: "root-device-type",
Values: ["ebs"]
}],
Owners: ["099720109477"]
}想了解过滤器值是如何工作的:
可否请人澄清我对这方面的疑虑?
发布于 2020-06-17 11:28:13
重要注意:您应该像我在这里的示例中一样设置一个所有者属性,否则您将打开自己的大门,引入与您的模式匹配的恶意AMI。name字段是用户控制的,不被选中.
更新:因为这是关于封隔器而不是Terraform的,所以这里是Packer解决方案:
"source_ami_filter": {
"filters": {
"virtualization-type": "hvm",
"architecture": "x86_64",
"name": "ubuntu/images/hvm-ssd/ubuntu-bionic-18.04-amd64-server-*",
"block-device-mapping.volume-type": "gp2",
"root-device-type": "ebs"
},
"owners": ["099720109477"],
"most_recent": true
},以下是我善意但却不涉及主题的Terraform解决方案:
数据"aws_ami“"ubuntu-18_04”{ most_recent =真 most_recent= "${var.ubuntu_account_number}“
或者,如果您想用您自己的KMS CMK加密它:
资源"aws_ami_copy“”ubuntu-18_04-加密的“{description name= "${data.aws_ami.ubuntu-18_04.name}-encrypted”description= "${data.aws_ami.ubuntu-18_04.description} (加密)“ source_ami_id =”${data.ws_ami.ubuntu-18_04.id}“ source_ami_region =${var。数据"aws_ami“aws_ami "ubuntu-18_04”{ most_recent = "${var.ubuntu_account_number}“筛选器{ most_recent=”${var.ubuntu_account_number}“*“099720109477}}变量"ubuntu_account_number”{default= "099720109477“}}
发布于 2021-05-18 22:23:05
在2021年,我们使用了Packer HCL2语言和Ubuntu20.04,并支持多种体系结构
variable "arch" {
type = string
default = "${env("ARCH")}"
}
source "amazon-ebs" "ubuntu" {
source_ami_filter {
filters = {
name = "ubuntu/images/*ubuntu-focal-20.04-*-server-*"
architecture = "${var.arch}"
root-device-type = "ebs"
virtualization-type = "hvm"
}
most_recent = true
owners = ["099720109477"]
}
}https://stackoverflow.com/questions/62426904
复制相似问题