update-secret operation for Secrets Manager replaces all keys of a secret with the new value provided in the
But sometimes we want to add a few extra keys, without replacing values already present in a secret.
In this post we show how to use bash to add keys to a secret without replacing existing values.
- jq installed
This command generates a file named
all-secrets. Run the command and update the file to reflect the list of secrets you want to add the new keys.
Keep only the the secrets you want to add the new keys in the generated
2. Store the new keys in a json file named
The script uses the
new-keys.json files created in steps 1 and 2.
For each line in the
all-secrets file, the script:#
- Gets current secret value and save to
- Updates the secret value with the
merge.jsonfile contents as the