Skip to content

Instantly share code, notes, and snippets.

@pivotaljohn
Last active April 17, 2020 21:17
Show Gist options
  • Save pivotaljohn/d3468c3239f79fea7e232751757e779a to your computer and use it in GitHub Desktop.
Save pivotaljohn/d3468c3239f79fea7e232751757e779a to your computer and use it in GitHub Desktop.
Referencing JSON data in a ytt template
$ ytt --data-value-file stable_config=stable_config.json -f cluster-template-paving.yaml -f values.yml

Note: the values.yml defines the stable_config data value. Without that declaration, the implied overlay from --data-value-file would fail. That is: values provided on the command-line overlay values from data value files.

#@ load("@ytt:data", "data")
#@ load("@ytt:json", "json")
#@ stable_config = json.decode(data.values.stable_config)
vpc_id: #@ stable_config["vpc_id"]
second_subnet_id: #@ stable_config["pks_subnet_ids"][1]
{
"vpc_id": "pete",
"pks_subnet_ids": [ 1, 2, 3 ]
}
#@data/values
---
stable_config: ~
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment