Aws-parameter-bulk - Export AWS SSM Parameter Store values in bulk to .env files

aws-parameter-bulk

Utility to read parameters from AWS Systems Manager (SSM) Parameter Store in bulk and output them in environment-file or json format. It can read all parameters for a given path, or read a list of single parameters. If the parameters contain json, this can be parsed as single values via a flag. It uses your current aws profile to access AWS SSM, you can supply a different profile if you need to read from a different account. Have your AWS CLI set up correctly. See below for instructions.

The output can be used as .env in your development workspace, as --from-env in docker, or as Kubernetes secret.

Usage

get reads names from single values, or from a path recursively. Use --help for usage and parameters.

$ aws-parameter-bulk --help

$ aws-parameter-bulk get --help

Assuming you have the following structure in SSM, and the parameters are filled with "valueOfParam1" etc.:

/dev/test/param1
/dev/test/param2
/dev/test/param3
/dev/other/other1
/dev/other/other2
/dev/testextend/param1
someparam1
someparam2
jsonparam1
jsonparam2

Get Path

These are the outputs you can create for a path variable. Note that the last part of the path will be printed in upper case, if you supply the --upper flag. To be a valid ENV Identifier the output has to use this format: [a-zA-Z_][a-zA-Z0-9_]*

$ aws-parameter-bulk get /dev/test --upper
PARAM1=valueOfParam1
PARAM2=valueOfParam2
PARAM3=valueOfParam3

Get Multiple Paths

You can supply multiple paths:

$ aws-parameter-bulk get /dev/test,/dev/other --upper
PARAM1=valueOfParam1
PARAM2=valueOfParam2
PARAM3=valueOfParam3
OTHER1=valueOfOther1
OTHER2=valueOfOther2

Overwrite Values

An env file key must be unique, therefore it will be filtered so each key only occurs once. The last key to appear will be printed out, so this will overwrite /dev/test/param1 with /dev/testextend/param1. This can be used to first read some default values and overwrite some of them.

$ aws-parameter-bulk get /dev/test,/dev/testextend --upper
PARAM1=valueOfParamFromExtend1
PARAM2=valueOfParam2
PARAM3=valueOfParam3

JSON Output

Output path parameters as JSON file:

$ aws-parameter-bulk get /dev/test,/dev/other --upper --outjson
{
    "PARAM1": "valueOfParam1",
    "PARAM2": "valueOfParam2",
    "PARAM3": "valueOfParam3",
    "OTHER1": "valueOfOther1",
    "OTHER2": "valueOfOther2"
}

Get Single Parameters

Reading single (non-path) SSM Parameters.

$ aws-parameter-bulk get someparam1,someparam2 --upper
SOMEPARAM1=valueOfSomeParam1
SOMEPARAM2=valueOfSomeParam2

Get Parameters Containing JSON

Reading SSM Parameters containing JSON, parsing and converting them. This also works for path parameters. Each parameter has to be json.

Assuming this is jsonparam1:

{
  "Json1a": "value1a",
  "Json1b": "value1b"
}

And jsonparam2:

{
  "JSON2a": "value2a",
  "JSON2b": "value2b"
}

This will be the output:

$ aws-parameter-bulk get jsonparam1,jsonparam2 --injson --upper
JSON1A=value1a
JSON1B=value1b
JSON2A=value2a
JSON2B=value2b

Saving From .env File To SSM Names

Takes a file in KEY=value form, and store each line as name and valie in ssm.

$ aws-parameter-bulk save .env
NAME1
NAME2

Saving From .env File To SSM Paths

Takes a file in KEY=value form, prefixes each key with the given path, and stores it in ssm.

$ aws-parameter-bulk save .env /dev/something
/dev/something/PARAM1
/dev/something/PARAM2

Saving From JSON File To SSM Paths

Using a json file as input and storing it to a path

$ aws-parameter-bulk save .env /dev/something --injson

/dev/something/key1=val1
2021-12-07T22:38:19Z INF pkg/util/awsssm.go:174 > Output: {
  Version: 1
}
/dev/something/key2=val2
2021-12-07T22:38:20Z INF pkg/util/awsssm.go:174 > Output: {
  Version: 1
}

Debugging

Add SSM_LOG_LEVEL=debug

$ SSM_LOG_LEVEL=debug aws-parameter-bulk get jsonparam1, jsonparam2 --injson --upper

Web UI

Start with parameter "web" to start a web ui on http://localhost:8888. Change the listen ip and port with the --address flag.

$ aws-parameter-bulk web

$ aws-parameter-bulk web --address :1234

AWS Setup

https://docs.aws.amazon.com/cli/latest/userguide/cli-configure-quickstart.html

It is important that you set your region in your aws profile.

$ aws configure
AWS Access Key ID [None]: AKIAIOSFODNN7EXAMPLE
AWS Secret Access Key [None]: wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY
Default region name [None]: eu-central-1
Default output format [None]: json

If you have multiple profiles like this (.aws/config):

[default]
account = 11111111111
region = eu-central-1
output = json

[profile other]
account = 2222222222
region = eu-central-1
output = json
source_profile = default

You can read the SSM Parameters from the other account like this:

$ AWS_PROFILE=other aws-parameter-bulk get /dev/test
Owner
Adam Malik
Software Developer, DevOps Engineer
Adam Malik
Similar Resources

Aws-cognito-demo-go - Source code for AWS Cognito in Go

