Skip to content

Commit

Permalink
add CHANGELOG and test coverage
Browse files Browse the repository at this point in the history
  • Loading branch information
anGie44 committed Aug 6, 2021
1 parent cc783c3 commit fb62431
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 1 deletion.
3 changes: 3 additions & 0 deletions .changelog/16471.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
```release-note:bug
resource/aws_iot_topic_rule: Correctly update resource on `error_action` change
```
2 changes: 1 addition & 1 deletion aws/resource_aws_iot_topic_rule.go
Original file line number Diff line number Diff line change
Expand Up @@ -1222,6 +1222,7 @@ func resourceAwsIotTopicRuleUpdate(d *schema.ResourceData, meta interface{}) err
"dynamodbv2",
"elasticsearch",
"enabled",
"error_action",
"firehose",
"iot_analytics",
"iot_events",
Expand All @@ -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)),
Expand Down
35 changes: 35 additions & 0 deletions aws/resource_aws_iot_topic_rule_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down

0 comments on commit fb62431

Please sign in to comment.