From 05312e509489213bede2ed1f98ee0d5ffd810c9a Mon Sep 17 00:00:00 2001 From: Cliffano Subagio Date: Mon, 14 Mar 2016 00:56:43 +1100 Subject: [PATCH] More note on variable interpolation support. --- README.md | 27 ++++++++++++++++++++++----- 1 file changed, 22 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index fa307e3..290b3b8 100644 --- a/README.md +++ b/README.md @@ -32,10 +32,7 @@ Add `json-updater` type to Packer template's post-processor section: ], "templates/child_template_2.json": [ "variables.aws_source_ami" - ], - "templates/child_template_3.json": [ - "{{ build_name }}.aws_source_ami" - ], + ] } } ] @@ -46,4 +43,24 @@ The above `ami_id` configuration indicates that the ID of the newly created AWS "aws_source_ami": "" } -You can use Configuration Templates, they will be expanded upon Template build time. +Variable interpolation is also supported: + + "variables": { + "build_id": "build_123" + }, + "post-processors": [ + { + "type": "json-updater", + "ami_id": { + "templates/child_template_3.json": [ + "variables.aws_source_ami_{{user `build_id` }}" + ], + } + } + ] + +The above `ami_id` configuration indicates that the ID of the newly created AWS AMI will be set as the value of `variables.aws_source_ami_build_123` key in `templates/child_template_3.json` file. + + "variables": { + "aws_source_ami_build_123": "" + }