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. 
>
> On Tue, Feb 25, 2020, 18:23 Mohammed Majid <[email protected] 
> <javascript:>> wrote:
>
>> 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
>>
>> -- 
>> 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 [email protected] <javascript:>.
>> To view this discussion on the web visit 
>> https://groups.google.com/d/msgid/packer-tool/CAGr0K9dkPcsy1cJaaGxNke2%3D03CPy-p%3DY8NV8wVsu9-GZkZT4A%40mail.gmail.com
>>  
>> <https://groups.google.com/d/msgid/packer-tool/CAGr0K9dkPcsy1cJaaGxNke2%3D03CPy-p%3DY8NV8wVsu9-GZkZT4A%40mail.gmail.com?utm_medium=email&utm_source=footer>
>> .
>>
>

-- 
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 [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/packer-tool/e3527a38-f7d7-4724-98a7-395074471820%40googlegroups.com.

Reply via email to