Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

AWS ECS FARGATE one-off task

i need for my personal project run one-off tasks on ecs (with fargate), like migration, app command etc etc.

The build and deploy pipelines are on gitlab (without job runners).

There are any possibility to run a container and die after the command execution on ecs fargate?

like image 802
Gianmarco Carrieri Avatar asked Jun 02 '20 14:06

Gianmarco Carrieri


People also ask

Can one ECS task have multiple containers?

You can use an Amazon ECS task definition to specify multiple containers. All the containers that you specify are deployed along the same compute capacity. Don't use this feature to add multiple application containers to the same task definition because this prevents copies of each application scaling separately.

What is task in ECS fargate?

Task CPU and memory Amazon ECS task definitions for AWS Fargate require that you specify CPU and memory at the task level. Although you can also specify CPU and memory at the container level for Fargate tasks, this is optional. Most use cases are satisfied by only specifying these resources at the task level.


Video Answer


1 Answers

Yes.

Fargate tasks can either run "standalone" or as part of an ECS service. The former are typically used for one-off / batch jobs, the latter are being used for long running apps (the ECS service will make sure a certain amount of tasks will always be running). See here for additional background. This isn't to say that the "standalone" mode can't execute long-running apps but simply there is no feedback loop with those and if they fail they will just stop.

For your use case you want to run one of these "standalone" tasks with a docker command that executes and exits. This will stop the task when the commands finishes. I am not how you intend to run this task but this is the CLI method to run this "one-off" task instance. The equivalent exists for the various language bindings of the AWS SDKs.

like image 194
mreferre Avatar answered Oct 26 '22 08:10

mreferre