Search code examples
amazon-web-servicesamazon-ec2amazon-ecsaws-fargate

How to trigger multiple container dynamically in AWS Fargate?


Requirement: We have n no.of client(region specific), we need to do some calculations daily on client data and we need to store the data in DynamoDB and this process should be dynamic.

Problem: We couldn't find any details on how we can trigger the multiple container dynamically using AWS Fargate which should take some input such as client ids.

We planned to use AWS Lambda + Fargate as the solution.


Solution

  • We can start containers for a task definition using AWS ECS run-task api

    • Define a task definition with container and default environment variables.
    • ECS Run Task with launchType Fargate(requires no management of EC2), can be triggered either from Lambda or from cloud watch event rule.
    • Pass in ContainerOverrides with additional attributes and environment variables when running the task with additional information for that particular run.