SNS

To create a SNS reactor that subscribes via an subscription configuration, use the NewSNSReactor constructor as in:

import (
  awsLambdaEvents "github.com/aws/aws-lambda-go/events"
  spartaArchetype "github.com/mweagle/Sparta/archetype"
)
// DynamoDB reactor function
func reactorFunc(ctx context.Context,
  snsEvent awsLambdaEvents.SNSEvent) (interface{}, error) {
  logger, _ := ctx.Value(sparta.ContextKeyRequestLogger).(*logrus.Entry)

  logger.WithFields(logrus.Fields{
    "Event": snsEvent,
  }).Info("SNS Event")
  return "Hello World 👋. Welcome to AWS Lambda! 🙌🎉🍾", nil
}

func main() {
  // ...
  handler := spartaArchetype.SNSReactorFunc(reactorFunc)
  lambdaFn, lambdaFnErr := spartaArchetype.NewDynamoDBReactor(handler,
    "SNS_ARN_OR_CLOUDFORMATION_REF_VALUE",
    nil)
}