diff --git a/events/README_CloudWatch_Events.md b/events/README_CloudWatch_Events.md index 2c6bb53b..b1d16dc7 100644 --- a/events/README_CloudWatch_Events.md +++ b/events/README_CloudWatch_Events.md @@ -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 +} +```