skip to Main Content

I have one lambda function which is calling ECS task. Now i want to pass the values of Lambda as input to ECS task and the ECS task’s result should return to Lambda.

I have tried to run ECS task in lambda using run_task() Method. It returns only the information about the ECS task but not the result(Output) of ECS task and i am not able to pass the values as input to ECS tasks.

Any working example on how to properly pass and return data in ECS task?

2

Answers


  1. ECS Tasks are not API calls or functions which you can pass values to and expect a return values from. Run Task simply means to spin up a "container". If that container was up successfully depends on so many factors like:

    • Is the referenced Docker image (in Task Definition) available
    • Does the task have enough permissions
    • Was the networking setup properly
    • Primary container in the task is working fine and passing health checks
    • and tons more!

    So if you want your container to read a value dynamically. You can set that value from your lambda to SSM Parameter Store. And then your application running in ECS can read from Parameter Store.

    Lambda -> save value in Parameter Store -> Run Task
    ECS Task -> Read value from Parameter Store
    
    Login or Signup to reply.
  2. Easiest to pass in ‘dynamic’ values into the task is to create an overrides dict/object and pass that into the run_task API call.

    It is mentioned here for example.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search