Skip to content

Commit

Permalink
r/aws_iot_topic_rule: test for timestream as iot action
Browse files Browse the repository at this point in the history
  • Loading branch information
thiagoarrais committed Mar 7, 2022
1 parent dccefb9 commit 37cc161
Showing 1 changed file with 55 additions and 0 deletions.
55 changes: 55 additions & 0 deletions internal/service/iot/topic_rule_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -425,6 +425,31 @@ func TestAccIoTTopicRule_Step_functions(t *testing.T) {
})
}

func TestAccIoTTopicRule_Timestream(t *testing.T) {
rName := sdkacctest.RandString(5)
resourceName := "aws_iot_topic_rule.rule"

resource.ParallelTest(t, resource.TestCase{
PreCheck: func() { acctest.PreCheck(t) },
ErrorCheck: acctest.ErrorCheck(t, iot.EndpointsID),
Providers: acctest.Providers,
CheckDestroy: testAccCheckTopicRuleDestroy,
Steps: []resource.TestStep{
{
Config: testAccTopicRule_timestream(rName),
Check: resource.ComposeTestCheckFunc(
testAccCheckTopicRuleExists("aws_iot_topic_rule.rule"),
),
},
{
ResourceName: resourceName,
ImportState: true,
ImportStateVerify: true,
},
},
})
}

func TestAccIoTTopicRule_IoT_analytics(t *testing.T) {
rName := sdkacctest.RandString(5)

Expand Down Expand Up @@ -1019,6 +1044,36 @@ resource "aws_iot_topic_rule" "rule" {
`, rName))
}

func testAccTopicRule_timestream(rName string) string {
return acctest.ConfigCompose(
testAccTopicRuleRole(rName),
fmt.Sprintf(`
resource "aws_iot_topic_rule" "rule" {
name = "test_rule_%[1]s"
description = "Example rule"
enabled = true
sql = "SELECT * FROM 'topic/test'"
sql_version = "2015-10-08"
timestream {
database_name = "TestDB"
role_arn = aws_iam_role.iot_role.arn
table_name = "test_table"
dimension {
name = "dim"
value = "$${dim}"
}
timestamp {
unit = "MILLISECONDS"
value = "$${time}"
}
}
}
`, rName))
}

func testAccTopicRule_iot_analytics(rName string) string {
return acctest.ConfigCompose(
testAccTopicRuleRole(rName),
Expand Down

0 comments on commit 37cc161

Please sign in to comment.