Skip to content

Added go handler for sns to lambda #102

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Dec 13, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 26 additions & 0 deletions integration-sns-to-lambda/example.go
Original file line number Diff line number Diff line change
@@ -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)
}
11 changes: 11 additions & 0 deletions integration-sns-to-lambda/snippet-data.json
Original file line number Diff line number Diff line change
Expand Up @@ -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:",
Expand Down