Packer amazon-ebs builder source_ami_filter Issue

1,774 views
Skip to first unread message

Josh Lynn

unread,
Dec 7, 2016, 8:12:52 AM12/7/16
to Packer
Hello All,

I'm experiencing an issue with my packer.json file with what appears to be a configuration issue with the source_ami_filter object.  I receive the following error when trying to run packer (via Jenkins):

2016/12/06 22:10:01 Preparing build: amazon-ebs
2016/12/06 22:10:01 Build 'amazon-ebs' prepare failure: 1 error(s) occurred:

* unknown configuration key: "source_ami_filter"
2016/12/06 22:10:01 ui error: Template validation failed. Errors are shown below.
2016/12/06 22:10:01 ui error: Errors validating build 'amazon-ebs'. 1 error(s) occurred:

I'm using the following 'builders' configuration:

"builders": [
    {
      "type": "amazon-ebs",
      "ssh_username": "ubuntu",
      "region": "{{user `packer_region`}}",
      "source_ami_filter": { "filters": {
          "virtualization-type": "hvm", 
          "name": "*ubuntu-trusty-14.04-amd64-server-*", 
          "root-device-type": "ebs" }, 
          "owners": ["099720109477"], 
          "most_recent": true 
      },
      "encrypted": "true",
      "instance_type": "{{user `packer_instance_type`}}",
      "iam_instance_profile": "{{user `packer_iam_instance_profile`}}",
      "vpc_id": "{{user `packer_vpc_id`}}",
      "subnet_id": "{{user `packer_subnet_id`}}",
      "security_group_id": "{{user `packer_security_group_id`}}",
      "ami_name": "{{user `role`}}-{{user `environment`}}- {{timestamp}}"
    }
  ],


Packer version is 0.10.1.  

According to the amazon-ebs builder documentation here:  https://www.packer.io/docs/builders/amazon-ebs.html I should be able to use source_ami_filter and have that do a dynamic lookup of the latest ami I'm looking for to build into my base image.  I can run things fine if I use source_ami and I hardcode or pass the ami into the source_ami object as a string, but I am trying to use some build-in functionality within packer to improve our pipeline a bit.

Alternatively, I attempted to put in a shell provisioner to find the AMI using the AWS CLI (See below), and I can still work that angle, but I wanted to try the method mentioned above with packer as it seems a bit cleaner.

AWS CLI example:

aws ec2 describe-images  \
  --region us-east-1 \
  --filter Name=owner-id,Values=099720109477  \
  --query 'Images[? starts_with(ImageLocation, `099720109477/ubuntu/images/hvm-ssd/ubuntu-trusty-14.04-amd64-server`)] | sort_by(@, & ImageLocation) | [-1] | ImageId'  --out text --profile hl-prod


I would appreciate any assistance on this.

Thank you!
Josh

Rickard von Essen

unread,
Dec 7, 2016, 11:36:41 AM12/7/16
to packe...@googlegroups.com
This is a new feature, upgrade to 0.12.0. 

--
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+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/packer-tool/1c94b466-e340-4a8a-96da-91c4659ca733%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Josh Lynn

unread,
Dec 7, 2016, 3:05:46 PM12/7/16
to Packer
Thanks Rickard, I was alerted to this by someone in the packer-tool IRC channel.  

I upgraded to 0.12.0 and this feature is working quite well for me!
To unsubscribe from this group and stop receiving emails from it, send an email to packer-tool...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages