From 2db030b8b39d96add7a187ed725a7fca6a49a6d3 Mon Sep 17 00:00:00 2001 From: kt Date: Tue, 14 Jan 2020 11:39:15 -0800 Subject: [PATCH] =?UTF-8?q?azurerm=5Fiothub=20&=20azurerm=5Fiothub=5Fdps:?= =?UTF-8?q?=20deprecate=20the=20sku.tier=20pro=E2=80=A6=20(#5382)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit partially addresses #1500 --- .../services/iothub/resource_arm_iot_dps.go | 4 +++- .../services/iothub/resource_arm_iothub.go | 23 ++++++++----------- .../iothub/resource_arm_iothub_dps.go | 20 +++++++--------- .../resource_arm_iot_dps_certificate_test.go | 2 -- .../iothub/tests/resource_arm_iot_dps_test.go | 7 +----- ...esource_arm_iothub_dps_certificate_test.go | 2 -- ...rm_iothub_dps_shared_access_policy_test.go | 4 ---- .../tests/resource_arm_iothub_dps_test.go | 7 +----- ...resource_arm_iothub_fallback_route_test.go | 2 -- .../tests/resource_arm_iothub_route_test.go | 2 -- .../iothub/tests/resource_arm_iothub_test.go | 8 +------ ...ream_analytics_stream_input_iothub_test.go | 2 -- .../guides/2.0-upgrade-guide.html.markdown | 8 +++++++ website/docs/r/iothub.html.markdown | 1 - .../r/iothub_consumer_group.html.markdown | 1 - website/docs/r/iothub_dps.html.markdown | 1 - .../r/iothub_dps_certificate.html.markdown | 1 - ...hub_dps_shared_access_policy.html.markdown | 1 - ...b_endpoint_storage_container.html.markdown | 1 - .../r/iothub_fallback_route.html.markdown | 1 - website/docs/r/iothub_route.html.markdown | 1 - .../iothub_shared_access_policy.html.markdown | 1 - ...nalytics_stream_input_iothub.html.markdown | 1 - 23 files changed, 31 insertions(+), 70 deletions(-) diff --git a/azurerm/internal/services/iothub/resource_arm_iot_dps.go b/azurerm/internal/services/iothub/resource_arm_iot_dps.go index c6d401a86c35..45a656e4dedb 100644 --- a/azurerm/internal/services/iothub/resource_arm_iot_dps.go +++ b/azurerm/internal/services/iothub/resource_arm_iot_dps.go @@ -84,7 +84,9 @@ As such the existing 'azurerm_iot_dps' resource is deprecated and will be remove "tier": { Type: schema.TypeString, - Required: true, + Optional: true, + Computed: true, + Deprecated: "This property is no longer required and will be removed in version 2.0 of the provider", DiffSuppressFunc: suppress.CaseDifference, ValidateFunc: validation.StringInSlice([]string{ string(devices.Basic), diff --git a/azurerm/internal/services/iothub/resource_arm_iothub.go b/azurerm/internal/services/iothub/resource_arm_iothub.go index dbd2c9c1205d..0babfe7bdae4 100644 --- a/azurerm/internal/services/iothub/resource_arm_iothub.go +++ b/azurerm/internal/services/iothub/resource_arm_iothub.go @@ -94,12 +94,14 @@ func resourceArmIotHub() *schema.Resource { string(devices.S1), string(devices.S2), string(devices.S3), - }, true), + }, true), // todo 2.0 make this case sensitive (all constants?) }, "tier": { Type: schema.TypeString, - Required: true, + Optional: true, + Computed: true, + Deprecated: "This property is no longer required and will be removed in version 2.0 of the provider", DiffSuppressFunc: suppress.CaseDifference, ValidateFunc: validation.StringInSlice([]string{ string(devices.Basic), @@ -111,7 +113,7 @@ func resourceArmIotHub() *schema.Resource { "capacity": { Type: schema.TypeInt, Required: true, - ValidateFunc: validation.IntAtLeast(1), + ValidateFunc: validation.IntBetween(1, 200), }, }, }, @@ -469,8 +471,6 @@ func resourceArmIotHubCreateUpdate(d *schema.ResourceData, meta interface{}) err } location := azure.NormalizeLocation(d.Get("location").(string)) - skuInfo := expandIoTHubSku(d) - t := d.Get("tags").(map[string]interface{}) routingProperties := devices.RoutingProperties{} @@ -500,7 +500,7 @@ func resourceArmIotHubCreateUpdate(d *schema.ResourceData, meta interface{}) err properties := devices.IotHubDescription{ Name: utils.String(name), Location: utils.String(location), - Sku: skuInfo, + Sku: expandIoTHubSku(d), Properties: &devices.IotHubProperties{ IPFilterRules: ipFilterRules, Routing: &routingProperties, @@ -508,7 +508,7 @@ func resourceArmIotHubCreateUpdate(d *schema.ResourceData, meta interface{}) err MessagingEndpoints: messagingEndpoints, EnableFileUploadNotifications: &enableFileUploadNotifications, }, - Tags: tags.Expand(t), + Tags: tags.Expand(d.Get("tags").(map[string]interface{})), } future, err := client.CreateOrUpdate(ctx, resourceGroup, name, properties, "") @@ -847,15 +847,10 @@ func expandIoTHubFallbackRoute(d *schema.ResourceData) *devices.FallbackRoutePro func expandIoTHubSku(d *schema.ResourceData) *devices.IotHubSkuInfo { skuList := d.Get("sku").([]interface{}) skuMap := skuList[0].(map[string]interface{}) - capacity := int64(skuMap["capacity"].(int)) - - name := skuMap["name"].(string) - tier := skuMap["tier"].(string) return &devices.IotHubSkuInfo{ - Name: devices.IotHubSku(name), - Tier: devices.IotHubSkuTier(tier), - Capacity: utils.Int64(capacity), + Name: devices.IotHubSku(skuMap["name"].(string)), + Capacity: utils.Int64(int64(skuMap["capacity"].(int))), } } diff --git a/azurerm/internal/services/iothub/resource_arm_iothub_dps.go b/azurerm/internal/services/iothub/resource_arm_iothub_dps.go index 9c43017114ef..789a01038ae9 100644 --- a/azurerm/internal/services/iothub/resource_arm_iothub_dps.go +++ b/azurerm/internal/services/iothub/resource_arm_iothub_dps.go @@ -73,13 +73,14 @@ func resourceArmIotHubDPS() *schema.Resource { string(devices.S1), string(devices.S2), string(devices.S3), - }, true), + }, true), // todo 2.0 make this case sensitive }, "tier": { - Type: schema.TypeString, - Required: true, - DiffSuppressFunc: suppress.CaseDifference, + Type: schema.TypeString, + Optional: true, + Computed: true, + Deprecated: "This property is no longer required and will be removed in version 2.0 of the provider", ValidateFunc: validation.StringInSlice([]string{ string(devices.Basic), string(devices.Free), @@ -90,7 +91,7 @@ func resourceArmIotHubDPS() *schema.Resource { "capacity": { Type: schema.TypeInt, Required: true, - ValidateFunc: validation.IntAtLeast(1), + ValidateFunc: validation.IntBetween(1, 200), }, }, }, @@ -329,15 +330,10 @@ func iothubdpsStateStatusCodeRefreshFunc(ctx context.Context, client *iothub.Iot func expandIoTHubDPSSku(d *schema.ResourceData) *iothub.IotDpsSkuInfo { skuList := d.Get("sku").([]interface{}) skuMap := skuList[0].(map[string]interface{}) - capacity := int64(skuMap["capacity"].(int)) - - name := skuMap["name"].(string) - tier := skuMap["tier"].(string) return &iothub.IotDpsSkuInfo{ - Name: iothub.IotDpsSku(name), - Tier: utils.String(tier), - Capacity: utils.Int64(capacity), + Name: iothub.IotDpsSku(skuMap["name"].(string)), + Capacity: utils.Int64(int64(skuMap["capacity"].(int))), } } diff --git a/azurerm/internal/services/iothub/tests/resource_arm_iot_dps_certificate_test.go b/azurerm/internal/services/iothub/tests/resource_arm_iot_dps_certificate_test.go index 586173592411..03bf322e7f41 100644 --- a/azurerm/internal/services/iothub/tests/resource_arm_iot_dps_certificate_test.go +++ b/azurerm/internal/services/iothub/tests/resource_arm_iot_dps_certificate_test.go @@ -154,7 +154,6 @@ resource "azurerm_iot_dps" "test" { sku { name = "S1" - tier = "Standard" capacity = "1" } } @@ -198,7 +197,6 @@ resource "azurerm_iot_dps" "test" { sku { name = "S1" - tier = "Standard" capacity = "1" } diff --git a/azurerm/internal/services/iothub/tests/resource_arm_iot_dps_test.go b/azurerm/internal/services/iothub/tests/resource_arm_iot_dps_test.go index a7f38dc0195b..8283155704e4 100644 --- a/azurerm/internal/services/iothub/tests/resource_arm_iot_dps_test.go +++ b/azurerm/internal/services/iothub/tests/resource_arm_iot_dps_test.go @@ -177,7 +177,6 @@ resource "azurerm_iot_dps" "test" { sku { name = "S1" - tier = "Standard" capacity = "1" } } @@ -191,12 +190,11 @@ func testAccAzureRMIotDPS_requiresImport(data acceptance.TestData) string { resource "azurerm_iot_dps" "import" { name = "${azurerm_iot_dps.test.name}" - resource_group_name = "${azurerm_iot_dps.test.name}" + resource_group_name = "${azurerm_iot_dps.test.resource_group_name}" location = "${azurerm_iot_dps.test.location}" sku { name = "S1" - tier = "Standard" capacity = "1" } } @@ -217,7 +215,6 @@ resource "azurerm_iot_dps" "test" { sku { name = "S1" - tier = "Standard" capacity = "1" } @@ -242,7 +239,6 @@ resource "azurerm_iot_dps" "test" { sku { name = "S1" - tier = "Standard" capacity = "1" } @@ -275,7 +271,6 @@ resource "azurerm_iot_dps" "test" { sku { name = "S1" - tier = "Standard" capacity = "1" } diff --git a/azurerm/internal/services/iothub/tests/resource_arm_iothub_dps_certificate_test.go b/azurerm/internal/services/iothub/tests/resource_arm_iothub_dps_certificate_test.go index 85e69cd1ada2..e0d00abc3b9c 100644 --- a/azurerm/internal/services/iothub/tests/resource_arm_iothub_dps_certificate_test.go +++ b/azurerm/internal/services/iothub/tests/resource_arm_iothub_dps_certificate_test.go @@ -154,7 +154,6 @@ resource "azurerm_iothub_dps" "test" { sku { name = "S1" - tier = "Standard" capacity = "1" } } @@ -198,7 +197,6 @@ resource "azurerm_iothub_dps" "test" { sku { name = "S1" - tier = "Standard" capacity = "1" } diff --git a/azurerm/internal/services/iothub/tests/resource_arm_iothub_dps_shared_access_policy_test.go b/azurerm/internal/services/iothub/tests/resource_arm_iothub_dps_shared_access_policy_test.go index 2d77a266e608..6cb1cbf87450 100644 --- a/azurerm/internal/services/iothub/tests/resource_arm_iothub_dps_shared_access_policy_test.go +++ b/azurerm/internal/services/iothub/tests/resource_arm_iothub_dps_shared_access_policy_test.go @@ -102,7 +102,6 @@ resource "azurerm_iothub_dps" "test" { sku { name = "S1" - tier = "Standard" capacity = "1" } } @@ -128,7 +127,6 @@ resource "azurerm_iothub_dps" "test" { sku { name = "S1" - tier = "Standard" capacity = "1" } } @@ -154,7 +152,6 @@ resource "azurerm_iothub_dps" "test" { sku { name = "S1" - tier = "Standard" capacity = "1" } } @@ -180,7 +177,6 @@ resource "azurerm_iothub_dps" "test" { sku { name = "S1" - tier = "Standard" capacity = "1" } } diff --git a/azurerm/internal/services/iothub/tests/resource_arm_iothub_dps_test.go b/azurerm/internal/services/iothub/tests/resource_arm_iothub_dps_test.go index 269a05f30a07..2219458d2d30 100644 --- a/azurerm/internal/services/iothub/tests/resource_arm_iothub_dps_test.go +++ b/azurerm/internal/services/iothub/tests/resource_arm_iothub_dps_test.go @@ -181,7 +181,6 @@ resource "azurerm_iothub_dps" "test" { sku { name = "S1" - tier = "Standard" capacity = "1" } } @@ -195,12 +194,11 @@ func testAccAzureRMIotHubDPS_requiresImport(data acceptance.TestData) string { resource "azurerm_iothub_dps" "import" { name = "${azurerm_iothub_dps.test.name}" - resource_group_name = "${azurerm_iothub_dps.test.name}" + resource_group_name = "${azurerm_iothub_dps.test.resource_group_name}" location = "${azurerm_iothub_dps.test.location}" sku { name = "S1" - tier = "Standard" capacity = "1" } } @@ -221,7 +219,6 @@ resource "azurerm_iothub_dps" "test" { sku { name = "S1" - tier = "Standard" capacity = "1" } @@ -246,7 +243,6 @@ resource "azurerm_iothub_dps" "test" { sku { name = "S1" - tier = "Standard" capacity = "1" } @@ -279,7 +275,6 @@ resource "azurerm_iothub_dps" "test" { sku { name = "S1" - tier = "Standard" capacity = "1" } diff --git a/azurerm/internal/services/iothub/tests/resource_arm_iothub_fallback_route_test.go b/azurerm/internal/services/iothub/tests/resource_arm_iothub_fallback_route_test.go index fc0a99c47fb7..1e82148defed 100644 --- a/azurerm/internal/services/iothub/tests/resource_arm_iothub_fallback_route_test.go +++ b/azurerm/internal/services/iothub/tests/resource_arm_iothub_fallback_route_test.go @@ -194,7 +194,6 @@ resource "azurerm_iothub" "test" { sku { name = "S1" - tier = "Standard" capacity = "1" } @@ -256,7 +255,6 @@ resource "azurerm_iothub" "test" { sku { name = "S1" - tier = "Standard" capacity = "1" } diff --git a/azurerm/internal/services/iothub/tests/resource_arm_iothub_route_test.go b/azurerm/internal/services/iothub/tests/resource_arm_iothub_route_test.go index 9171fac98f38..eb1a49a39b94 100644 --- a/azurerm/internal/services/iothub/tests/resource_arm_iothub_route_test.go +++ b/azurerm/internal/services/iothub/tests/resource_arm_iothub_route_test.go @@ -217,7 +217,6 @@ resource "azurerm_iothub" "test" { sku { name = "S1" - tier = "Standard" capacity = "1" } @@ -282,7 +281,6 @@ resource "azurerm_iothub" "test" { sku { name = "S1" - tier = "Standard" capacity = "1" } diff --git a/azurerm/internal/services/iothub/tests/resource_arm_iothub_test.go b/azurerm/internal/services/iothub/tests/resource_arm_iothub_test.go index 05c01de5f65a..ef10dd9bf47b 100644 --- a/azurerm/internal/services/iothub/tests/resource_arm_iothub_test.go +++ b/azurerm/internal/services/iothub/tests/resource_arm_iothub_test.go @@ -229,7 +229,6 @@ resource "azurerm_iothub" "test" { sku { name = "B1" - tier = "Basic" capacity = "1" } @@ -247,7 +246,7 @@ func testAccAzureRMIotHub_requiresImport(data acceptance.TestData) string { resource "azurerm_iothub" "import" { name = "${azurerm_iothub.test.name}" - resource_group_name = "${azurerm_iothub.test.name}" + resource_group_name = "${azurerm_iothub.test.resource_group_name}" location = "${azurerm_iothub.test.location}" sku { @@ -277,7 +276,6 @@ resource "azurerm_iothub" "test" { sku { name = "S1" - tier = "Standard" capacity = "1" } @@ -302,7 +300,6 @@ resource "azurerm_iothub" "test" { sku { name = "S1" - tier = "Standard" capacity = "1" } @@ -371,7 +368,6 @@ resource "azurerm_iothub" "test" { sku { name = "S1" - tier = "Standard" capacity = "1" } @@ -429,7 +425,6 @@ resource "azurerm_iothub" "test" { sku { name = "S1" - tier = "Standard" capacity = "1" } @@ -475,7 +470,6 @@ resource "azurerm_iothub" "test" { sku { name = "S1" - tier = "Standard" capacity = "1" } diff --git a/azurerm/internal/services/streamanalytics/tests/resource_arm_stream_analytics_stream_input_iothub_test.go b/azurerm/internal/services/streamanalytics/tests/resource_arm_stream_analytics_stream_input_iothub_test.go index 37ffea4bbbb7..523e7baaca8e 100644 --- a/azurerm/internal/services/streamanalytics/tests/resource_arm_stream_analytics_stream_input_iothub_test.go +++ b/azurerm/internal/services/streamanalytics/tests/resource_arm_stream_analytics_stream_input_iothub_test.go @@ -255,7 +255,6 @@ resource "azurerm_iothub" "updated" { sku { name = "S1" - tier = "Standard" capacity = "1" } } @@ -310,7 +309,6 @@ resource "azurerm_iothub" "test" { sku { name = "S1" - tier = "Standard" capacity = "1" } } diff --git a/website/docs/guides/2.0-upgrade-guide.html.markdown b/website/docs/guides/2.0-upgrade-guide.html.markdown index 1017c8101502..4d3e2c33ee6b 100644 --- a/website/docs/guides/2.0-upgrade-guide.html.markdown +++ b/website/docs/guides/2.0-upgrade-guide.html.markdown @@ -299,6 +299,14 @@ The deprecated `location` field will be removed, since this is no longer used. The deprecated `internal_public_ip_address_id` field in the `ip_configuration` block will be removed. This field has been replaced by the `public_ip_address_id` field in the `ip_configuration` block. +### Resource: `azurerm_iothub` + +The deprecated `sku.tier` property will be remove. + +### Resource: `azurerm_iothub_dps` + +The deprecated `sku.tier` property will be remove. + ### Resource: `azurerm_iot_dps` This resource has been renamed to `azurerm_iothub_dps` which is available from v1.37 of the AzureRM Provider - instructions on [how to migrate are available in this guide](https://terraform.io/docs/providers/azurerm/guides/migrating-between-renamed-resources.html). As such this resource will be removed. diff --git a/website/docs/r/iothub.html.markdown b/website/docs/r/iothub.html.markdown index 2f997acdf2b0..f4fff20c587b 100644 --- a/website/docs/r/iothub.html.markdown +++ b/website/docs/r/iothub.html.markdown @@ -46,7 +46,6 @@ resource "azurerm_iothub" "example" { sku { name = "S1" - tier = "Standard" capacity = "1" } diff --git a/website/docs/r/iothub_consumer_group.html.markdown b/website/docs/r/iothub_consumer_group.html.markdown index 2b1c57f265ba..9cf5cd399aba 100644 --- a/website/docs/r/iothub_consumer_group.html.markdown +++ b/website/docs/r/iothub_consumer_group.html.markdown @@ -25,7 +25,6 @@ resource "azurerm_iothub" "example" { sku { name = "S1" - tier = "Standard" capacity = "1" } diff --git a/website/docs/r/iothub_dps.html.markdown b/website/docs/r/iothub_dps.html.markdown index 7d362e11ba5c..007efab732fc 100644 --- a/website/docs/r/iothub_dps.html.markdown +++ b/website/docs/r/iothub_dps.html.markdown @@ -25,7 +25,6 @@ resource "azurerm_iothub_dps" "example" { sku { name = "S1" - tier = "Standard" capacity = "1" } } diff --git a/website/docs/r/iothub_dps_certificate.html.markdown b/website/docs/r/iothub_dps_certificate.html.markdown index 564715a70155..cb529cbdb7e2 100644 --- a/website/docs/r/iothub_dps_certificate.html.markdown +++ b/website/docs/r/iothub_dps_certificate.html.markdown @@ -25,7 +25,6 @@ resource "azurerm_iothub_dps" "example" { sku { name = "S1" - tier = "Standard" capacity = "1" } } diff --git a/website/docs/r/iothub_dps_shared_access_policy.html.markdown b/website/docs/r/iothub_dps_shared_access_policy.html.markdown index 87da57ca2381..29a7cfe26727 100644 --- a/website/docs/r/iothub_dps_shared_access_policy.html.markdown +++ b/website/docs/r/iothub_dps_shared_access_policy.html.markdown @@ -25,7 +25,6 @@ resource "azurerm_iothub_dps" "example" { sku { name = "S1" - tier = "Standard" capacity = "1" } } diff --git a/website/docs/r/iothub_endpoint_storage_container.html.markdown b/website/docs/r/iothub_endpoint_storage_container.html.markdown index e4112b80cb7f..04458a746aba 100644 --- a/website/docs/r/iothub_endpoint_storage_container.html.markdown +++ b/website/docs/r/iothub_endpoint_storage_container.html.markdown @@ -42,7 +42,6 @@ resource "azurerm_iothub" "example" { sku { name = "S1" - tier = "Standard" capacity = "1" } } diff --git a/website/docs/r/iothub_fallback_route.html.markdown b/website/docs/r/iothub_fallback_route.html.markdown index a00f2373b6fc..ffa33bc5f8ff 100644 --- a/website/docs/r/iothub_fallback_route.html.markdown +++ b/website/docs/r/iothub_fallback_route.html.markdown @@ -42,7 +42,6 @@ resource "azurerm_iothub" "example" { sku { name = "S1" - tier = "Standard" capacity = "1" } diff --git a/website/docs/r/iothub_route.html.markdown b/website/docs/r/iothub_route.html.markdown index 19a41061c626..ec3e2386dfde 100644 --- a/website/docs/r/iothub_route.html.markdown +++ b/website/docs/r/iothub_route.html.markdown @@ -42,7 +42,6 @@ resource "azurerm_iothub" "example" { sku { name = "S1" - tier = "Standard" capacity = "1" } diff --git a/website/docs/r/iothub_shared_access_policy.html.markdown b/website/docs/r/iothub_shared_access_policy.html.markdown index c055a34a7cdf..22a840304338 100644 --- a/website/docs/r/iothub_shared_access_policy.html.markdown +++ b/website/docs/r/iothub_shared_access_policy.html.markdown @@ -25,7 +25,6 @@ resource "azurerm_iothub" "example" { sku { name = "S1" - tier = "Standard" capacity = "1" } } diff --git a/website/docs/r/stream_analytics_stream_input_iothub.html.markdown b/website/docs/r/stream_analytics_stream_input_iothub.html.markdown index f2bc15321c5d..5174d320463a 100644 --- a/website/docs/r/stream_analytics_stream_input_iothub.html.markdown +++ b/website/docs/r/stream_analytics_stream_input_iothub.html.markdown @@ -29,7 +29,6 @@ resource "azurerm_iothub" "example" { sku { name = "S1" - tier = "Standard" capacity = "1" } }