Skip to content

Instantly share code, notes, and snippets.

@sasasin
Created October 19, 2020 10:45
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sasasin/f7d0f311b78b92d9fc408c4a5cfa76fb to your computer and use it in GitHub Desktop.
Save sasasin/f7d0f311b78b92d9fc408c4a5cfa76fb to your computer and use it in GitHub Desktop.
SecretsManagerをdotenv形式に変換するやつ
#!/bin/bash -e
# SecretsManagerから取ってきたJSONのSecretStringをバラして、dotenv形式に変換する
# https://docs.aws.amazon.com/cli/latest/reference/secretsmanager/get-secret-value.html
SECRET_ID="$1"
aws secretsmanager get-secret-value \
--secret-id "${SECRET_ID}" \
--query SecretString \
| jq -r 'fromjson | keys[] as $k | "\($k)=\"\(.[$k])\""'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment