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
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:
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.
Easiest to pass in ‘dynamic’ values into the task is to create an
overrides
dict/object and pass that into therun_task
API call.It is mentioned here for example.