Skip to content

Commit

Permalink
Add CloudWatch README (#242)
Browse files Browse the repository at this point in the history
* Add CloudWatch README

* Update README_CloudWatch_Events.md

* Update README_CloudWatch_Logs.md
  • Loading branch information
Tensho authored and bmoffatt committed Oct 23, 2019
1 parent 476be7d commit b5b7267
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 0 deletions.
4 changes: 4 additions & 0 deletions events/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,10 @@ This package provides input types for Lambda functions that process AWS events.

[CloudFormation Events](../cfn/README.md)

[CloudWatch Events](README_CloudWatch_Events.md)

[CloudWatch Logs](README_CloudWatch_Logs.md)

[Chime Bot Events](README_Chime_Bots.md)

[Code Commit Events](README_CodeCommit.md)
Expand Down
17 changes: 17 additions & 0 deletions events/README_CloudWatch_Events.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@

# Sample Function

The following is a Lambda function that receives Amazon CloudWatch event record data as input and writes event detail to Lambda's CloudWatch Logs. Note that by default anything written to Console will be logged as CloudWatch Logs events.

```go
import (
"context"
"fmt"

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

func handler(ctx context.Context, event events.CloudWatchEvent) {
fmt.Printf("Detail = %s\n", event.Detail)
}
```
20 changes: 20 additions & 0 deletions events/README_CloudWatch_Logs.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@

# Sample Function

The following is a Lambda function that receives Amazon CloudWatch Logs event record data as input and writes message part to Lambda's CloudWatch Logs. Note that by default anything written to Console will be logged as CloudWatch Logs events.

```go
import (
"context"
"fmt"

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

func handler(ctx context.Context, logsEvent events.CloudwatchLogsEvent) {
data, _ := logsEvent.AWSLogs.Parse()
for _, logEvent := range data.LogEvents {
fmt.Printf("Message = %s\n", logEvent.Message)
}
}
```

0 comments on commit b5b7267

Please sign in to comment.