I'm using AWS-CDK to deploy an ECS cluster, and I'd like to add secrets from the Secrets Manager. The secret is a large JSON blob with many key/value pairs. I'm including the secrets in my task definition using the following in my task definition:
secrets: {
FOO: Secret.fromSecretsManager(mySecret, 'FOO'),
BAR: Secret.fromSecretsManager(mySecret, 'BAR'),
BAZ: Secret.fromSecretsManager(mySecret, 'BAZ'),
...
}
This works fine, but I have to manually add every single secret key to this task definition, which is starting to get unwieldy.
Is it possible to dynamically inject all key/value pairs that are defined in a given secret?