Skip to content

Commit

Permalink
Merge pull request #11390 from magodo/iothub_ip_filter_rule_change_to…
Browse files Browse the repository at this point in the history
…_list

azurerm_iothub - change `filter_rule` from TypeSet to TypeList
  • Loading branch information
manicminer authored Apr 21, 2021
2 parents 5cb8b70 + 8d97a70 commit 84b39de
Show file tree
Hide file tree
Showing 2 changed files with 73 additions and 2 deletions.
4 changes: 2 additions & 2 deletions azurerm/internal/services/iothub/iothub_resource.go
Original file line number Diff line number Diff line change
Expand Up @@ -424,7 +424,7 @@ func resourceIotHub() *schema.Resource {
},

"ip_filter_rule": {
Type: schema.TypeSet,
Type: schema.TypeList,
Optional: true,
Elem: &schema.Resource{
Schema: map[string]*schema.Schema{
Expand Down Expand Up @@ -1286,7 +1286,7 @@ func validateIoTHubFileNameFormat(v interface{}, k string) (warnings []string, e
}

func expandIPFilterRules(d *schema.ResourceData) *[]devices.IPFilterRule {
ipFilterRuleList := d.Get("ip_filter_rule").(*schema.Set).List()
ipFilterRuleList := d.Get("ip_filter_rule").([]interface{})
if len(ipFilterRuleList) == 0 {
return nil
}
Expand Down
71 changes: 71 additions & 0 deletions azurerm/internal/services/iothub/iothub_resource_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,13 @@ func TestAccIotHub_ipFilterRules(t *testing.T) {
),
},
data.ImportStep(),
{
Config: r.ipFilterRulesUpdate(data),
Check: resource.ComposeTestCheckFunc(
check.That(data.ResourceName).ExistsInAzure(r),
),
},
data.ImportStep(),
})
}

Expand Down Expand Up @@ -359,6 +366,70 @@ resource "azurerm_iothub" "test" {
action = "Accept"
}
ip_filter_rule {
name = "test2"
ip_mask = "10.0.2.0/31"
action = "Accept"
}
ip_filter_rule {
name = "test3"
ip_mask = "10.0.3.0/31"
action = "Accept"
}
tags = {
purpose = "testing"
}
}
`, data.RandomInteger, data.Locations.Primary, data.RandomInteger)
}

func (IotHubResource) ipFilterRulesUpdate(data acceptance.TestData) string {
return fmt.Sprintf(`
provider "azurerm" {
features {}
}
resource "azurerm_resource_group" "test" {
name = "acctestRG-%d"
location = "%s"
}
resource "azurerm_iothub" "test" {
name = "acctestIoTHub-%d"
resource_group_name = azurerm_resource_group.test.name
location = azurerm_resource_group.test.location
sku {
name = "S1"
capacity = "1"
}
ip_filter_rule {
name = "test4"
ip_mask = "10.0.4.0/31"
action = "Accept"
}
ip_filter_rule {
name = "test"
ip_mask = "10.0.0.0/31"
action = "Accept"
}
ip_filter_rule {
name = "test3"
ip_mask = "10.0.3.0/31"
action = "Accept"
}
ip_filter_rule {
name = "test5"
ip_mask = "10.0.5.0/31"
action = "Accept"
}
tags = {
purpose = "testing"
}
Expand Down

0 comments on commit 84b39de

Please sign in to comment.