Search code examples
node.jsamazon-web-servicesaws-lambdaserverless-frameworkaws-step-functions

How to call an AWS Step Function using the definitions in the serverless-step-functions plugin?


I'm using Serverless Framework to create my Lambda functions and the serverless-step-functions plugin to define my step functions.

Is it possible to call an step function directly from one of the lambda functions using the name defined into the serverless.yml file?


Solution

  • Solved using serverless environment variables:

    environment:
      MYFUNCTION_ARN: "arn:aws:states:${self:provider.region}:${self:provider.environment.AWS_ACCOUNT}:stateMachine:${self:service}-${self:provider.stage}-myFunction"
    

    In the function:

    var params = {
      stateMachineArn: process.env.MYFUNCTION_ARN
    };