https://github.com/b-b3rn4rd/json2ssm
AWS Parameter Store import & export functionality for JSON
https://github.com/b-b3rn4rd/json2ssm
aws golang json ssm
Last synced: 5 months ago
JSON representation
AWS Parameter Store import & export functionality for JSON
- Host: GitHub
- URL: https://github.com/b-b3rn4rd/json2ssm
- Owner: b-b3rn4rd
- License: apache-2.0
- Created: 2018-05-14T11:48:12.000Z (about 8 years ago)
- Default Branch: master
- Last Pushed: 2020-01-15T19:56:40.000Z (over 6 years ago)
- Last Synced: 2024-06-19T05:43:02.031Z (about 2 years ago)
- Topics: aws, golang, json, ssm
- Language: Go
- Size: 38.1 KB
- Stars: 52
- Watchers: 3
- Forks: 10
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
[](https://goreportcard.com/report/github.com/b-b3rn4rd/json2ssm) [](https://travis-ci.org/b-b3rn4rd/json2ssm) JSON import/export functions with AWS SSM Parameter Store
================================================
*json2ssm* - provides JSON import, export and delete functionality when working with AWS SSM parameter store while keeping original data types.
Motivation
--------------
AWS SSM Parameter Store is a great service for centrally storing and managing application parameters and secrets.
However, seeding parameters often becomes an adhoc process when parameters are added manually
or provisioned from different scripts which makes it difficult to promote applications between environments.
Using `json2ssm` parameters can be imported from a single or multiple JSON source files, additionally, it also provides export function to recursively retrieve parameters in JSON format for scenarios
when it's easier to work with JSON structure, for example with Jenkins pipelines or inside ansible playbooks.
Examples
----------------
Let's start with an example and import following file into SSM parameter store:
```bash
$ cat ../../pkg/storage/testdata/colors.json
{
"colors": [
{
"color": "black",
"category": "hue",
"type": "primary",
"code": {
"rgba": [255,255,255,1],
"hex": "#000"
}
},
{
"color": "white",
"category": "value",
"code": {
"rgba": [0,0,0,1],
"hex": "#FFF"
}
},
{
"color": "red",
"category": "hue",
"type": "primary",
"code": {
"rgba": [255,0,0,1],
"hex": "#FF0"
}
},
{
"color": "blue",
"category": "hue",
"type": "primary",
"code": {
"rgba": [0,0,255,1],
"hex": "#00F"
}
},
{
"color": "yellow",
"category": "hue",
"type": "primary",
"code": {
"rgba": [255,255,0,1],
"hex": "#FF0"
}
},
{
"color": "green",
"category": "hue",
"type": "secondary",
"code": {
"rgba": [0,255,0,1],
"hex": "#0F0"
}
}
]
}
```
```bash
$ json2ssm put-json --json-file ../../pkg/storage/testdata/colors.json
47 / 47 [=============================================================================>] 100%
Import has successfully finished, 47 parameters have been (over)written to SSM parameter store.
```
Retrieve the first color:
```bash
$ json2ssm get-json --path "/colors/0"
8 / 8 [==============================================================================] 8s
{
"category": "hue",
"code": {
"hex": "#000",
"rgba": [
255,
255,
255,
1
]
},
"color": "black",
"type": "primary"
}
```
Retrieve the first color's `rgba` value and store it in a file:
```bash
$ json2ssm get-json --path "/colors/0/code/rgba" > rgba.son
4 / 4 [==============================================================================] 2s
$ cat rgba.json
[
255,
255,
255,
1
]
```
Installation
=============
```bash
brew tap b-b3rn4rd/homebrew-tap
brew install json2ssm
```
*Using go get*
```bash
go get github.com/b-b3rn4rd/json2ssm
```
Usage
=============
```bash
$ json2ssm --help
usage: json2ssm [] [ ...]
Flags:
--help Show context-sensitive help (also try --help-long and
--help-man).
-d, --debug Enable debug logging.
--version Show application version.
Commands:
help [...]
Show help.
put-json --json-file=JSON-FILE --encrypt []
Creates SSM parameters from the specified JSON file.
get-json --path=PATH --decrypt
Retrieves JSON document from SSM parameter store using given path (prefix).
del-json --json-file=JSON-FILE
Deletes parameters from SSM parameter store based on the specified JSON
file.
```