Skip to content

Commit

Permalink
[479] CloudWatchEvent renamed to EventBridgeEvent (#537)
Browse files Browse the repository at this point in the history
* #479 CloudWatchEvent renamed to EventBridgeEvent

* #479 CloudWatchEvent renamed to EventBridgeEvent

* #479 code improvements after code review

* #479 small fixes after code review

* #479 small fix after code review
  • Loading branch information
mateusmarquezini committed Jan 4, 2024
1 parent f079271 commit 50dbfb1
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 9 deletions.
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

0 comments on commit 50dbfb1

Please sign in to comment.