Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can a lambda in an AWS Step Function know the name of the step it is in?

For a lambda executed within a step function, I kind of expected that I could get the name of the current step from the lambda context, but it doesn't seem to be that simple.

Is there any way to get the name of the current step in a lambda that is executed within a Step Function?

like image 364
Free Willaert Avatar asked May 11 '17 23:05

Free Willaert


People also ask

Can a Lambda call a step function?

Services that you can configure to invoke Step Functions include: AWS Lambda, using the StartExecution call. Amazon API Gateway.

What is difference between STEP function and Lambda?

Step Functions is a serverless orchestration service that lets you easily coordinate multiple Lambda functions into flexible workflows that are easy to debug and easy to change. Step Functions will keep your Lambda functions free of additional logic by triggering and tracking each step of your application for you.

Can AWS step function call another step function?

IAM Policy for the Main Workflow Role Recently, AWS Step function added a functionality to call one step function from another step function. It works like calling any other service ( AWS Glue, AWS Lambda, AWS Sagemaker , AWS Batch ). It does support both Sync and aysnc.


2 Answers

Based on the documentation, I was using Parameters and $$ to pass the step function context object into my lambda function. To test and see if it was working, I thought I could go to the step function console, start a new execution and see the context object being passed into the step function on the "Step Input" tab. To my dismay, it wasn't displayed there. I added some diagnostic logging to the lambda function serializing the input to JSON and logging out to CloudWatch. Cloudwatch logs showed that the context object was being passed in.

Anyway, thought I would post this here to maybe help someone avoid the time I spent trying to figure this one out. It gets passed in, just doesn't show up in the step function console.

like image 161
Daryl Avatar answered Sep 21 '22 12:09

Daryl


AWS Step Functions released Context Object where you can access information about your execution.

You can use it to send the execution arn to your lambda.

https://docs.aws.amazon.com/step-functions/latest/dg/input-output-contextobject.html

like image 26
diegosantiviago Avatar answered Sep 18 '22 12:09

diegosantiviago