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

events: Add working example for CloudWatch Events #375

Merged
merged 4 commits into from
Sep 18, 2021
Merged
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
21 changes: 21 additions & 0 deletions events/README_CloudWatch_Events.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,24 @@ func handler(ctx context.Context, event events.CloudWatchEvent) {
fmt.Printf("Detail = %s\n", event.Detail)
}
```

## CloudWatch Scheduled Events

If you have a constant JSON text in a CloudWatch Scheduled Event, it can be accessed either by explicitly defining a structure for the json payload you would expect:

```go
type MyRequest struct {
Name string `json:"name"`
}

func handler(ctx context.Context, req MyRequest) {
}
```

or by accepting raw json blob as is:

```go
func handler(ctx context.Context, b json.RawMessage) {
// json.RawMessage is basically []byte which can be unmarshalled
}
```