Created
January 11, 2019 20:21
-
-
Save robinbowes/c01275094747650033f6ddbe235be4ed to your computer and use it in GitHub Desktop.
Given input.json, I'd like to extract all the variable names and any default values
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"variable": { | |
"cloud": { | |
"description": "The cloud for this service" | |
}, | |
"cluster": { | |
"default": "default", | |
"description": "The cluster name to use for this service" | |
}, | |
"cost_center": { | |
"default": "unknown", | |
"description": "Used to set Cost Center tag, for accounting purposes" | |
}, | |
"owner": { | |
"default": "unknown", | |
"description": "Used to set Owner tag, for accounting purposes" | |
}, | |
"region": { | |
"description": "The region for this service" | |
}, | |
"service": { | |
"default": "netbox", | |
"description": "The service name" | |
}, | |
"site": { | |
"description": "The site for this service" | |
}, | |
"ssm_region": { | |
"description": "The region to use for the SSM parameter store" | |
}, | |
"stage": { | |
"description": "The stage for this service" | |
} | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"cloud": "", | |
"cluster": "default", | |
"cost_center": "unknown", | |
"owner": "unknown", | |
"region": "", | |
"service": "netbox", | |
"site": "", | |
"ssm_region": "", | |
"stage": "" | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Actually, the input file is terraform code. I first converted to JSON using hcltool.
This is
variables.tf
:This is how I converted it:
Output: