The AWS SSM Param Store can be a great way to store
and fetch
values that you may need to keep secret. Simply using the aws-cli
you can add this to a script or even just import the right package for your language.
This post will focus on just the aws-cli
.
Put
aws ssm put-parameter \
--name "staging_key" \
--type "String" \
--value "the-bees-knees"
Get
aws ssm get-parameter \
--name "staging_key"
Now the bread and butter is when you need to fetch multiple variables. The best way to do so is with hierarchy, for example, /stage/$STAGE-API-KEY
. If all your keys for a given environment have /stage/*
then you can fetch them all in one quick transaction using get-parameter-by-path
:
aws ssm get-parameters-by-path \
--path "/stage"
I wrote this quick post because of just how useful this was and somewhat hidden for me, as at the time I had not seen this similar functionality in the AWS Console.