I need to query the secret value from AWS Secrets Manager within Jenkins:
This is part of the pipeline:
sec=$(aws secretsmanager get-secret-value \
--secret-id mySecretId \
--query 'SecretString' \
--output text)
echo "${sec}"
# Result: {"username":"gwuser","password":"myPasswordValue","dbInstanceIdentifier":"mySecretId"}
How can I now extract the "myPasswordValue"?
The suggestion by @Mark B works:
#!/bin/bash
sec=$(aws secretsmanager get-secret-value \
--secret-id mySecretId \
--query 'SecretString' \
--output text | jq .password | tr -d '"')
echo "${sec}"
# Result: myPasswordValue
tr -d '"'
removes the quotes.