Packer not returning latest AMI ID

88 views
Skip to first unread message

Mohammed Majid

unread,
Feb 25, 2020, 12:23:44 PM2/25/20
to packe...@googlegroups.com
Dear Packer group,

I am using latest packer 1.5.4

I want to get the latest AMI ID's for Ubuntu 16.04, 18.04, CentOS7, AmazonLinux2

Packer always uses the AMI ID which is one ami behind the latest ami, even though i tell to use the latest AMI.

The following is the aws ec2 command which will return the latest AMI.

aws ec2 describe-images \

     --filters "Name=name,Values=ubuntu/images/hvm-ssd/ubuntu-xenial-16.04-amd64-server-*" \

     --query 'Images[*].[ImageId,CreationDate]' --output text \

     | sort -k2 -r \

     | head -n1


Which returns ami-092d0fe375260a228 , it is the latest one.


In the packer json template i am using the following.

"source_ami": "{{user `source_ami`}}",
"source_ami_filter": {
               "filters": {
                "virtualization-type": "hvm",
                "name":"ubuntu/images/hvm-ssd/ubuntu-xenial-16.04-amd64-server-*",
                "root-device-type": "ebs"
              },
              "owners": ["099720109477"],
              "most_recent": true
           }

it returns ami-08bc77a2c7eb2b1da and is not the latest one.

In the above code i am passing the latest ami id in the source_ami variable, its not considering that, instead it picks an ami id which is one ami behind the latest one.

Could you please let me know how can i solve this issue ?

Appreciate your reply.

Thanks & Regards
Majid M A

Rickard von Essen

unread,
Feb 25, 2020, 12:36:45 PM2/25/20
to packe...@googlegroups.com
Your describe-images command doesn't filter based on owners which makes it vulnerable to finding images from untrusted/malicious sources. 

--
This mailing list is governed under the HashiCorp Community Guidelines - https://www.hashicorp.com/community-guidelines.html. Behavior in violation of those guidelines may result in your removal from this mailing list.
 
GitHub Issues: https://github.com/mitchellh/packer/issues
IRC: #packer-tool on Freenode
---
You received this message because you are subscribed to the Google Groups "Packer" group.
To unsubscribe from this group and stop receiving emails from it, send an email to packer-tool...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/packer-tool/CAGr0K9dkPcsy1cJaaGxNke2%3D03CPy-p%3DY8NV8wVsu9-GZkZT4A%40mail.gmail.com.

Mohammed Majid

unread,
Feb 25, 2020, 12:44:03 PM2/25/20
to Packer
Understood i have not supplied the owner in the aws ec2 describe command, but if use the following code in the packer, it does not yield latest ami.

"source_ami_filter": {
               "filters": {
                "virtualization-type": "hvm",
                "name":"ubuntu/images/hvm-ssd/ubuntu-xenial-16.04-amd64-server-*",
                "root-device-type": "ebs"
              },
              "owners": ["099720109477"],
              "most_recent": true
           }

am i missing anything ? please let me know.

Awaiting your response.


On Tuesday, February 25, 2020 at 11:06:45 PM UTC+5:30, Rickard von Essen wrote:
Your describe-images command doesn't filter based on owners which makes it vulnerable to finding images from untrusted/malicious sources. 

To unsubscribe from this group and stop receiving emails from it, send an email to packe...@googlegroups.com.

John Roh

unread,
Feb 25, 2020, 1:08:07 PM2/25/20
to packe...@googlegroups.com
Putting "ubuntu-xenial-16.04-amd64-server-*" should be enough. 
Is this AMI belong to the account, 099720109477? 

To unsubscribe from this group and stop receiving emails from it, send an email to packer-tool...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/packer-tool/e3527a38-f7d7-4724-98a7-395074471820%40googlegroups.com.

Mohammed Majid

unread,
Feb 25, 2020, 1:08:53 PM2/25/20
to Packer
Yes rickard, the latest ami what i was getting was from an unknown owner.

When i did supply the owner, the ami id's is consistent 

Thanks for you pointing it and thanks for your help.

Thanks & Regards,
Majid M A

Mohammed Majid

unread,
Feb 25, 2020, 1:09:13 PM2/25/20
to packe...@googlegroups.com
Yes, this is from 099720109477.

Reply all
Reply to author
Forward
0 new messages