Skip to content

Commit

Permalink
Update S3 Event to working Go file (#212)
Browse files Browse the repository at this point in the history
* Update S3 Event to working Go file

Example provided does not work without changing the script slightly...

* Update README_S3.md

more tabs
  • Loading branch information
Aaron Mulgrew authored and bmoffatt committed Jul 2, 2019
1 parent c970554 commit 4b515f5
Showing 1 changed file with 17 additions and 7 deletions.
24 changes: 17 additions & 7 deletions events/README_S3.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,27 @@ The following is a sample class and Lambda function that receives Amazon S3 even

```go

// main.go
package main

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

func handler(ctx context.Context, s3Event events.S3Event) {
for _, record := range s3Event.Records {
s3 := record.S3
fmt.Printf("[%s - %s] Bucket = %s, Key = %s \n", record.EventSource, record.EventTime, s3.Bucket.Name, s3.Object.Key)
}
for _, record := range s3Event.Records {
s3 := record.S3
fmt.Printf("[%s - %s] Bucket = %s, Key = %s \n", record.EventSource, record.EventTime, s3.Bucket.Name, s3.Object.Key)
}
}


func main() {
// Make the handler available for Remote Procedure Call by AWS Lambda
lambda.Start(handler)
}

```

0 comments on commit 4b515f5

Please sign in to comment.