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?
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.
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.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With