从SNS接收到的JSON转发到Lambda-GoLang

I am trying to achieve the following: Cloudwatch alarm details are received as JSON to a Lambda The Lambda looks at the JSON to determine if the 'NewStateValue' == "ALARM" If it does == "ALARM" forward the whole JSON received from the SNS out via another SNS.

I am most of the way towards achieving this and I have the following code:

package main

import (
    "context"
    "fmt"
    "encoding/json"

    "github.com/aws/aws-lambda-go/events"
    "github.com/aws/aws-lambda-go/lambda"
    "github.com/aws/aws-sdk-go/aws"
    "github.com/aws/aws-sdk-go/aws/session"
    "github.com/aws/aws-sdk-go/service/sns"
)

func handler(ctx context.Context, snsEvent events.SNSEvent) {
    for _, record := range snsEvent.Records {
        snsRecord := record.SNS

//To add in additional fields to publish to the logs add "snsRecord.'fieldname'"
        fmt.Printf("Message = %s 
", snsRecord.Message) 
        var event CloudWatchAlarm
        err := json.Unmarshal([]byte(snsRecord.Message), &event)
        if err != nil {
            fmt.Println("There is an error: " + err.Error())
        }
        fmt.Printf("Test Message = %s 
", event.NewStateValue)
        if ( event.NewStateValue == "ALARM") {
            svc := sns.New(session.New())
  // params will be sent to the publish call included here is the bare minimum params to send a message.
    params := &sns.PublishInput{
        Message: Message: aws.String("message"), // This is the message itself (can be XML / JSON / Text - anything you want)
        TopicArn: aws.String("my arn"),  //Get this from the Topic in the AWS console.
    }

    resp, err := svc.Publish(params)   //Call to puclish the message

    if err != nil {                    //Check for errors
        // Print the error, cast err to awserr.Error to get the Code and
        // Message from an error.
        fmt.Println(err.Error())
        return
    }

    // Pretty-print the response data.
    fmt.Println(resp)
}
        }
    }


func main() {
    lambda.Start(handler)
}

Currently this sends an email to the address set-up in the SNS linked to the ARN above. However I would like the email to include the full, ideally formatted, JSON received by the first SNS. I have the Cloudwatch JSON structure defined in another file, this is being called by var event CloudWatchAlarm

Any pointers would be great!

Thanks!

From AWS SDK for Go docs:

type PublishInput struct {
// The message you want to send.
//
// If you are publishing to a topic and you want to send the same message to
// all transport protocols, include the text of the message as a String value.
// If you want to send different messages for each transport protocol, set the
// value of the MessageStructure parameter to json and use a JSON object for
// the Message parameter.

So, params would be:

params := &sns.PublishInput{
        Message: myjson, // json data you want to send
        TopicArn: aws.String("my arn"),
        MessageStructure: aws.String("json")
    }

WARNING

Notice the help paragraph says "use a JSON object for the parameter message", such JSON object must have a keys that correspond to supported transport protocol That means

{
  'default': json_message,
  'email': json_message
}

It will send json_message using both the default and email transports.