codetheweb / serverless-step-functions-local

Run AWS step functions offline with Serverless
MIT License
17 stars 17 forks source link

feat: Use new serverless resolver #9

Closed danielpoonwj closed 3 years ago

danielpoonwj commented 3 years ago

Purpose

Allow variable resolution in the step functions config, following this approach: https://github.com/serverless-operations/serverless-step-functions/pull/451.

This allows for variables to be properly resolved instead of appearing as strings as-is. Resource variables can currently be replaced through TaskResourceMapping, but other essential fields like QueueUrl for sqs:sendMessage resources need to be supported. Instead of overloading TaskResourceMapping with custom syntax, allow variable resolution to give users full flexibility to configure however they want.

TaskResourceMapping is still handy, but can consider deprecating it in the future since the functionality is now possible through variables, and there'll be one less thing to maintain.

The example below (and in the README) shows how to reference an arbitrary custom variable.

custom:
  ...
  sqsUrl: http://localhost:4566/101010101010/example-queue

stepFunctions:
  stateMachines:
    WaitMachine:
      definition:
        StartAt: send_message
        States:
          send_message:
            Type: Task
            Resource: arn:aws:states:::sqs:sendMessage
            Parameters:
              QueueUrl: ${self:custom.sqsUrl}
              "MessageBody.$": "$"
            End: true

Notes

codetheweb commented 3 years ago

Sounds good to me, thanks.

(You seem to know your way around Serverless / AWS while I haven't used this in a few years, would be happy to transfer ownership to you if you want.)

codetheweb commented 3 years ago

Published in v0.2.0