# Accessing Step Function ARN dynamically in Serverless Framework

**URL:** <https://forum.serverless.com/t/accessing-step-function-arn-dynamically-in-serverless-framework/18838>\
**Category:** Serverless Framework\
**Tags:** aws, lambda, cloudformation\
**Created:** [May 6, 2023, 2:01pm UTC](https://forum.serverless.com/t/accessing-step-function-arn-dynamically-in-serverless-framework/18838 "2023-05-06T14:01:20Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Ncado](https://yyz2.discourse-cdn.com/flex036/user_avatar/forum.serverless.com/ncado/32/7454_2.png) [@Ncado](https://forum.serverless.com/u/Ncado)\
**Post date:** [May 6, 2023, 2:01pm UTC](https://forum.serverless.com/t/accessing-step-function-arn-dynamically-in-serverless-framework/18838/1 "2023-05-06T14:01:21Z")

</div>

I’m currently working on a project using the Serverless Framework, and I’m facing an issue. I have a Lambda function that needs to start a Step Function execution. However, I’m having trouble accessing the ARN of the Step Function dynamically within the Lambda function.

Here’s how I declare my step functions inside `serverless.yml` file:

```auto
stepFunctions:
  stateMachines:
    SubscriptionStateMachine:
      definition:
        StartAt: ChooseAction
        States:
          ChooseAction:
            Type: Choice
            Choices:
              - Variable: "$.changesType"
                StringEquals: "CANCEL"
                Next: CancelSubscription       
          CancelSubscription:
            Type: Task
            Resource:
              Fn::GetAtt: [cancelSubscription, Arn]
            End: true

```

And here’s the Lambda function code:

```auto
async function processMessage(message) {
  const stateMachineArn = process.env.STATE_MACHINE_ARN;

  const params = {
    stateMachineArn,
    input: JSON.stringify({
      changesType: "CANCEL", 
      ...JSON.parse(message.Body), 
    }),
  };

```
