Home > Back-end >  How does AWS Step Functions invoke Lambdas?
How does AWS Step Functions invoke Lambdas?

Time:09-15

From an architecture point of view, when an AWS Step Functions invoke a Lambda, does it go through API Gateway or does the invocation happen directly?

CodePudding user response:

The AWS Step Functions service directly invokes Lambda functions - there is no need for the Step Function service to go via another AWS service to invoke a Lambda.

You can see the lambda:InvokeFunction IAM permission needed by the service, in the AWS Lambda IAM policy template within the Step Function docs. There is no permission required for the API gateway.

You also wouldn't have the option to specify the InvocationType if it went via the API Gateway.

CodePudding user response:

To add to the above answer, when you create an Amazon States Language document, you can reference the ARN of the Lambda function. That is how AWS Step Functions invoke an AWS Lambda function. For example:

 {
        "Comment": "A simple AWS Step Functions state machine that automates a call center support session.",
        "StartAt": "Open Case",
        "States": {
        "Open Case": {
        "Type": "Task",
        **"Resource": "arn:aws:lambda:REGION:ACCOUNT_ID:function:FUNCTION_NAME",**
        "Next": "Assign Case"
          },
         "Assign Case": {
         "Type": "Task",
         "Resource": "arn:aws:lambda:REGION:ACCOUNT_ID:function:FUNCTION_NAME",
         "Next": "Send Email"
         },
         "Send Email": {
         "Type": "Task",
         "Resource": "arn:aws:lambda:REGION:ACCOUNT_ID:function:FUNCTION_NAME",
         "End": true
          }
          }
  • Related