From 50dbfb12d5bfc88c681a4b8d4fbea871f0b449e6 Mon Sep 17 00:00:00 2001 From: Mateus Marquezini Date: Thu, 4 Jan 2024 20:26:54 -0300 Subject: [PATCH] [479] CloudWatchEvent renamed to EventBridgeEvent (#537) * #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 --- ...DME_CloudWatch_Events.md => README_EventBridge_Events.md} | 4 ++-- events/cloudwatch_events.go | 5 +++-- events/codedeploy.go | 2 -- events/codepipeline_cloudwatch.go | 4 ++-- events/codepipeline_cloudwatch_test.go | 3 ++- 5 files changed, 9 insertions(+), 9 deletions(-) rename events/{README_CloudWatch_Events.md => README_EventBridge_Events.md} (67%) diff --git a/events/README_CloudWatch_Events.md b/events/README_EventBridge_Events.md similarity index 67% rename from events/README_CloudWatch_Events.md rename to events/README_EventBridge_Events.md index b1d16dc7..52ea90c2 100644 --- a/events/README_CloudWatch_Events.md +++ b/events/README_EventBridge_Events.md @@ -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 ( @@ -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) } ``` diff --git a/events/cloudwatch_events.go b/events/cloudwatch_events.go index e3201fdb..0b109ba3 100644 --- a/events/cloudwatch_events.go +++ b/events/cloudwatch_events.go @@ -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"` @@ -18,3 +17,5 @@ type CloudWatchEvent struct { Resources []string `json:"resources"` Detail json.RawMessage `json:"detail"` } + +type EventBridgeEvent = CloudWatchEvent diff --git a/events/codedeploy.go b/events/codedeploy.go index e54eeded..af239bbf 100644 --- a/events/codedeploy.go +++ b/events/codedeploy.go @@ -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"` diff --git a/events/codepipeline_cloudwatch.go b/events/codepipeline_cloudwatch.go index 0beea862..41340c4e 100644 --- a/events/codepipeline_cloudwatch.go +++ b/events/codepipeline_cloudwatch.go @@ -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"` @@ -76,6 +74,8 @@ type CodePipelineCloudWatchEvent struct { Detail CodePipelineEventDetail `json:"detail"` } +type CodePipelineEventBridgeEvent = CodePipelineCloudWatchEvent + type CodePipelineEventDetail struct { Pipeline string `json:"pipeline"` diff --git a/events/codepipeline_cloudwatch_test.go b/events/codepipeline_cloudwatch_test.go index e1e21748..13321980 100644 --- a/events/codepipeline_cloudwatch_test.go +++ b/events/codepipeline_cloudwatch_test.go @@ -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) {