<p>There's a good article about enabling auto-deployment everytime an image is pushed to ECR here: <a href="https://medium.com/@YadavPrakshi/automate-zero-downtime-deployment-with-amazon-ecs-and-lambda-c4e49953273d" rel="nofollow noreferrer">https://medium.com/@YadavPrakshi/automate-zero-downtime-deployment-with-amazon-ecs-and-lambda-c4e49953273d</a> </p>

<p>Check the following part out: </p>

<h1>Automate Deployment whenever Docker Image gets uploaded on ECR</h1>

<p>EC2 Container does not write logs directly to CloudWatch but CloudTrail records API activity for ECS. The flow of automation will be like this: Whenever a Upload occurs to ECR, CloudTrail records PutImage event and can write it to CloudWatch Logs. An Alarm can be triggered whenever a PutImage event is written in CloudWatch Logs which can further trigger a Lambda Function through SNS. Lambda Function Contains the code to Create Task Definition Revision and Update Service with latest Task Definition.</p>

CC BY-SA 4.0
2019-08-22T11:55:08.943Z
2019-08-22T11:55:08.943Z
Jaumzera
<p>I don't think you can trigger re-deployment based on ECS image being updated. You can however do it as part of your <em>Jenkins pipeline</em> - after you push to ECR as a <strong>next step in the pipeline</strong> can run a script that will reload the task.</p>

<p>In fact in my pipelines I deploy the <em>ECS Tasks</em> through <em>CloudFormation templates</em> and the CloudFormation stack update is part of the pipeline. That way I update the ECS Task definition automatically every time I push a new image to non-prod ECR. </p>

<p>Hope that helps :)</p>

CC BY-SA 4.0
2018-11-28T03:01:20.253Z
2018-11-28T03:01:20.253Z
MLu
<p>I'm using github, jenkins, aws ECR, aws ECS.</p>

<p>I want to deploy automatically when github have new commit. When github have new commit, github sends a event webhook to jenkins, jenkins builds the images and pushes to ECR with tag 'latest'.</p>

<p>I wonder how can I make my ECS service restart task and redeploy images automatically when the ECR image is changed?</p>

<docker><amazon-web-services><amazon-ecs>
ECS auto deploy with ECR
Yeonsuk Choi
# ECS auto deploy with ECR

(Asked by: username_0 on 2018-11-28)

I'm using github, jenkins, aws ECR, aws ECS.

I want to deploy automatically when github have new commit. When github have new commit, github sends a event webhook to jenkins, jenkins builds the images and pushes to ECR with tag 'latest'.

I wonder how can I make my ECS service restart task and redeploy images automatically when the ECR image is changed?

**Tags:** docker, amazon-web-services, amazon-ecs


---

## 2 answers

### Answer by username_2 on 2018-11-28. Score: 3 | Accepted answer

I don't think you can trigger re-deployment based on ECS image being updated. You can however do it as part of your *Jenkins pipeline* - after you push to ECR as a **next step in the pipeline** can run a script that will reload the task.

In fact in my pipelines I deploy the *ECS Tasks* through *CloudFormation templates* and the CloudFormation stack update is part of the pipeline. That way I update the ECS Task definition automatically every time I push a new image to non-prod ECR.

Hope that helps :)


---

### Answer by username_1 on 2019-08-22. Score: 1

There's a good article about enabling auto-deployment everytime an image is pushed to ECR here: <https://medium.com/@YadavPrakshi/automate-zero-downtime-deployment-with-amazon-ecs-and-lambda-c4e49953273d>

Check the following part out:

# Automate Deployment whenever Docker Image gets uploaded on ECR

EC2 Container does not write logs directly to CloudWatch but CloudTrail records API activity for ECS. The flow of automation will be like this: Whenever a Upload occurs to ECR, CloudTrail records PutImage event and can write it to CloudWatch Logs. An Alarm can be triggered whenever a PutImage event is written in CloudWatch Logs which can further trigger a Lambda Function through SNS. Lambda Function Contains the code to Create Task Definition Revision and Update Service with latest Task Definition.


---

