Retrieving secrets using the AWS CLI

You can retrieve secrets via the AWS CLI by using the aws secretsmanager get-secret-value command:

> aws secretsmanager get-secret-value --secret-id test/credentials
{
"ARN": "arn:aws:secretsmanager:us-east-1:385605022855:secret:test/credentials-l3JdTI",
"Name": "test/credentials",
"VersionId": "beab75bd-e9bc-4ac8-913e-aca26f6e3940",
"SecretString": "{\"MYSQL_PASSWORD\":\"some-super-password\"}",
"VersionStages": [
"AWSCURRENT"
],
"CreatedDate": 1523605423.133
}
Obtain a Secret Value Using the AWS CLI

Later on in this chapter, you will create a custom entrypoint script for the sample application container, which will use the command in the preceding example to inject secrets into the application container environment on startup.