Skip to content

Instantly share code, notes, and snippets.

@mdp
Created January 8, 2018 21:33
Show Gist options
  • Save mdp/723d04cf211ca3a4e3d707e2c6393d56 to your computer and use it in GitHub Desktop.
Save mdp/723d04cf211ca3a4e3d707e2c6393d56 to your computer and use it in GitHub Desktop.
.env to SSM
#!/bin/bash
# Usage: ./env-to-ssm.sh prefix envfile
# Ex: ./env-to-ssm.sh prod.app .env
AWS_SSM_PREFIX=$1
ENV_FILE=$2
cat aws/.env | grep -v ^# | grep -v -e '^$' | while read line
do
IFS='=' read -r key val <<< "$line"
echo "Setting $AWS_SSM_PREFIX.$key: $val"
aws ssm put-parameter --overwrite --cli-input-json '{
"Name": "'"$AWS_SSM_PREFIX.$key"'",
"Value": "'"$(echo $val | sed -e 's/^"//' -e 's/"$//')"'",
"Type": "SecureString"
}'
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment