From 06d8c8f379abdda6fa70b542a667817d9dcd7f2e Mon Sep 17 00:00:00 2001 From: Mark Dordoy Date: Tue, 28 Apr 2020 16:26:06 +0100 Subject: [PATCH 1/5] Removed forceNew flag from tags --- azuread/resource_service_principal.go | 1 - 1 file changed, 1 deletion(-) diff --git a/azuread/resource_service_principal.go b/azuread/resource_service_principal.go index 519d24cbea..85a2aa1705 100644 --- a/azuread/resource_service_principal.go +++ b/azuread/resource_service_principal.go @@ -55,7 +55,6 @@ func resourceServicePrincipal() *schema.Resource { "tags": { Type: schema.TypeSet, Optional: true, - ForceNew: true, Set: schema.HashString, Elem: &schema.Schema{ Type: schema.TypeString, From abe8dff5f0bf59c9ca6dcb4f6b16709297a1b990 Mon Sep 17 00:00:00 2001 From: Mark Dordoy Date: Tue, 28 Apr 2020 16:52:01 +0100 Subject: [PATCH 2/5] Update resource_service_principal.go --- azuread/resource_service_principal.go | 1 + 1 file changed, 1 insertion(+) diff --git a/azuread/resource_service_principal.go b/azuread/resource_service_principal.go index 85a2aa1705..f9c3b8f535 100644 --- a/azuread/resource_service_principal.go +++ b/azuread/resource_service_principal.go @@ -64,6 +64,7 @@ func resourceServicePrincipal() *schema.Resource { } } + func resourceServicePrincipalCreate(d *schema.ResourceData, meta interface{}) error { client := meta.(*ArmClient).servicePrincipalsClient ctx := meta.(*ArmClient).StopContext From ac774112e2439b4b2b2e024a07a66bc47c50c5d6 Mon Sep 17 00:00:00 2001 From: Mark Dordoy Date: Tue, 28 Apr 2020 16:52:15 +0100 Subject: [PATCH 3/5] Update resource_service_principal.go --- azuread/resource_service_principal.go | 1 - 1 file changed, 1 deletion(-) diff --git a/azuread/resource_service_principal.go b/azuread/resource_service_principal.go index f9c3b8f535..0ec6928bee 100644 --- a/azuread/resource_service_principal.go +++ b/azuread/resource_service_principal.go @@ -16,7 +16,6 @@ import ( ) const servicePrincipalResourceName = "azuread_service_principal" - func resourceServicePrincipal() *schema.Resource { return &schema.Resource{ Create: resourceServicePrincipalCreate, From cc6e00fa26c0c240b2d5f2892ebf80efced59f33 Mon Sep 17 00:00:00 2001 From: Mark Dordoy Date: Tue, 28 Apr 2020 16:52:45 +0100 Subject: [PATCH 4/5] Update resource_service_principal.go --- azuread/resource_service_principal.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/azuread/resource_service_principal.go b/azuread/resource_service_principal.go index 0ec6928bee..85a2aa1705 100644 --- a/azuread/resource_service_principal.go +++ b/azuread/resource_service_principal.go @@ -16,6 +16,7 @@ import ( ) const servicePrincipalResourceName = "azuread_service_principal" + func resourceServicePrincipal() *schema.Resource { return &schema.Resource{ Create: resourceServicePrincipalCreate, @@ -63,7 +64,6 @@ func resourceServicePrincipal() *schema.Resource { } } - func resourceServicePrincipalCreate(d *schema.ResourceData, meta interface{}) error { client := meta.(*ArmClient).servicePrincipalsClient ctx := meta.(*ArmClient).StopContext From d58717da0671ed73d1175ae973e2b5c19de5ed9d Mon Sep 17 00:00:00 2001 From: kt Date: Wed, 13 May 2020 23:21:44 -0700 Subject: [PATCH 5/5] update tags on change --- azuread/resource_service_principal.go | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/azuread/resource_service_principal.go b/azuread/resource_service_principal.go index 85a2aa1705..c2d09d937f 100644 --- a/azuread/resource_service_principal.go +++ b/azuread/resource_service_principal.go @@ -114,6 +114,15 @@ func resourceServicePrincipalUpdate(d *schema.ResourceData, meta interface{}) er properties.AppRoleAssignmentRequired = p.Bool(d.Get("app_role_assignment_required").(bool)) } + if d.HasChange("tags") { + if v, ok := d.GetOk("tags"); ok { + properties.Tags = tf.ExpandStringSlicePtr(v.(*schema.Set).List()) + } else { + empty := []string{} // clear tags with empty array + properties.Tags = &empty + } + } + if _, err := client.Update(ctx, d.Id(), properties); err != nil { return fmt.Errorf("Error patching Azure AD Service Principal with ID %q: %+v", d.Id(), err) }