Use Product Code to filter AMIs used as source images by packer
Add documentation for this process
Change-Id: I5d548ceefb93602d751b5c88230e7dba0a88be2a
diff --git a/packer/templates/basebuild.json b/packer/templates/basebuild.json
index 92f5090..e19bf61 100644
--- a/packer/templates/basebuild.json
+++ b/packer/templates/basebuild.json
@@ -1,10 +1,12 @@
{
"variables": {
+ "instance_type": "t2.medium",
"aws_access_key": null,
"aws_security_key": null,
"security_group_id": null,
"source_ami_filter_name": null,
"source_ami_filter_owner": null,
+ "source_ami_filter_product_code": "",
"subnet_id": null,
"ssh_user": null,
"distro": null,
@@ -15,13 +17,14 @@
{
"access_key": "{{user `aws_access_key`}}",
"ami_name": "{{user `distro`}} - basebuild - {{user `arch`}} - {{isotime \"20060102-1504\"}}",
- "instance_type": "t2.micro",
+ "instance_type": "{{user `instance_type`}}",
"region": "us-west-2",
"secret_key": "{{user `aws_security_key`}}",
"security_group_id": "{{user `security_group_id`}}",
"source_ami_filter": {
"filters": {
"name": "{{user `source_ami_filter_name`}}",
+ "product-code": "{{user `source_ami_filter_product_code`}}",
"architecture": "{{user `arch`}}",
"root-device-type": "ebs",
"virtualization-type": "hvm"
diff --git a/packer/vars/centos-7.json b/packer/vars/centos-7.json
index aa629a9..340f545 100644
--- a/packer/vars/centos-7.json
+++ b/packer/vars/centos-7.json
@@ -1,6 +1,8 @@
{
"source_ami_filter_name": "*CentOS Linux 7*HVM*",
- "source_ami_filter_owner": "679593333241",
+ "source_ami_filter_owner": "aws-marketplace",
+ "source_ami_filter_product_code": "aw0evgkw8e5c1q413zgy5pjce",
+
"ssh_user": "centos",
"distro": "CentOS 7",
diff --git a/packer/vars/ubuntu-16.04.json b/packer/vars/ubuntu-16.04.json
index 972ff75..4f7d473 100644
--- a/packer/vars/ubuntu-16.04.json
+++ b/packer/vars/ubuntu-16.04.json
@@ -1,6 +1,7 @@
{
"source_ami_filter_name": "*ubuntu*16.04*",
- "source_ami_filter_owner": "099720109477",
+ "source_ami_filter_owner": "aws-marketplace",
+ "source_ami_filter_product_code": "csv6h7oyg29b7epjzg7qdr7no",
"ssh_user": "ubuntu",