I'm currently managing my ECS configurations with Terraform and have a setup that creates all my ECS task definitions. However, I'm facing a challenge integrating my task definitions with my code deployment process. Here's the situation: my code pipeline builds Docker images, tags them with the commit hash, and pushes them to ECR. It then creates a new task definition while only updating the image properties for the containers. The problem arises because Terraform has a static image tag in the configuration, leading to complications when I need to make changes, such as updating CPU allocations for containers. Ideally, I'd like to manage the task definitions in a more efficient way, possibly storing them in S3 as a single source of truth. What strategies can I adopt to streamline the integration between ECS task definitions and the code pipeline, while using Terraform? Thanks for the help!
1 Answer
One approach is to keep your ECS task definitions out of Terraform for deployment purposes. Let the code pipeline handle the task definitions as the single source of truth, while Terraform can be used just for infrastructure setup. This way, you avoid redundancies and simplify updates to the task definitions.

But then you'd have to hard-code some values, like database hosts, in your definitions. How do you manage such dynamic configurations?