From fb6243152f069448cda496011185ab8d96403775 Mon Sep 17 00:00:00 2001 From: Angie Pinilla Date: Fri, 6 Aug 2021 15:51:23 -0400 Subject: [PATCH] add CHANGELOG and test coverage --- .changelog/16471.txt | 3 +++ aws/resource_aws_iot_topic_rule.go | 2 +- aws/resource_aws_iot_topic_rule_test.go | 35 +++++++++++++++++++++++++ 3 files changed, 39 insertions(+), 1 deletion(-) create mode 100644 .changelog/16471.txt diff --git a/.changelog/16471.txt b/.changelog/16471.txt new file mode 100644 index 000000000000..9ff7f7d1626a --- /dev/null +++ b/.changelog/16471.txt @@ -0,0 +1,3 @@ +```release-note:bug +resource/aws_iot_topic_rule: Correctly update resource on `error_action` change +``` \ No newline at end of file diff --git a/aws/resource_aws_iot_topic_rule.go b/aws/resource_aws_iot_topic_rule.go index 1b74a5440dd3..043811a32877 100644 --- a/aws/resource_aws_iot_topic_rule.go +++ b/aws/resource_aws_iot_topic_rule.go @@ -1222,6 +1222,7 @@ func resourceAwsIotTopicRuleUpdate(d *schema.ResourceData, meta interface{}) err "dynamodbv2", "elasticsearch", "enabled", + "error_action", "firehose", "iot_analytics", "iot_events", @@ -1234,7 +1235,6 @@ func resourceAwsIotTopicRuleUpdate(d *schema.ResourceData, meta interface{}) err "sql", "sql_version", "sqs", - "error_action", ) { input := &iot.ReplaceTopicRuleInput{ RuleName: aws.String(d.Get("name").(string)), diff --git a/aws/resource_aws_iot_topic_rule_test.go b/aws/resource_aws_iot_topic_rule_test.go index 49a1bd2a79b6..787b08b5bad6 100644 --- a/aws/resource_aws_iot_topic_rule_test.go +++ b/aws/resource_aws_iot_topic_rule_test.go @@ -586,6 +586,41 @@ func TestAccAWSIoTTopicRule_errorAction(t *testing.T) { }) } +// Reference: https://github.com/hashicorp/terraform-provider-aws/issues/16115 +func TestAccAWSIoTTopicRule_updateKinesisErrorAction(t *testing.T) { + rName := acctest.RandString(5) + resourceName := "aws_iot_topic_rule.rule" + + resource.ParallelTest(t, resource.TestCase{ + PreCheck: func() { testAccPreCheck(t) }, + ErrorCheck: testAccErrorCheck(t, iot.EndpointsID), + Providers: testAccProviders, + CheckDestroy: testAccCheckAWSIoTTopicRuleDestroy, + Steps: []resource.TestStep{ + { + Config: testAccAWSIoTTopicRule_kinesis(rName), + Check: resource.ComposeTestCheckFunc( + testAccCheckAWSIoTTopicRuleExists("aws_iot_topic_rule.rule"), + resource.TestCheckResourceAttr(resourceName, "error_action.#", "0"), + ), + }, + + { + Config: testAccAWSIoTTopicRule_errorAction(rName), + Check: resource.ComposeTestCheckFunc( + testAccCheckAWSIoTTopicRuleExists("aws_iot_topic_rule.rule"), + resource.TestCheckResourceAttr(resourceName, "error_action.#", "1"), + ), + }, + { + ResourceName: resourceName, + ImportState: true, + ImportStateVerify: true, + }, + }, + }) +} + func testAccCheckAWSIoTTopicRuleDestroy(s *terraform.State) error { conn := testAccProvider.Meta().(*AWSClient).iotconn