profile
viewpoint

Ask questionsDoes this project work with SNS destinations?

I have been struggling with a Golang lambda all day (which works great, until....) and I can't quite get it work with publishing to an SNS Topic via the Destination feature.

My handler looks akin to:

func handler(ctx context.Context, sqsEvent events.SQSEvent) (Response, error) {

Response is a struct with four strings on it, marked for how I want them to be serialized (all of the properties start with an upper case letter, so they are public)

If I execute the Lamba, I can see a response, which is proper JSON that I expect (so it looks like it serializes fine).

The SNS topic I have setup has SNS:Publish given to the role executing the lambda, and the lambda has SNS:publish to the topic's ARN.

A coworker and I were able to get a node.js test lambda to publish to the SNS topic, so we are scratching our heads at this one.

I'm using 1.16.0 of this library, Golang 1.14.2, Mac OS X 10.15.4, building with GOOS=linux and my code (minus the actual code I wrote) looks more or less like this:

package main

import (
        "fmt"
        "context"
        "github.com/aws/aws-lambda-go/lambda"
        "github.com/aws/aws-lambda-go/events"
)

type Response struct {
        Name string `json:"name"`
}

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

func handler(ctx context.Context, sqsEvent events.SQSEvent) (Response, error) {
        response := Response{Name: "name"}
        return response, nil
}
aws/aws-lambda-go

Answer questions mhart

Right, I believe that's the issue here. Kinesis, SQS and DynamoDB Streams all use synchronous invokes.

https://aws.amazon.com/blogs/architecture/understanding-the-different-ways-to-invoke-lambda-functions/

useful!

Related questions

json: cannot unmarshal object into Go struct field APIGatewayProxyRequest.body of type string on GET request hot 1
API Gateway Proxy: headers are case sensitive hot 1
json: cannot unmarshal string into Go struct field APIGatewayProxyRequestContext.authorizer hot 1
json: cannot unmarshal object into Go struct field APIGatewayProxyRequest.body of type string on GET request hot 1
Github User Rank List