AWS Cognito Demo in Go Source code for YouTube series, AWS Cognito in Go - https

Dec 10, 2022

Una prueba técnica: Servicio Golang REST API local, sobre Docker, gRPC, AWS Serverless y sobre Kubernetes en AWS EC2

Una prueba técnica: Servicio Golang REST API local, sobre Docker, gRPC, AWS Serverless y sobre Kubernetes en AWS EC2

May 7, 2022

Aws-cdk-go-examples - Example projects using the AWS CDK by Golang

aws-cdk-go-examples Example projects using the AWS CDK by Golang Useful commands

Nov 24, 2022

A tool to decrypt files by AWS KMS

KMS-Decrypter Decrypt all files in folder then output to destination folder by AWS KMS. Usage Usage of ./.out/decrypter: -f string path to e

Sep 20, 2022

Apple Store 预约助手

 Apple Store 预约助手

Apple Store 预约助手 本项目仅供学习使用 iPhone13系列 重构, 升级 fyne 至 2.0, 写起来的确比 1.0 舒服得多 azhan info 修改版本更多的意义在于___库存监控 2021.10.8_16:00pm, 完成了修复和测试 仅用于澳门iphone13预约 修改m

Apr 19, 2022

It is a package and command line application that provides you to store encrypted credentials/secrets in your repository.

sypher[ ⚠️ Work in progress] sypher provides you to store your credentials and secrets as encrypted in your repository. Usage Install the command line

Feb 23, 2022

AWS SDK for the Go programming language.

AWS SDK for Go aws-sdk-go is the official AWS SDK for the Go programming language. Checkout our release notes for information about the latest bug fix

Dec 31, 2022

Simple tool to search tagged resources between all AWS resouces

Welcome to Cloud Inventory Tags 👋 Simple tool to search tagged resources around all AWS Account Installation MacOS / OSX

Jan 26, 2022

Lambda stack to turn off and destroy all resources from your personal AWS Account to avoid billing surprises

Lambda stack to turn off and destroy all resources from your personal AWS Account to avoid billing surprises

AWS, Turn off my Account, please Lambda stack to turn off and destroy all resources from your personal AWS Account to avoid billing surprises Resource

Oct 25, 2022
Comments
  • Feature request: Use underscores in export for prefix path

    Feature request: Use underscores in export for prefix path

    With a SSM structure like:

    /app/foo = foo
    /app/bar/foo = foo
    

    and using aws-parameter-bulk get /app --prefixpath --upper --export results in outputting:

    export /APP/FOO=foo
    export /APP/BAR/FOO=foo
    

    Could this be adapted so it would replace the slashes to underscores instead like so?

    export APP_FOO=foo
    export APP_BAR_FOO=foo
    
A thin go client that interfaces with AWS SSM

go-ssm-aws A thin go client that interfaces with AWS SSM. Why this package? This

May 14, 2022
Alibaba Cloud cms-export SDK for Go

English | 简体中文 Alibaba Cloud cms-export SDK for Go Requirements It's necessary for you to make sure your system have installed Go environment which ve

Jan 10, 2022
Log4Shell: a middleware plugin for Traefik which blocks JNDI attacks based on HTTP header values
Log4Shell: a middleware plugin for Traefik which blocks JNDI attacks based on HTTP header values

Traefik (pronounced traffic) is a modern HTTP reverse proxy and load balancer that makes deploying microservices easy. Traefik integrates with your ex

Dec 26, 2022
Simple no frills AWS S3 Golang Library using REST with V4 Signing (without AWS Go SDK)

simples3 : Simple no frills AWS S3 Library using REST with V4 Signing Overview SimpleS3 is a golang library for uploading and deleting objects on S3 b

Nov 4, 2022
Integrate AWS EKS Anywhere cluster with AWS Services
 Integrate AWS EKS Anywhere cluster with AWS Services

This article provides step-by-step instruction on integrating AWS EKS Anywhere with AWS Services so the applications running on customer data center can securely connect with these services.

Mar 6, 2022
Apis para la administracion de notifiaciones, utilizando servicios como AWS SNS y AWS SQS

notificacion_api Servicio para envío de notificaciónes por difusión en AWS SNS Especificaciones Técnicas Tecnologías Implementadas y Versiones Golang

Jan 7, 2022
AWS credential_process utility to assume AWS IAM Roles with Yubikey Touch and Authenticator App TOPT MFA to provide temporary session credentials; With encrypted caching and support for automatic credential refresh.
AWS credential_process utility to assume AWS IAM Roles with Yubikey Touch and Authenticator App TOPT MFA to provide temporary session credentials; With encrypted caching and support for automatic credential refresh.

AWS credential_process utility to assume AWS IAM Roles with Yubikey Touch and Authenticator App TOPT MFA to provide temporary session credentials; With encrypted caching and support for automatic credential refresh.

Dec 20, 2022
A package for access aws service using AWS SDK for Golang

goaws ?? A package for access aws service using AWS SDK for Golang Advantage with goaws package Example for get user list IAM with AWS SDK for Golang

Nov 25, 2021
Simple CRUD API written in Go, built using AWS SAM tool and using the AWS' infrastructure.
Simple CRUD API written in Go, built using AWS SAM tool and using the AWS' infrastructure.

tutor-pet API Simple CRUD API written in Go, built using AWS SAM tool and using the AWS' infrastructure. Macro architecture: Code architecture: Pre-Re

Aug 17, 2022
Feb 7, 2022