0

I've created a simple task to print a hello world. I've created a ECR image, docker compose and ecs-params.yml.

I get the cloudwatch log for the print, but the task keeps launching every minute, which I guess it's due to REPLICA service type.

How can I stop this from happening, I want to launch this Fargate task ONLY from a lambda, and when it finishes I don't it to be relaunched.

Thanks in advance

1 Answers1

1

If you want a one-shot / one-off / standalone task to be launched by ECS and have it run until it finishes, you wouldn't use an ECS service definition but merely a task. You can run tasks on their own without packaging as an ECS service.

See: https://docs.aws.amazon.com/AmazonECS/latest/developerguide/ecs_run_task.html

If you are using the ECS CLI, then there is also ecs-cli compose create. So, you would use that call and not the one also creating an ECS service along with it.

You can then use AWS Lambda and send an ecs:RunTask AWS API call to invoke/start the ECS task.

httpdigest
  • 5,411
  • 2
  • 14
  • 28
  • That can be it, yeah. But how can I generate the task from AWS CLI without creating the service along with it? To do it the first time i used `ecs-cli compose (...) service up`, so that it grabs docker-compose.yml + ecs-params.yml. – Marcos Pérez Fontecha Jan 27 '21 at 12:50
  • 1
    I've already created the task without any service inside the cluster, thank you! Now it's time to start the task from AWS Lambda – Marcos Pérez Fontecha Jan 27 '21 at 13:21