Hey all,
My goal is simple. Commit a change to the application and have it running live on AWS.
I have built all my infra with Terraform, so I want to only use Terraform to make changes to AWS. The question is, how do I update my ECS Service and keep it in sync with Terraform. The solution I came up with, not sure if I’m reinventing the wheel here, is the following:
- Use
circleci/aws-ecr
to push the newly built image to ECR. - use
circleci/aws-ecs
->update-task-definition-from-json
to update thetask-definition.json
- Since I have an updated
task-definition.json
in the Terraform dir holding the newly built image, it’s only a matter of aterraform apply
. I have set it with backend so it should be possible to run it from circleci withcircleci/terraform
. - I should have the latest container up and running, so the first goal is achieved.
- Now, I need to have it in sync. Circleci made changes to the
task-definition.json
and also at the terraform state. I can give an access key to my github account for the ci to commit the changes.
Is there an easier way to do this?