If you're looking for the AMI released by Cannonical, you need the
appropriate "owner":

This works for me:

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

On Tue, Aug 14, 2018 at 3:38 PM, Steve Schofield <[email protected]>
wrote:

> I'm newer to packer and aws...I've spent the afternoon and got an image
> build if I hard code an ami image name.  I can't get filtering to work.  I
> get the error about not finding anything.  I did get my sample to build
> successfully in aws account if I hard code the name of the ami.   I'm a bit
> lost where to turn to next.   I'll continue to search the interwebs.
> Looking for some direction.
>
> I've been using the following URL for reference...https://docs.aws.
> amazon.com/AWSEC2/latest/APIReference/API_DescribeImages.html
> My complete JSON is listed below.
>
> amazon-ebs output will be in this color.
>
> ==> amazon-ebs: Prevalidating AMI Name: packer-ES-1534285997
> ==> amazon-ebs: No AMI was found matching filters: {
> ==> amazon-ebs:   Filters: [{
> ==> amazon-ebs:       Name: "name",
> ==> amazon-ebs:       Values: ["ubuntu/images/*ubuntu-
> xenial-16.04-amd64-server-*"]
> ==> amazon-ebs:     },{
> ==> amazon-ebs:       Name: "root-device-type",
> ==> amazon-ebs:       Values: ["ebs"]
> ==> amazon-ebs:     },{
> ==> amazon-ebs:       Name: "virtualization-type",
> ==> amazon-ebs:       Values: ["hvm"]
> ==> amazon-ebs:     }],
> ==> amazon-ebs:   Owners: ["123456789"]
> ==> amazon-ebs: }
> Build 'amazon-ebs' errored: No AMI was found matching filters: {
>   Filters: [{
>       Name: "name",
>       Values: ["ubuntu/images/*ubuntu-xenial-16.04-amd64-server-*"]
>     },{
>       Name: "root-device-type",
>       Values: ["ebs"]
>     },{
>       Name: "virtualization-type",
>       Values: ["hvm"]
>     }],
>   Owners: ["123456789"]
> }
>
> complete json
>
> {
>  "builders": [
>   {
>    "type": "amazon-ebs",
>    "access_key": "{{user `access_key_#`}}",
>    "secret_key": "{{user `secret_key_#`}}",
>    "region": "us-east-1",
>          "instance_type" : "t2.micro",
>          "ssh_username" : "ubuntu",
>          "ami_name" : "packer-ES-{{timestamp}}",
>          "source_ami_filter": {
>             "filters": {
>               "virtualization-type": "hvm",
>               "name": "ubuntu/images/*ubuntu-xenial-16.04-amd64-server-*",
>               "root-device-type": "ebs"
>             },
>             "owners": ["123456789"],
>             "most_recent": true
>          },
>          "launch_block_device_mappings" : [
>             {
>                "device_name" : "/dev/sdb",
>                "delete_on_termination" : true,
>                "volume_size" : 10,
>                "volume_type" : "gp2"
>             }
>          ],
>          "ami_block_device_mappings" : [
>             {
>                "device_name" : "/dev/sdb",
>                "delete_on_termination" : true,
>                "volume_type" : "gp2"
>             }
>          ]
>       }
>    ],
>    "provisioners": [
>      {
>        "type": "shell",
>        "inline": [
>          "lsblk",
>          "df -h"
>        ]
>      }
>    ]
> }
>
>
> --
> 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/5c42e184-4ef0-4492-b9c5-48c2d1d2dde7%40googlegroups.com
> <https://groups.google.com/d/msgid/packer-tool/5c42e184-4ef0-4492-b9c5-48c2d1d2dde7%40googlegroups.com?utm_medium=email&utm_source=footer>
> .
> For more options, visit https://groups.google.com/d/optout.
>

-- 
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/CAGPV1upYRwsdfaEbaAy8-cm5CTyS59wxGAgrFxUUB2bgwNV-cQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to