Skip to content

Instantly share code, notes, and snippets.

I want to configure an AWS Launch Config resource to use a local user-data file from the repo. And I set that up okay
using file(), but variables had to be hard-coded for each stack. There was no interpolation. That's fine if each stack
has their own launch config, but what I'd really like to do is re-use one user-data file for a couple different stacks
and feed in variables to differentiate between each.
I created a template resource and file and fed in variables, but I'm getting a weird error. Is this the correct approach?
# Code snippet
>I want to configure an AWS Launch Config resource to use a local user-data file from the repo. And I set that up okay using file(), but variables had to be hard-coded for each stack. There was no interpolation.
>That's fine if each stack has their own launch config, but what I'd really like to do is re-use one user-data file for a couple different stacks and feed in variables to differentiate between each.
>I created a template resource and file and fed in variables, but I'm getting a weird error. Is this the correct approach?
``
# Code snippet
data "template_file" "user-data" {
require 'chef/provisioning/aws_driver'
with_driver 'aws'
# Public subnet
machine 'test' do
tag 'test_successful'
recipe 'hdp::default'
with_machine_options :bootstrap_options => {
:key_name => 'jreid2012',
$ chef-client -z simple.rb
[2015-04-11T21:54:50-04:00] INFO: Started chef-zero at http://localhost:8889 with repository at /Users/jreid/repo/chef-repo
One version per cookbook
[2015-04-11T21:54:50-04:00] INFO: Forking chef instance to converge...
Starting Chef Client, version 12.2.1
[2015-04-11T21:54:50-04:00] INFO: *** Chef 12.2.1 ***
[2015-04-11T21:54:50-04:00] INFO: Chef-client pid: 18822
[2015-04-11T21:54:52-04:00] INFO: Run List is []
[2015-04-11T21:54:52-04:00] INFO: Run List expands to []
# Run help to see available commands, apps.
$ ./bin/chefdk-update-app.sh -h
Usage: ./bin/chefdk-update-app.rb APP_NAME [options]
-r, --ref REF Git reference (branch, tag, sha, etc.)
-h, --help Prints this help
App names:
* berkshelf
* chef