I am working on a project where it is required to create multiple instance of container dynamically based on the count received from the AWS Lambda function. Each container will execute its own task. I have done a lot of research but still not sure how to achieve this. Also how to delete the container instance when the task execution is completed?
Asked
Active
Viewed 700 times
1 Answers
1
You're describing the use case AWS Batch has been built for. It essentially allows you to submit tasks that are being processed in Docker Containers and manages the lifecycle of those containers for you. Since pre:invent 2020 it also supports Fargate.
An alternative would be using a Step Function that processes the output of the Lambda function and dynamically creates ECS tasks for that. Tasks without a service, so they just terminate when they're done processing. Depending on the amount of jobs you have I'd prefer AWS Batch.

Maurice
- 11,482
- 2
- 25
- 45
-
Will i be able to pass the data to containers if i will go with the alternative solution which you have mentioned? – jeevan_23 Feb 24 '21 at 13:43
-
Yes, you can do that - have a look a [this blog post](https://aws.amazon.com/blogs/compute/creating-a-simple-fetch-and-run-aws-batch-job/) for an example. – Maurice Feb 24 '21 at 14:06