Skip to content

Commit 4b515f5

Browse files
Aaron Mulgrewbmoffatt
Aaron Mulgrew
authored andcommitted
Update S3 Event to working Go file (#212)
* Update S3 Event to working Go file Example provided does not work without changing the script slightly... * Update README_S3.md more tabs
1 parent c970554 commit 4b515f5

File tree

1 file changed

+17
-7
lines changed

1 file changed

+17
-7
lines changed

events/README_S3.md

Lines changed: 17 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,17 +4,27 @@ The following is a sample class and Lambda function that receives Amazon S3 even
44

55
```go
66

7+
// main.go
8+
package main
9+
710
import (
8-
"fmt"
9-
"context"
10-
"github.com/aws/aws-lambda-go/events"
11+
"fmt"
12+
"context"
13+
"github.com/aws/aws-lambda-go/lambda"
14+
"github.com/aws/aws-lambda-go/events"
1115
)
1216

1317
func handler(ctx context.Context, s3Event events.S3Event) {
14-
for _, record := range s3Event.Records {
15-
s3 := record.S3
16-
fmt.Printf("[%s - %s] Bucket = %s, Key = %s \n", record.EventSource, record.EventTime, s3.Bucket.Name, s3.Object.Key)
17-
}
18+
for _, record := range s3Event.Records {
19+
s3 := record.S3
20+
fmt.Printf("[%s - %s] Bucket = %s, Key = %s \n", record.EventSource, record.EventTime, s3.Bucket.Name, s3.Object.Key)
21+
}
22+
}
23+
24+
25+
func main() {
26+
// Make the handler available for Remote Procedure Call by AWS Lambda
27+
lambda.Start(handler)
1828
}
1929

2030
```

0 commit comments

Comments
 (0)