Created
May 23, 2022 19:11
-
-
Save inhumantsar/732dd79d377ee33edd7745fd360237f9 to your computer and use it in GitHub Desktop.
Rename a bunch of AWS Secrets Manager secrets
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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