org-formation-cli
org-formation-cli copied to clipboard
Feature request: !StringJson function
Subject
I would like a function that's the opposite of !JsonString to support my use cases. The general use case is to convert a string to a json object then pass it to a cloudformation or TemplatingContext parameter.
Use cases
These use cases are derived from the Templating context example in the docs:
Read ports in from a file, convert the string to a json list object and then pass it to the ports parameter:
SecurityGroupExample:
Type: update-stacks
Template: ./security-group.njk
StackName: SecurityGroupExample
Parameter:
ports: !StringJson
- !Readfile "ports.json"
Get data from a REST API endpoint, convert the string to a json dictionary object and then pass it to the hounds TemplatingContext parameter:
DogsExample:
Type: update-stacks
Template: ./dogs.njk
StackName: DogsExample
TemplatingContext:
hounds: !StringJson
- !Cmd "wget -qO- https://dog.ceo/api/breed/hound/list"
have you tried:
SecurityGroupExample:
Type: update-stacks
Template: ./security-group.njk
StackName: SecurityGroupExample
Parameter:
ports: !Include "ports.json"
I dont think this will help with the !Cmd "wget -qO- https://dog.ceo/api/breed/hound/list"
though....
I have not tried !Include
in that context @OlafConijn. I will investigate that.
I dont think this will help with the !Cmd "wget -qO- https://dog.ceo/api/breed/hound/list" though....
If !Cmd
doesn't work then how about a new org-formation !Request
function would basically do a "curl -X GET https://dog.ceo/api/breed/hound/list"? This is how it would work..
Get data from a REST API endpoint, convert the string to a json dictionary object and then pass it to the hounds TemplatingContext parameter:
DogsExample:
Type: update-stacks
Template: ./dogs.njk
StackName: DogsExample
TemplatingContext:
hounds: !StringJson
- !Request "https://dog.ceo/api/breed/hound/list"