Search code examples
amazon-web-servicesserverless-frameworkaws-step-functionsserverless-framework-step-functions

Accessing input to step function to then use as message for SNS


I'm using the serverless framework to build a step function which receives input and then uses this input to send a message via SNS.

How do I pass the input to the message field?

Here is my definition and attempt:

stepFunctions:
  stateMachines:
    hellostepfunc1:
      name: testermachine
      definition:
        Comment: "test machine"
        StartAt: SNSState
        States:
          SNSState:
            Type: Task
            InputPath: $
            Resource: arn:aws:states:::sns:publish
            Parameters:
              TopicArn:
                Fn::GetAtt: [ MyTopic, TopicArn ]
              Message: {InputPath: $}
            End: true

Solution

  • You can perform a SNS publish operation within a Step Function. See AWS Docs - Connect to SNS from Step Functions