Skip to content

Instantly share code, notes, and snippets.

@inhumantsar
Created May 23, 2022 19:11
Show Gist options
  • Save inhumantsar/732dd79d377ee33edd7745fd360237f9 to your computer and use it in GitHub Desktop.
Save inhumantsar/732dd79d377ee33edd7745fd360237f9 to your computer and use it in GitHub Desktop.
Rename a bunch of AWS Secrets Manager secrets
for secret in `aws secretsmanager list-secrets | jq -r '.SecretList[] | select(.Name | test("old-middle")) | .Name'`; do
prefix=$(echo $secret | cut -d/ -f1)
suffix=$(echo $secret | cut -d/ -f3)
content="$(aws secretsmanager get-secret-value --secret $secret | jq -r .SecretString)"
aws secretsmanager create-secret --name $prefix/new-middle/$suffix --secret-string "${content}"
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment