i create a private ami on amazon and installed few things on it manually. I am new to packer and i now want to use the previous image as base and create new ami using packer. However i keep on getting error message that my base image does not exists. Here is my packer file
data "amazon-ami" "cocktails" {
filters = {
virtualization-type = "hvm"
name = "test-ami-24112022"
root-device-type = "ebs"
}
owners = ["my-account-id"]
most_recent = true
}
source "amazon-ebs" "cocktails" {
instance_type = "t2.micro"
region = "eu-west-2"
ssh_username = "ec2-user"
ami_name = "test-${uuidv4()}"
source_ami = data.amazon-ami.cocktails.id
}
build {
sources = ["source.amazon-ebs.cocktails"]
provisioner "file" {
source = "test.txt"
destination = "/home/ec2-user/test.txt"
}
}
This is the error i am getting
Datasource.Execute failed: No AMI was found matching filters: {
Filters: [{
Name: "root-device-type",
Values: ["ebs"]
},{
Name: "virtualization-type",
Values: ["hvm"]
},{
Name: "name",
Values: ["test-ami-24112022"]
}],
Owners: ["my-account-id"]
}
on main.pkr.hcl line 1:
(source code not available)
The issue was in my config file of aws. It had some pre loaded data which i used previously and it was pointing to wrong region, when i deleted the config and recreated using correct region it worked
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.