Search code examples
amazon-web-servicesamazon-ecsaws-codepipeline

AWS CodePipeline: how to find out if deployment stage's ECS Fargate task is finished executing proccesses in containers?


I have a AWS CodePipeline with two deployment stages:

  1. Deployment to ECS Fargate task (test environment).
  2. Deployment to ECS Fargate task (actual environment).

First deployment stage (test one) has container with entry point which executes tests.

My problem is that I'd like to proceed to second deployment stage only if first (test) fargate task has finished all proccesses in containers and stopped them.

So far I've tried moving first ECS Fargate task's launch to buildspec.yml with command 'aws ecs run-task', which gets up, does the job and then kills itself, which is behaviour that is needed. However I'd like to stop whole pipeline until tests are not finished.enter image description here


Solution

  • This article says you can deploy your containers on the build machine itself using docker-compose as a prebuild action, then in build action run the test runner command (npm test). This should fail the deploy test stage if the tests fail and pass if the tests pass and then let the pipeline continue.