Reputation: 386
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?
Upvotes: 2
Views: 1089
Reputation: 11531
CDK doesn't know what fields your secret has, and the task definition has to have each secret specified explicitly.
So your only solution, besides modifying the structure of the Secret (sounds like you could do with multiple secrets), would be to pass the whole JSON string to the container and have it parse it out.
Upvotes: 2