4

I deploy on AWS ECS a CloudFormation Stack, say teststack, via the command

aws cloudformation deploy --template-file ./CloudFormationTemplate.yml --stack-name teststack --force-upload

My stack executes a certain Docker image, say myname/myimage:latest.

I want to deploy & update the stack via a pipeline (I'm using GitLab, but I guess this is not relevant for the question of interest here).

In this setting, I may modify my Docker image without touching the CloudFormation Template file; I then build & push the new image myname/myimage:latest to my registry; finally, I trigger a new pipeline, which launches again the command aws cloudformation deploy ... --force-upload.

When executing aws cloudformation deploy ... --force-upload, the pipeline returns No changes to deploy. Stack stack-name is up to date.

Evidently, since the stack is executing the latest tagged images, it returns that everything is up to date, whitout making a pull of the new latest image.

Is there a way to force AWS CloudFormation to pull new Docker images from my registry?

1 Answer 1

3

Is using tags other than latest an option here? If so then you could tag the latest change you want to update let say myname/myimage:0-0-1 and then update the container definition in your cloudformation template to use this new tag.

If you wish to continue using the latest tag you probably cant force the deployment by a cloudformation template update. In my project when I didnt want to change the tag I ended up doing the update using AWS CLI:

aws ecs update-service --service ${ecsService}  --cluster ${ecsCluster} --region ${region} --force-new-deployment
Sign up to request clarification or add additional context in comments.

3 Comments

I hoped to be able to avoid the use of different tags than latest, since this would mean that I need to update the CloudFormation Template at each update of the stack just to change the image version. But I am thinking of a procedure that automates this procedure via some script... Thanks for the suggestion, I am going to try it.
I opted for the tag solution, since it turns out quite simple to edit the CloudFormation Template inserting an environment variable. Thanks for the hint.
I used this command but it does not do anything on the service. after running this, the service will be printed on the cli but nothing happens on the ECS side. no new revision. is it possible that the command does not show the error logs?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.