From 761f8b56ca2f4fac09401d3a5f4573a8f41df064 Mon Sep 17 00:00:00 2001 From: paul kannan Date: Fri, 8 Dec 2023 11:28:00 +0530 Subject: [PATCH 1/2] Update snippet-data.json added go code details to json file --- integration-sns-to-lambda/snippet-data.json | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/integration-sns-to-lambda/snippet-data.json b/integration-sns-to-lambda/snippet-data.json index 9394456..90c6219 100644 --- a/integration-sns-to-lambda/snippet-data.json +++ b/integration-sns-to-lambda/snippet-data.json @@ -53,6 +53,17 @@ } ] }, + { + "id": "Go", + "title": "Usage Example with Go:", + "description": "Consuming an SNS event with Lambda using Go.", + "snippets": [ + { + "snippetPath": "example.go", + "language": "go" + } + ] + }, { "id": "Python", "title": "Usage Example with Python:", From 3c153bbba9d796efd792675feded5caab0466be0 Mon Sep 17 00:00:00 2001 From: paul kannan Date: Fri, 8 Dec 2023 11:29:27 +0530 Subject: [PATCH 2/2] Add files via upload added example.go --- integration-sns-to-lambda/example.go | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 integration-sns-to-lambda/example.go diff --git a/integration-sns-to-lambda/example.go b/integration-sns-to-lambda/example.go new file mode 100644 index 0000000..7d902e2 --- /dev/null +++ b/integration-sns-to-lambda/example.go @@ -0,0 +1,26 @@ +package main + +import ( + "context" + "fmt" + + "github.com/aws/aws-lambda-go/events" + "github.com/aws/aws-lambda-go/lambda" +) + +func handler(ctx context.Context, snsEvent events.SNSEvent) { + for _, record := range snsEvent.Records { + processMessage(record) + } + fmt.Println("done") +} + +func processMessage(record events.SNSEventRecord) { + message := record.SNS.Message + fmt.Printf("Processed message: %s\n", message) + // TODO: Process your record here +} + +func main() { + lambda.Start(handler) +}