diff --git a/azurerm/internal/services/notificationhub/resource_arm_notification_hub_namespace.go b/azurerm/internal/services/notificationhub/resource_arm_notification_hub_namespace.go index a9975f893dce..b7f8a05b2580 100644 --- a/azurerm/internal/services/notificationhub/resource_arm_notification_hub_namespace.go +++ b/azurerm/internal/services/notificationhub/resource_arm_notification_hub_namespace.go @@ -52,35 +52,9 @@ func resourceArmNotificationHubNamespace() *schema.Resource { "location": azure.SchemaLocation(), - "sku": { - Type: schema.TypeList, - Optional: true, - Computed: true, - Deprecated: "This property has been deprecated in favour of the 'sku_name' property and will be removed in version 2.0 of the provider", - ConflictsWith: []string{"sku_name"}, - MaxItems: 1, - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "name": { - Type: schema.TypeString, - Required: true, - ForceNew: true, - ValidateFunc: validation.StringInSlice([]string{ - string(notificationhubs.Basic), - string(notificationhubs.Free), - string(notificationhubs.Standard), - }, false), - }, - }, - }, - }, - "sku_name": { - Type: schema.TypeString, - Optional: true, - Computed: true, - ForceNew: true, - ConflictsWith: []string{"sku"}, + Type: schema.TypeString, + Required: true, ValidateFunc: validation.StringInSlice([]string{ string(notificationhubs.Basic), string(notificationhubs.Free), @@ -121,25 +95,8 @@ func resourceArmNotificationHubNamespaceCreateUpdate(d *schema.ResourceData, met ctx, cancel := timeouts.ForCreateUpdate(meta.(*clients.Client).StopContext, d) defer cancel() - // Remove in 2.0 - var sku notificationhubs.Sku - - if inputs := d.Get("sku").([]interface{}); len(inputs) != 0 { - input := inputs[0].(map[string]interface{}) - v := input["name"].(string) - - sku = notificationhubs.Sku{ - Name: notificationhubs.SkuName(v), - } - } else { - // Keep in 2.0 - sku = notificationhubs.Sku{ - Name: notificationhubs.SkuName(d.Get("sku_name").(string)), - } - } - - if sku.Name == "" { - return fmt.Errorf("either 'sku_name' or 'sku' must be defined in the configuration file") + sku := notificationhubs.Sku{ + Name: notificationhubs.SkuName(d.Get("sku_name").(string)), } name := d.Get("name").(string) @@ -236,11 +193,6 @@ func resourceArmNotificationHubNamespaceRead(d *schema.ResourceData, meta interf } if sku := resp.Sku; sku != nil { - // Remove in 2.0 - if err := d.Set("sku", flattenNotificationHubNamespacesSku(sku)); err != nil { - return fmt.Errorf("Error setting 'sku': %+v", err) - } - if err := d.Set("sku_name", string(sku.Name)); err != nil { return fmt.Errorf("Error setting 'sku_name': %+v", err) } @@ -292,20 +244,6 @@ func resourceArmNotificationHubNamespaceDelete(d *schema.ResourceData, meta inte return nil } -// Remove in 2.0 -func flattenNotificationHubNamespacesSku(input *notificationhubs.Sku) []interface{} { - outputs := make([]interface{}, 0) - if input == nil { - return outputs - } - - output := map[string]interface{}{ - "name": string(input.Name), - } - outputs = append(outputs, output) - return outputs -} - func notificationHubNamespaceStateRefreshFunc(ctx context.Context, client *notificationhubs.NamespacesClient, resourceGroupName string, name string) resource.StateRefreshFunc { return func() (interface{}, string, error) { res, err := client.Get(ctx, resourceGroupName, name) diff --git a/azurerm/internal/services/notificationhub/tests/resource_arm_notification_hub_authorization_rule_test.go b/azurerm/internal/services/notificationhub/tests/resource_arm_notification_hub_authorization_rule_test.go index 17a550b2f2d8..d354ab07c668 100644 --- a/azurerm/internal/services/notificationhub/tests/resource_arm_notification_hub_authorization_rule_test.go +++ b/azurerm/internal/services/notificationhub/tests/resource_arm_notification_hub_authorization_rule_test.go @@ -355,10 +355,7 @@ resource "azurerm_notification_hub_namespace" "test" { resource_group_name = "${azurerm_resource_group.test.name}" location = "${azurerm_resource_group.test.location}" namespace_type = "NotificationHub" - - sku { - name = "Free" - } + sku_name = "Free" } resource "azurerm_notification_hub" "test" { diff --git a/azurerm/internal/services/notificationhub/tests/resource_arm_notification_hub_namespace_test.go b/azurerm/internal/services/notificationhub/tests/resource_arm_notification_hub_namespace_test.go index ac7e31b86ba1..fae8ccae7d72 100644 --- a/azurerm/internal/services/notificationhub/tests/resource_arm_notification_hub_namespace_test.go +++ b/azurerm/internal/services/notificationhub/tests/resource_arm_notification_hub_namespace_test.go @@ -3,7 +3,6 @@ package tests import ( "fmt" "net/http" - "regexp" "testing" "github.com/hashicorp/terraform-plugin-sdk/helper/resource" @@ -31,41 +30,6 @@ func TestAccAzureRMNotificationHubNamespace_free(t *testing.T) { }) } -// Remove in 2.0 -func TestAccAzureRMNotificationHubNamespace_freeClassic(t *testing.T) { - data := acceptance.BuildTestData(t, "azurerm_notification_hub_namespace", "test") - resource.ParallelTest(t, resource.TestCase{ - PreCheck: func() { acceptance.PreCheck(t) }, - Providers: acceptance.SupportedProviders, - CheckDestroy: testCheckAzureRMNotificationHubNamespaceDestroy, - Steps: []resource.TestStep{ - { - Config: testAccAzureRMNotificationHubNamespace_freeClassic(data), - Check: resource.ComposeTestCheckFunc( - testCheckAzureRMNotificationHubNamespaceExists(data.ResourceName), - ), - }, - data.ImportStep(), - }, - }) -} - -// Remove in 2.0 -func TestAccAzureRMNotificationHubNamespace_freeNotDefined(t *testing.T) { - data := acceptance.BuildTestData(t, "azurerm_notification_hub_namespace", "test") - resource.ParallelTest(t, resource.TestCase{ - PreCheck: func() { acceptance.PreCheck(t) }, - Providers: acceptance.SupportedProviders, - CheckDestroy: testCheckAzureRMNotificationHubNamespaceDestroy, - Steps: []resource.TestStep{ - { - Config: testAccAzureRMNotificationHubNamespace_freeNotDefined(data), - ExpectError: regexp.MustCompile("either 'sku_name' or 'sku' must be defined in the configuration file"), - }, - }, - }) -} - func TestAccAzureRMNotificationHubNamespace_requiresImport(t *testing.T) { if !features.ShouldResourcesBeImported() { t.Skip("Skipping since resources aren't required to be imported") @@ -158,42 +122,6 @@ resource "azurerm_notification_hub_namespace" "test" { `, data.RandomInteger, data.Locations.Primary, data.RandomInteger) } -func testAccAzureRMNotificationHubNamespace_freeClassic(data acceptance.TestData) string { - return fmt.Sprintf(` -resource "azurerm_resource_group" "test" { - name = "acctestRG-%d" - location = "%s" -} - -resource "azurerm_notification_hub_namespace" "test" { - name = "acctestnhn-%d" - resource_group_name = "${azurerm_resource_group.test.name}" - location = "${azurerm_resource_group.test.location}" - namespace_type = "NotificationHub" - - sku { - name = "Free" - } -} -`, data.RandomInteger, data.Locations.Primary, data.RandomInteger) -} - -func testAccAzureRMNotificationHubNamespace_freeNotDefined(data acceptance.TestData) string { - return fmt.Sprintf(` -resource "azurerm_resource_group" "test" { - name = "acctestRG-%d" - location = "%s" -} - -resource "azurerm_notification_hub_namespace" "test" { - name = "acctestnhn-%d" - resource_group_name = "${azurerm_resource_group.test.name}" - location = "${azurerm_resource_group.test.location}" - namespace_type = "NotificationHub" -} -`, data.RandomInteger, data.Locations.Primary, data.RandomInteger) -} - func testAccAzureRMNotificationHubNamespace_requiresImport(data acceptance.TestData) string { template := testAccAzureRMNotificationHubNamespace_free(data) return fmt.Sprintf(` diff --git a/azurerm/internal/services/notificationhub/tests/resource_arm_notification_hub_test.go b/azurerm/internal/services/notificationhub/tests/resource_arm_notification_hub_test.go index e3bc7705020b..7daae627df7f 100644 --- a/azurerm/internal/services/notificationhub/tests/resource_arm_notification_hub_test.go +++ b/azurerm/internal/services/notificationhub/tests/resource_arm_notification_hub_test.go @@ -123,10 +123,7 @@ resource "azurerm_notification_hub_namespace" "test" { resource_group_name = "${azurerm_resource_group.test.name}" location = "${azurerm_resource_group.test.location}" namespace_type = "NotificationHub" - - sku { - name = "Free" - } + sku_name = "Free" } resource "azurerm_notification_hub" "test" { @@ -144,10 +141,10 @@ func testAccAzureRMNotificationHub_requiresImport(data acceptance.TestData) stri %s resource "azurerm_notification_hub" "import" { - name = "${azurerm_notification_hub.test.name}" - namespace_name = "${azurerm_notification_hub.test.namespace_name}" - resource_group_name = "${azurerm_notification_hub.test.resource_group_name}" - location = "${azurerm_notification_hub.test.location}" + name = azurerm_notification_hub.test.name + namespace_name = azurerm_notification_hub.test.namespace_name + resource_group_name = azurerm_notification_hub.test.resource_group_name + location = azurerm_notification_hub.test.location } `, template) } diff --git a/website/docs/guides/2.0-upgrade-guide.html.markdown b/website/docs/guides/2.0-upgrade-guide.html.markdown index 3c3fc2955605..369b96dc7992 100644 --- a/website/docs/guides/2.0-upgrade-guide.html.markdown +++ b/website/docs/guides/2.0-upgrade-guide.html.markdown @@ -383,6 +383,12 @@ The `load_balancer_backend_address_pools_ids` field in the `ip_configuration` bl The `load_balancer_inbound_nat_rules_ids` field in the `ip_configuration` block will been removed. This has been replaced by the `azurerm_network_interface_nat_rule_association` resource. +## Resource: `azurerm_notification_hub_namespace` + +The deprecated `sku` block has been replaced by the `sku_name` field and will be removed. + +The `sku_name` field will become Required. + ### Resource: `azurerm_packet_capture` The `azurerm_packet_capture` resource will be deprecated in favour of a new resources `azurerm_network_packet_capture`. diff --git a/website/docs/r/notification_hub_authorization_rule.html.markdown b/website/docs/r/notification_hub_authorization_rule.html.markdown index 244bcdd91f74..5e94363fd6cd 100644 --- a/website/docs/r/notification_hub_authorization_rule.html.markdown +++ b/website/docs/r/notification_hub_authorization_rule.html.markdown @@ -24,8 +24,7 @@ resource "azurerm_notification_hub_namespace" "example" { resource_group_name = azurerm_resource_group.example.name location = azurerm_resource_group.example.location namespace_type = "NotificationHub" - - sku_name = "Free" + sku_name = "Free" } resource "azurerm_notification_hub" "example" { diff --git a/website/docs/r/notification_hub_namespace.html.markdown b/website/docs/r/notification_hub_namespace.html.markdown index 90c14d01687c..e38ed7cb2730 100644 --- a/website/docs/r/notification_hub_namespace.html.markdown +++ b/website/docs/r/notification_hub_namespace.html.markdown @@ -24,8 +24,7 @@ resource "azurerm_notification_hub_namespace" "example" { resource_group_name = azurerm_resource_group.example.name location = azurerm_resource_group.example.location namespace_type = "NotificationHub" - - sku_name = "Free" + sku_name = "Free" } ``` @@ -41,18 +40,10 @@ The following arguments are supported: * `namespace_type` - (Required) The Type of Namespace - possible values are `Messaging` or `NotificationHub`. Changing this forces a new resource to be created. -* `sku` - (Optional **Deprecated**)) A `sku` block as described below. - -* `sku_name` - (Optional) The name of the SKU to use for this Notification Hub Namespace. Possible values are `Free`, `Basic` or `Standard`. Changing this forces a new resource to be created. +* `sku_name` - (Required) The name of the SKU to use for this Notification Hub Namespace. Possible values are `Free`, `Basic` or `Standard`. Changing this forces a new resource to be created. * `enabled` - (Optional) Is this Notification Hub Namespace enabled? Defaults to `true`. ----- - -A `sku` block contains: - -* `name` - (Required) The name of the SKU to use for this Notification Hub Namespace. Possible values are `Free`, `Basic` or `Standard`. Changing this forces a new resource to be created. - ## Attributes Reference The following attributes are exported: