Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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