Skip to content

When is the ECS secret is resolved?

0

When using the secrets as reference in ECS, at what point are they resolved?

  1. At task start time
  2. At container start time

I.e. imagine I have two tasks:

  1. sidecar
  2. app (depends on sidecar success, before starting)

What if the sidecar updates the secret in Secrets Manager that app needs access to.

Will app get the new secret value as the environment value, or the old one (before task had started)?

2 Answers
0

ECS resolves secrets from AWS Secrets Manager or Systems Manager Parameter Store at task start time. This means that secret values are fixed for the duration of the task's runtime and are not updated dynamically if the secrets change afterward. To apply updated secrets, tasks need to be restarted or redeployed. Proper handling of secrets involves understanding these mechanics and implementing strategies for managing updates effective

Practical Scenario with Sidecar and App Tasks .Suppose you have a sidecar container responsible for updating a secret in Secrets Manager. This sidecar task may run before or alongside the app task. The app task depends on the secret updated by the sidecar. However, if the app task is running and the sidecar updates the secret afterward, the app task will not see the updated value until it is restarted. In the container environment The app container will continue to use the value of the secret that was resolved when it initially started. The environment variable containing the secret does not dynamically update if the secret value changes while the task is running.

EXPERT

answered 2 years ago

EXPERT

reviewed 2 years ago

0

To resolve this issue and ensure the app uses the latest secret value, you'll need to restart the app container. This can be achieved by:

  1. Updating the ECS service: Force a new deployment of the service, which will cause all tasks (including the app container) to be restarted.
  2. Using a secrets management client library: The app can periodically retrieve the latest secret value from Secrets Manager using a client library. This approach provides more flexibility but requires additional code and management.
  • Secrets are resolved at container start time, not task start time.
  • Updating a secret in Secrets Manager does not automatically update its value in running containers.
  • To use the latest secret value, you must restart the container or use a secrets management client library.

https://docs.aws.amazon.com/AmazonECS/latest/developerguide/task_definition_parameters.html

EXPERT

answered 2 years ago

EXPERT

reviewed 2 years ago

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.