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

[479] CloudWatchEvent renamed to EventBridgeEvent #537

Merged
merged 6 commits into from
Jan 4, 2024
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
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@

# 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.
The following is a Lambda function that receives Amazon EventBridge 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 (
Expand All @@ -11,7 +11,7 @@ import (
"github.com/aws/aws-lambda-go/events"
)

func handler(ctx context.Context, event events.CloudWatchEvent) {
func handler(ctx context.Context, event events.EventBridgeEvent) {
fmt.Printf("Detail = %s\n", event.Detail)
}
```
Expand Down
5 changes: 3 additions & 2 deletions events/cloudwatch_events.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,7 @@ import (
"time"
)

// CloudWatchEvent is the outer structure of an event sent via CloudWatch Events.
// For examples of events that come via CloudWatch Events, see https://docs.aws.amazon.com/AmazonCloudWatch/latest/events/EventTypes.html
// CloudWatchEvent is the outer structure of an event sent via EventBridge serverless service.
type CloudWatchEvent struct {
Version string `json:"version"`
ID string `json:"id"`
Expand All @@ -18,3 +17,5 @@ type CloudWatchEvent struct {
Resources []string `json:"resources"`
Detail json.RawMessage `json:"detail"`
}

type EventBridgeEvent = CloudWatchEvent
2 changes: 0 additions & 2 deletions events/codedeploy.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,6 @@ const (
CodeDeployDeploymentStateSuccess CodeDeployDeploymentState = "SUCCESS"
)

// CodeDeployEvent is documented at:
// https://docs.aws.amazon.com/AmazonCloudWatch/latest/events/EventTypes.html#acd_event_types
type CodeDeployEvent struct {
// AccountID is the id of the AWS account from which the event originated.
AccountID string `json:"account"`
Expand Down
4 changes: 2 additions & 2 deletions events/codepipeline_cloudwatch.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,6 @@ const (
CodePipelineActionStateCanceled CodePipelineActionState = "CANCELED"
)

// CodePipelineEvent is documented at:
// https://docs.aws.amazon.com/AmazonCloudWatch/latest/events/EventTypes.html#codepipeline_event_type
type CodePipelineCloudWatchEvent struct {
// Version is the version of the event's schema.
Version string `json:"version"`
Expand Down Expand Up @@ -76,6 +74,8 @@ type CodePipelineCloudWatchEvent struct {
Detail CodePipelineEventDetail `json:"detail"`
}

type CodePipelineEventBridgeEvent = CodePipelineCloudWatchEvent

type CodePipelineEventDetail struct {
Pipeline string `json:"pipeline"`

Expand Down
3 changes: 2 additions & 1 deletion events/codepipeline_cloudwatch_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,11 @@ package events

import (
"encoding/json"
"github.com/stretchr/testify/require"
"io/ioutil" //nolint: staticcheck
"testing"
"time"

"github.com/stretchr/testify/require"
)

func TestUnmarshalCodePipelineEvent(t *testing.T) {
Expand Down