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

r/aws_cloudwatch_event_api_destination: Fix crash on update #19654

Merged
merged 2 commits into from
Jun 3, 2021
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
3 changes: 3 additions & 0 deletions .changelog/19654.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
```release-note:bug
resource/aws_cloudwatch_event_api_destination: Fix crash on resource update
```
2 changes: 1 addition & 1 deletion aws/resource_aws_cloudwatch_event_api_destination.go
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand Down
11 changes: 5 additions & 6 deletions aws/resource_aws_cloudwatch_event_api_destination_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import (
"testing"

"github.com/aws/aws-sdk-go/aws"
"github.com/aws/aws-sdk-go/service/cloudwatchevents"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💯

events "github.com/aws/aws-sdk-go/service/cloudwatchevents"
"github.com/hashicorp/go-multierror"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/acctest"
Expand Down Expand Up @@ -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{
Expand Down Expand Up @@ -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{
Expand Down Expand Up @@ -207,7 +206,7 @@ func TestAccAWSCloudWatchEventApiDestination_optional(t *testing.T) {
invocationEndpointModified,
httpMethodModified,
descriptionModified,
int64(invocationRateLimitPerSecondModified),
int64(invocationRateLimitPerSecond),
),
Check: resource.ComposeTestCheckFunc(
testAccCheckCloudWatchEventApiDestinationExists(resourceName, &v3),
Expand All @@ -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)),
),
},
},
Expand All @@ -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{
Expand Down