From ee293883a506d677de4b44e66d32f223a8c72a8c Mon Sep 17 00:00:00 2001 From: neil-yechenwei Date: Fri, 5 Jun 2020 15:15:11 +0800 Subject: [PATCH 1/3] Fix compatibility issue while parsing resource id for event hub auth rule --- .../eventhub_namespace_authorization_rule_resource.go | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/azurerm/internal/services/eventhub/eventhub_namespace_authorization_rule_resource.go b/azurerm/internal/services/eventhub/eventhub_namespace_authorization_rule_resource.go index e75a340e7fa2..2a94e6ed0063 100644 --- a/azurerm/internal/services/eventhub/eventhub_namespace_authorization_rule_resource.go +++ b/azurerm/internal/services/eventhub/eventhub_namespace_authorization_rule_resource.go @@ -120,6 +120,9 @@ func resourceArmEventHubNamespaceAuthorizationRuleRead(d *schema.ResourceData, m } name := id.Path["authorizationRules"] + if name == "" { + name = id.Path["AuthorizationRules"] + } resourceGroup := id.ResourceGroup namespaceName := id.Path["namespaces"] @@ -169,6 +172,9 @@ func resourceArmEventHubNamespaceAuthorizationRuleDelete(d *schema.ResourceData, } name := id.Path["authorizationRules"] + if name == "" { + name = id.Path["AuthorizationRules"] + } resourceGroup := id.ResourceGroup namespaceName := id.Path["namespaces"] From daa3526190eeb9e06f91b3d00b6df57b04357b57 Mon Sep 17 00:00:00 2001 From: neil-yechenwei Date: Fri, 5 Jun 2020 17:24:09 +0800 Subject: [PATCH 2/3] Update code --- .../eventhub/eventhub_namespace_authorization_rule_resource.go | 3 +++ 1 file changed, 3 insertions(+) diff --git a/azurerm/internal/services/eventhub/eventhub_namespace_authorization_rule_resource.go b/azurerm/internal/services/eventhub/eventhub_namespace_authorization_rule_resource.go index 2a94e6ed0063..35ae211cb109 100644 --- a/azurerm/internal/services/eventhub/eventhub_namespace_authorization_rule_resource.go +++ b/azurerm/internal/services/eventhub/eventhub_namespace_authorization_rule_resource.go @@ -172,6 +172,9 @@ func resourceArmEventHubNamespaceAuthorizationRuleDelete(d *schema.ResourceData, } name := id.Path["authorizationRules"] + // The resource id is built with `authorizationRules` in newer API version. However, it is built with `AuthorizationRules` in older API version. + // Hence currently it fails to parse resource id with `AuthorizationRules` for older one. + // So it has to be compatible with both new version and old version. if name == "" { name = id.Path["AuthorizationRules"] } From 8cab3d11171eb113224527b1038d49271750e422 Mon Sep 17 00:00:00 2001 From: neil-yechenwei Date: Fri, 5 Jun 2020 20:31:08 +0800 Subject: [PATCH 3/3] Update code --- .../eventhub_namespace_authorization_rule_resource.go | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/azurerm/internal/services/eventhub/eventhub_namespace_authorization_rule_resource.go b/azurerm/internal/services/eventhub/eventhub_namespace_authorization_rule_resource.go index 35ae211cb109..2a23e4c780a9 100644 --- a/azurerm/internal/services/eventhub/eventhub_namespace_authorization_rule_resource.go +++ b/azurerm/internal/services/eventhub/eventhub_namespace_authorization_rule_resource.go @@ -120,6 +120,9 @@ func resourceArmEventHubNamespaceAuthorizationRuleRead(d *schema.ResourceData, m } name := id.Path["authorizationRules"] + // The resource id is made of `authorizationRules` in newer API version. However, it is made of `AuthorizationRules` in older API version. + // Hence currently it would fail to parse resource id with `AuthorizationRules` for older one. + // So here it has to be compatible with both new version and old version. if name == "" { name = id.Path["AuthorizationRules"] } @@ -172,9 +175,9 @@ func resourceArmEventHubNamespaceAuthorizationRuleDelete(d *schema.ResourceData, } name := id.Path["authorizationRules"] - // The resource id is built with `authorizationRules` in newer API version. However, it is built with `AuthorizationRules` in older API version. - // Hence currently it fails to parse resource id with `AuthorizationRules` for older one. - // So it has to be compatible with both new version and old version. + // The resource id is made of `authorizationRules` in newer API version. However, it is made of `AuthorizationRules` in older API version. + // Hence currently it would fail to parse resource id with `AuthorizationRules` for older one. + // So here it has to be compatible with both new version and old version. if name == "" { name = id.Path["AuthorizationRules"] }