Member-only story
Secrets such as environment variables are a must when working with applications using tools such as the CDK. When generating our CloudFormation templates, the last thing you want is to have environment variables leaking through your Git history.
This short overview will create/retrieve a secret from the AWS Secrets Manager and show how you can then require it within a CDK stack.
The secrets manager from the CLI
Ensure that you have the aws-cli installed.
We’re going to add values for example/secretKey
and example/secretToken
. For us to reference later in the example CDK usage.
Creating our first example of two secrets:
The response from each will give you an ARN value — make sure you note these down.
If you do not note it down, you can always re-fetch the secret using describe-secret
from the CLI: