Search code examples
javaspringamazon-web-servicesspring-bootamazon-ecs

Spring Boot in AWS ECS: Application Configuration Updates


Let's say I have a Spring Boot application running in AWS ECS. Let's further suppose that Spring Cloud Config Server is overkill, and we set all application properties via environment variables loaded via the current task definition.

E.g. in application.yml:

db:
  url: ${DB_URL}

Let's also assume that the task definition pulls the necessary config values from AWS Parameter Store.

If I update the corresponding DB_URL value in AWS Parameter store, is there any reasonable way for the Spring application to see this value short of starting up a new container?

My hunch would be that, with the container already built, the values specified by the task definition were baked in to the container once it was created.

(I realize even if the updated value was visible that there's still the matter of properly updating the affected resource(s).)

Another thought might be to use AWS Secrets Manager as it seems to have the client-side caching library (https://github.com/aws/aws-secretsmanager-caching-java), but then all configuration values would have to be stored there instead of AWS Parameter Store.

I'm pretty sure I know the answer, but I wanted to make sure I'm not missing anything: Is there any other way to accomplish what's being asked besides the above? Or is the creation of a new container the only way (unless I want to switch to using, say, Spring Cloud Config Server)?

Thank you in advance!


Solution

  • Recreating the container is the only way to update the environment variables. This generally isn't an issue as ECS will spin up the new container, and start sending traffic to the new container, draining connections from the old container, so your application won't be down during this process.