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