Skip to content
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

Add CloudWatch README #242

Merged
merged 4 commits into from
Oct 23, 2019
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
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)
}
}
```