I am retrieving secrets I have stored in AWS secrets manager with the AWS cli like this:
aws secretsmanager get-secret-value --secret-id secrets
Which returns
arn:aws:secretsmanager<ID>:secret:my_secrets <number> my_secrets {"API_KEY":"ABCDEFGHI"} <UUID string> VERSIONSTAGES AWSCURRENT
Does anyone know how I only get the secret ("API_KEY": "ABCDEFGHI")? I need to move these secrets to my register-task-definition environment variables. The best way would be to store them in a file and delete it after us or store them in variable. It is running on a linux machine.
You can retrieve your secrets by using the console (https://console.aws.amazon.com/secretsmanager/ ) or the AWS CLI ( get-secret-value ). In applications, you can retrieve your secrets by calling GetSecretValue in any of the AWS SDKs. However, we recommend that you cache your secret values by using client-side caching.
Open the Amazon VPC console, select Endpoints, and then select Create Endpoint. Select AWS Services as the Service category, and then, in the Service Name list, select the Secrets Manager endpoint service named com. amazonaws.
Your lambda function will be able to execute all Secrets Manager actions on the secret.
Use the --query
option of the CLI to extract just the secret.
aws secretsmanager get-secret-value --secret-id secrets --query SecretString --output text
aws secretsmanager get-secret-value --secret-id secrets| jq --raw-output '.SecretString' | jq -r .API_KEY
using jq you can print.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With