Can we use serverless-step-functions plugin with aws-go-mod serverless framework's tempalte

59 Views Asked by At

I have initialised a serverless application using aws-go-mod template. I want to define step functions with lambda functions associated with it. If we use nodejs we can simply use the plugin serverless-step-functions to define the workflow. As I am using golang for the development of the handlers serverless-step-functions is not available. To make use of the plugin what I have done is, I have initialised a npm using npm init -y within the root directory where I have the serverless.yml file and installed the plugin using npm install --save-dev serverless-step-functions. After that I include the below line to the serverless.yml file.

plugins:
  - serverless-step-functions

Defined the step functions as below.

service: golangstepfunctions

frameworkVersion: '3'

provider:
  name: aws
  runtime: go1.x

plugins:
  - serverless-step-functions

package:
  patterns:
    - '!./**'
    - ./bin/**

functions:
  hello:
    handler: bin/hello
  world:
    handler: bin/world

stepFunctions:
  stateMachines:
    storeCheckoutFlow:
      name: storeCheckoutFlow
      definition:
        StartAt: checkInventory
        States:
          checkInventory:
            Type: Task
            Resource:
              Fn::GetAtt: [hello, Arn]
            ResultPath: '$.book'
            Next: calculateTotal
          calculateTotal:
            Type: Task
            Resource:
              Fn::GetAtt: [world, Arn]
            ResultPath: '$.check'
            End: true

When I deploy this everything is working fine. I can't understand how serverless-step-functions plugin is working within the go runtime. What I understand is irrespective of the runtime serverless-step-functions plugins simply convert the stepfunctions definitions within the serverless.yml file to Amazon State Langugae.

How all these are working ? Is this the correct way to do this ?

I've attached the screenshot of the folder structure

enter image description here

0

There are 0 best solutions below