nzoschke / gofaas

A boilerplate Go and AWS Lambda app. Demonstrates an expert configuration of 10+ AWS services to support running Go functions-as-a-service (FaaS).
Apache License 2.0
801 stars 43 forks source link

SQS #64

Open nzoschke opened 6 years ago

nzoschke commented 6 years ago

SQS is an event source worth demoing and documenting

StevenACoffman commented 6 years ago
Resources:
Sample Function

The following is a sample class and Lambda function that receives Amazon SQS event message data as input, writes some of the message data to CloudWatch Logs, and responds with a 200 status and the same body as the request. (Note that by default anything written to Console will be logged as CloudWatch Logs events.)

package main

import (
    "context"
    "fmt"

    "github.com/aws/aws-lambda-go/events"
    "github.com/aws/aws-lambda-go/lambda"
)

func handler(ctx context.Context, sqsEvent events.SQSEvent) error {
    for _, message := range sqsEvent.Records {
        fmt.Printf("The message %s for event source %s = %s \n", message.MessageId, message.EventSource, message.Body)
    }

    return nil
}

func main() {
    lambda.Start(handler)
}
StevenACoffman commented 6 years ago

While I know that the following resources are not golang or SAM, this might be a useful template for what to cover in this repo on SQS and Lambda:

Topics Covered: