Skip to content

vincentjorgensen/yaml_to_json

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

12 Commits
 
 
 
 
 
 
 
 

Repository files navigation

yaml_to_json

Convenience scripts for converting from yaml to json. Currently my usecase is writing AWS CloudFormation templates in YAML and then converting them to JSON for the upload to AWS.

Two implementations are included: Ruby and Python.

The advantage of writing CloudFormation templates in YAML over JSON is that YAML allows for comments. Also, in my option, YAML is far for readable than JSON. Since CloudFormation requires JSON, it's convenient to develop to YAML and then convert to JSON right before uploading.

If you would like to contribute another language, please fork and open a PR.

Example:

yaml_to_json.py < cf.yaml > cf.cftemplate

aws cloudformation create --template-body file://cf.cftemplate

CloudFormation Functions

Some common CloudFormation functions are non-obvious in YAML. The following are quick conversions.

JSON YAML
"Fn::GetAtt":
[ "MyLoadBalancer",
"DNSName" ]
Fn::GetAtt:
- MyLoadBalancer
- DNSName
"Fn::Join":
[ "delimiter",
[ comma-delimited, list,
of, values ] ]
Fn:Join:
- delimiter
- - comma-delimited
  - list
  - of
  - values
"Fn::FindInMap:"
[ "EbsOptimizedMap",
{ "Ref": "InstanceType" },
"Optimized" ]
Fn::FindInMap:
  - EbsOptimizedMap
  - Ref: InstanceType
  - Optimized

About

Convenience scripts for converting from yaml to json

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published