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

azurerm_iothub - endpoint and route can now be cleared by setting them to [] #8028

Merged
merged 2 commits into from
Aug 11, 2020
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
14 changes: 8 additions & 6 deletions azurerm/internal/services/iothub/iothub_resource.go
Original file line number Diff line number Diff line change
Expand Up @@ -209,9 +209,10 @@ func resourceArmIotHub() *schema.Resource {
},

"endpoint": {
Type: schema.TypeList,
Optional: true,
Computed: true,
Type: schema.TypeList,
Optional: true,
Computed: true,
ConfigMode: schema.SchemaConfigModeAttr,
Elem: &schema.Resource{
Schema: map[string]*schema.Schema{
"type": {
Expand Down Expand Up @@ -285,9 +286,10 @@ func resourceArmIotHub() *schema.Resource {
},

"route": {
Type: schema.TypeList,
Optional: true,
Computed: true,
Type: schema.TypeList,
Optional: true,
Computed: true,
ConfigMode: schema.SchemaConfigModeAttr,
Elem: &schema.Resource{
Schema: map[string]*schema.Schema{
"name": {
Expand Down
98 changes: 98 additions & 0 deletions azurerm/internal/services/iothub/tests/iothub_resource_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,32 @@ func TestAccAzureRMIotHub_customRoutes(t *testing.T) {
})
}

func TestAccAzureRMIotHub_removeEndpointsAndRoutes(t *testing.T) {
data := acceptance.BuildTestData(t, "azurerm_iothub", "test")

resource.ParallelTest(t, resource.TestCase{
PreCheck: func() { acceptance.PreCheck(t) },
Providers: acceptance.SupportedProviders,
CheckDestroy: testCheckAzureRMIotHubDestroy,
Steps: []resource.TestStep{
{
Config: testAccAzureRMIotHub_customRoutes(data),
Check: resource.ComposeTestCheckFunc(
testCheckAzureRMIotHubExists(data.ResourceName),
),
},
data.ImportStep(),
{
Config: testAccAzureRMIotHub_removeEndpointsAndRoutes(data),
Check: resource.ComposeTestCheckFunc(
testCheckAzureRMIotHubExists(data.ResourceName),
),
},
data.ImportStep(),
},
})
}

func TestAccAzureRMIotHub_fileUpload(t *testing.T) {
data := acceptance.BuildTestData(t, "azurerm_iothub", "test")

Expand Down Expand Up @@ -422,6 +448,78 @@ resource "azurerm_iothub" "test" {
`, data.RandomInteger, data.Locations.Primary, data.RandomString, data.RandomInteger, data.RandomInteger)
}

func testAccAzureRMIotHub_removeEndpointsAndRoutes(data acceptance.TestData) string {
return fmt.Sprintf(`
provider "azurerm" {
features {}
}

resource "azurerm_resource_group" "test" {
name = "acctestRG-%d"
location = "%s"
}

resource "azurerm_storage_account" "test" {
name = "acctestsa%s"
resource_group_name = azurerm_resource_group.test.name
location = azurerm_resource_group.test.location
account_tier = "Standard"
account_replication_type = "LRS"
}

resource "azurerm_storage_container" "test" {
name = "test"
storage_account_name = azurerm_storage_account.test.name
container_access_type = "private"
}

resource "azurerm_eventhub_namespace" "test" {
resource_group_name = azurerm_resource_group.test.name
location = azurerm_resource_group.test.location
name = "acctest-%d"
sku = "Basic"
}

resource "azurerm_eventhub" "test" {
name = "acctest"
resource_group_name = azurerm_resource_group.test.name
namespace_name = azurerm_eventhub_namespace.test.name
partition_count = 2
message_retention = 1
}

resource "azurerm_eventhub_authorization_rule" "test" {
resource_group_name = azurerm_resource_group.test.name
namespace_name = azurerm_eventhub_namespace.test.name
eventhub_name = azurerm_eventhub.test.name
name = "acctest"
send = true
}

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"
}

event_hub_retention_in_days = 7
event_hub_partition_count = 77

endpoint = []

route = []

tags = {
purpose = "testing"
}
}
`, data.RandomInteger, data.Locations.Primary, data.RandomString, data.RandomInteger, data.RandomInteger)
}

func testAccAzureRMIotHub_fallbackRoute(data acceptance.TestData) string {
return fmt.Sprintf(`
provider "azurerm" {
Expand Down