Passing StateMachine ARN through enviroment variable using Serverless.yml

660 Views Asked by At

While testing I am getting the following message:

 Serverless Warning --------------------------------------
 A valid service attribute to satisfy the declaration     
'self:resources.Outputs.StateMachine.Value' could not be found.

excerpts of the serverless.yml

  name: aws
  runtime: nodejs12.x
  stage: ${opt:stage, 'dev'}
  region: us-east-1 
  lambdaHashingVersion: 20201221
  versionFunctions: false
  environment:
    statemachine_arn: ${self:resources.Outputs.StateMachine.Value}

State Functions

stepFunctions:
  stateMachines:
    updateMetric:
       name: updateMetric
       definition:
         Comment: "A state machine to update data"
         StartAt: getMetric
          ........
          ........
           
              

Outputs

resources:
  - ${file(./resources/dynamodb-table.yml)}
  - Outputs:
      StateMachine:
        Value:
          Ref: UpdateMetric

All I am trying to pass the ARN of the state machine so that I can start the stateMachine from a lamda function.

It seems my reference in outputs section not working or I am not calling it properly here:

 environment:
    statemachine_arn: ${self:resources.Outputs.StateMachine.Value}
1

There are 1 best solutions below

1
Charlie Conneely On

Try capitalising the first letter of updateMetric.