Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

AWS CodePipeline for ECS scheduled tasks?

I know that AWS CodePipeline supports updating ECS services.

What if I want to instead update an ECS scheduled task, which does not contain a service definition?

like image 687
Fela Maslen Avatar asked Sep 03 '25 07:09

Fela Maslen


2 Answers

It turns out that CodePipeline doesn't support deploying to scheduled tasks. Instead, you have to specify a static tag (such as latest) in the task definition for the ECS scheduled task, and then make sure it always pulls the latest image by setting the image pull policy accordingly. (The default policy should work, but not guarantee that a cached image will not be run if the pull fails).

like image 161
Fela Maslen Avatar answered Sep 04 '25 21:09

Fela Maslen


Since your ECS scheduled task always uses the latest image, all you need to do in the CodePipeline is include CodeCommit and CodeBuild, then skip CodeDeploy. Your CodeBuild should include a buildspec.yml file that builds the latest image. The CodeBuild pushes the latest image to your ECR. So when you git push a commit to the repo, the pipeline triggers the CodeBuild which builds the new image, so next time your ECS scheduled task runs, it uses the new image from ECR.

like image 35
aoo Avatar answered Sep 04 '25 21:09

aoo