From 629605281787cf1fa396938aa908cf63bd6a8e57 Mon Sep 17 00:00:00 2001 From: Kit Ewbank Date: Thu, 3 Jun 2021 16:42:07 -0400 Subject: [PATCH 1/2] r/aws_cloudwatch_event_api_destination: Fix crash on update. --- aws/resource_aws_cloudwatch_event_api_destination.go | 2 +- ...ource_aws_cloudwatch_event_api_destination_test.go | 11 +++++------ 2 files changed, 6 insertions(+), 7 deletions(-) diff --git a/aws/resource_aws_cloudwatch_event_api_destination.go b/aws/resource_aws_cloudwatch_event_api_destination.go index 0a645db0a8d..749becf9958 100644 --- a/aws/resource_aws_cloudwatch_event_api_destination.go +++ b/aws/resource_aws_cloudwatch_event_api_destination.go @@ -148,7 +148,7 @@ func resourceAwsCloudWatchEventApiDestinationUpdate(d *schema.ResourceData, meta input.InvocationEndpoint = aws.String(invocationEndpoint.(string)) } if invocationRateLimitPerSecond, ok := d.GetOk("invocation_rate_limit_per_second"); ok { - input.InvocationRateLimitPerSecond = aws.Int64(invocationRateLimitPerSecond.(int64)) + input.InvocationRateLimitPerSecond = aws.Int64(int64(invocationRateLimitPerSecond.(int))) } if httpMethod, ok := d.GetOk("http_method"); ok { input.HttpMethod = aws.String(httpMethod.(string)) diff --git a/aws/resource_aws_cloudwatch_event_api_destination_test.go b/aws/resource_aws_cloudwatch_event_api_destination_test.go index 6ee21570cbd..2f0b4045e50 100644 --- a/aws/resource_aws_cloudwatch_event_api_destination_test.go +++ b/aws/resource_aws_cloudwatch_event_api_destination_test.go @@ -7,7 +7,6 @@ import ( "testing" "github.com/aws/aws-sdk-go/aws" - "github.com/aws/aws-sdk-go/service/cloudwatchevents" events "github.com/aws/aws-sdk-go/service/cloudwatchevents" "github.com/hashicorp/go-multierror" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/acctest" @@ -84,7 +83,7 @@ func TestAccAWSCloudWatchEventApiDestination_basic(t *testing.T) { resource.ParallelTest(t, resource.TestCase{ PreCheck: func() { testAccPreCheck(t) }, - ErrorCheck: testAccErrorCheck(t, cloudwatchevents.EndpointsID), + ErrorCheck: testAccErrorCheck(t, events.EndpointsID), Providers: testAccProviders, CheckDestroy: testAccCheckAWSCloudWatchEventApiDestinationDestroy, Steps: []resource.TestStep{ @@ -157,7 +156,7 @@ func TestAccAWSCloudWatchEventApiDestination_optional(t *testing.T) { resource.ParallelTest(t, resource.TestCase{ PreCheck: func() { testAccPreCheck(t) }, - ErrorCheck: testAccErrorCheck(t, cloudwatchevents.EndpointsID), + ErrorCheck: testAccErrorCheck(t, events.EndpointsID), Providers: testAccProviders, CheckDestroy: testAccCheckAWSCloudWatchEventApiDestinationDestroy, Steps: []resource.TestStep{ @@ -207,7 +206,7 @@ func TestAccAWSCloudWatchEventApiDestination_optional(t *testing.T) { invocationEndpointModified, httpMethodModified, descriptionModified, - int64(invocationRateLimitPerSecondModified), + int64(invocationRateLimitPerSecond), ), Check: resource.ComposeTestCheckFunc( testAccCheckCloudWatchEventApiDestinationExists(resourceName, &v3), @@ -216,7 +215,7 @@ func TestAccAWSCloudWatchEventApiDestination_optional(t *testing.T) { resource.TestCheckResourceAttr(resourceName, "http_method", httpMethodModified), resource.TestCheckResourceAttr(resourceName, "invocation_endpoint", invocationEndpointModified), resource.TestCheckResourceAttr(resourceName, "description", descriptionModified), - resource.TestCheckResourceAttr(resourceName, "invocation_rate_limit_per_second", fmt.Sprint(invocationRateLimitPerSecondModified)), + resource.TestCheckResourceAttr(resourceName, "invocation_rate_limit_per_second", fmt.Sprint(invocationRateLimitPerSecond)), ), }, }, @@ -233,7 +232,7 @@ func TestAccAWSCloudWatchEventApiDestination_disappears(t *testing.T) { resource.ParallelTest(t, resource.TestCase{ PreCheck: func() { testAccPreCheck(t) }, - ErrorCheck: testAccErrorCheck(t, cloudwatchevents.EndpointsID), + ErrorCheck: testAccErrorCheck(t, events.EndpointsID), Providers: testAccProviders, CheckDestroy: testAccCheckAWSCloudWatchEventApiDestinationDestroy, Steps: []resource.TestStep{ From 550aac9b869c91e8968d4c787b0d389580454609 Mon Sep 17 00:00:00 2001 From: Kit Ewbank Date: Thu, 3 Jun 2021 16:46:45 -0400 Subject: [PATCH 2/2] Add CHANGELOG entry. --- .changelog/19654.txt | 3 +++ 1 file changed, 3 insertions(+) create mode 100644 .changelog/19654.txt diff --git a/.changelog/19654.txt b/.changelog/19654.txt new file mode 100644 index 00000000000..3e8303887fb --- /dev/null +++ b/.changelog/19654.txt @@ -0,0 +1,3 @@ +```release-note:bug +resource/aws_cloudwatch_event_api_destination: Fix crash on resource update +``` \ No newline at end of file