From 54ee9e39225776ae612c4793e44ca10e9c1a23f8 Mon Sep 17 00:00:00 2001 From: Vladimir Lazarenko Date: Mon, 25 Oct 2021 14:12:52 +0200 Subject: [PATCH 1/7] `azurerm_synapse_workspace_key`: Fix argument name and docs Fixes #13864 --- internal/services/synapse/synapse_workspace_key_resource.go | 6 +++--- website/docs/r/synapse_workspace_keys.html.markdown | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/internal/services/synapse/synapse_workspace_key_resource.go b/internal/services/synapse/synapse_workspace_key_resource.go index ea1da7bedc2e..4a82bd0bbb44 100644 --- a/internal/services/synapse/synapse_workspace_key_resource.go +++ b/internal/services/synapse/synapse_workspace_key_resource.go @@ -43,7 +43,7 @@ func resourceSynapseWorkspaceKey() *pluginsdk.Resource { ValidateFunc: validate.WorkspaceID, }, - "cusomter_managed_key_name": { + "customer_managed_key_name": { Type: pluginsdk.TypeString, Required: true, }, @@ -75,7 +75,7 @@ func resourceSynapseWorkspaceKeysCreateUpdate(d *pluginsdk.ResourceData, meta in } key := d.Get("customer_managed_key_versionless_id") - keyName := d.Get("cusomter_managed_key_name").(string) + keyName := d.Get("customer_managed_key_name").(string) isActiveCMK := d.Get("active").(bool) log.Printf("[INFO] Is active CMK: %t", isActiveCMK) @@ -134,7 +134,7 @@ func resourceSynapseWorkspaceKeyRead(d *pluginsdk.ResourceData, meta interface{} // Set the properties d.Set("synapse_workspace_id", workspaceID.ID()) d.Set("active", resp.KeyProperties.IsActiveCMK) - d.Set("cusomter_managed_key_name", id.KeyName) + d.Set("customer_managed_key_name", id.KeyName) d.Set("customer_managed_key_versionless_id", resp.KeyProperties.KeyVaultURL) return nil diff --git a/website/docs/r/synapse_workspace_keys.html.markdown b/website/docs/r/synapse_workspace_keys.html.markdown index d194a76c7256..a198b47eb634 100644 --- a/website/docs/r/synapse_workspace_keys.html.markdown +++ b/website/docs/r/synapse_workspace_keys.html.markdown @@ -1,7 +1,7 @@ --- subcategory: "Synapse" layout: "azurerm" -page_title: "Azure Resource Manager: azurerm_synapse_workspace_keys" +page_title: "Azure Resource Manager: azurerm_synapse_workspace_key" description: |- Manages Synapse Workspace Keys --- @@ -116,7 +116,7 @@ resource "azurerm_synapse_workspace_key" "example" { The following arguments are supported: -* `key_name` - (Required) Specifies the name of the workspace key. Should match the name of the key in the synapse workspace. +* `customer_managed_key_name` - (Required) Specifies the name of the workspace key. Should match the name of the key in the synapse workspace. * `customer_managed_key_versionless_id` - (Required) The Azure Key Vault Key Versionless ID to be used as the Customer Managed Key (CMK) for double encryption From 581f170e7b1b717de773ecb16e62dfb84d9c2bc3 Mon Sep 17 00:00:00 2001 From: Vladimir Lazarenko Date: Mon, 25 Oct 2021 15:51:29 +0200 Subject: [PATCH 2/7] Ingore linting error --- internal/acceptance/testcase.go | 1 + 1 file changed, 1 insertion(+) diff --git a/internal/acceptance/testcase.go b/internal/acceptance/testcase.go index 06c5ed7b4321..3ddb0e492c5f 100644 --- a/internal/acceptance/testcase.go +++ b/internal/acceptance/testcase.go @@ -36,6 +36,7 @@ func (td TestData) DataSourceTestInSequence(t *testing.T, steps []TestStep) { td.runAcceptanceSequentialTest(t, testCase) } +// lintignore:AT001 func (td TestData) ResourceTest(t *testing.T, testResource types.TestResource, steps []TestStep) { testCase := resource.TestCase{ PreCheck: func() { PreCheck(t) }, From 4e01c79fd628c8b72fe8e15b55a62ca4717ff28a Mon Sep 17 00:00:00 2001 From: Vladimir Lazarenko Date: Wed, 27 Oct 2021 10:13:07 +0200 Subject: [PATCH 3/7] wip --- .../synapse/synapse_workspace_key_resource.go | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/internal/services/synapse/synapse_workspace_key_resource.go b/internal/services/synapse/synapse_workspace_key_resource.go index 4a82bd0bbb44..0de0c9783dde 100644 --- a/internal/services/synapse/synapse_workspace_key_resource.go +++ b/internal/services/synapse/synapse_workspace_key_resource.go @@ -43,9 +43,17 @@ func resourceSynapseWorkspaceKey() *pluginsdk.Resource { ValidateFunc: validate.WorkspaceID, }, + "cusomter_managed_key_name": { + Type: pluginsdk.TypeString, + Required: true, + Deprecated: "As this property name contained a typo originally, please switch to using 'customer_managed_key_name' instead.", + ConflictsWith: []string{"customer_managed_key_name"}, + }, + "customer_managed_key_name": { Type: pluginsdk.TypeString, Required: true, + ConflictsWith: []string{"cusomter_managed_key_name"}, }, "customer_managed_key_versionless_id": { @@ -76,6 +84,7 @@ func resourceSynapseWorkspaceKeysCreateUpdate(d *pluginsdk.ResourceData, meta in key := d.Get("customer_managed_key_versionless_id") keyName := d.Get("customer_managed_key_name").(string) + keyNameTypoed := d.Get("cusomter_managed_key_name").(string) isActiveCMK := d.Get("active").(bool) log.Printf("[INFO] Is active CMK: %t", isActiveCMK) @@ -89,7 +98,7 @@ func resourceSynapseWorkspaceKeysCreateUpdate(d *pluginsdk.ResourceData, meta in KeyProperties: &keyProperties, } - keyresult, err := client.CreateOrUpdate(ctx, workspaceId.ResourceGroup, workspaceId.Name, keyName, synapseKey) + keyresult, err := client.CreateOrUpdate(ctx, workspaceId.ResourceGroup, workspaceId.Name, (keyName, synapseKey) if err != nil { return fmt.Errorf("creating Synapse Workspace Key %q (Workspace %q): %+v", workspaceId.Name, workspaceId.Name, err) } From e03eb71eeb784b97f5c47d2925a601cd1298a79e Mon Sep 17 00:00:00 2001 From: Vladimir Lazarenko Date: Thu, 28 Oct 2021 12:59:28 +0200 Subject: [PATCH 4/7] Sigh... --- .../synapse/synapse_workspace_key_resource.go | 24 +++++++++++++++---- 1 file changed, 20 insertions(+), 4 deletions(-) diff --git a/internal/services/synapse/synapse_workspace_key_resource.go b/internal/services/synapse/synapse_workspace_key_resource.go index 0de0c9783dde..a9b944e5998f 100644 --- a/internal/services/synapse/synapse_workspace_key_resource.go +++ b/internal/services/synapse/synapse_workspace_key_resource.go @@ -45,15 +45,23 @@ func resourceSynapseWorkspaceKey() *pluginsdk.Resource { "cusomter_managed_key_name": { Type: pluginsdk.TypeString, - Required: true, + Optional: true, Deprecated: "As this property name contained a typo originally, please switch to using 'customer_managed_key_name' instead.", + AtLeastOneOf: []string{ + "cusomter_managed_key_name", + "customer_managed_key_name", + }, ConflictsWith: []string{"customer_managed_key_name"}, }, "customer_managed_key_name": { - Type: pluginsdk.TypeString, - Required: true, + Type: pluginsdk.TypeString, + Optional: true, ConflictsWith: []string{"cusomter_managed_key_name"}, + AtLeastOneOf: []string{ + "cusomter_managed_key_name", + "customer_managed_key_name", + }, }, "customer_managed_key_versionless_id": { @@ -98,7 +106,14 @@ func resourceSynapseWorkspaceKeysCreateUpdate(d *pluginsdk.ResourceData, meta in KeyProperties: &keyProperties, } - keyresult, err := client.CreateOrUpdate(ctx, workspaceId.ResourceGroup, workspaceId.Name, (keyName, synapseKey) + actualKeyName := "" + if keyName != "" { + actualKeyName = keyName + } else { + actualKeyName = keyNameTypoed + } + + keyresult, err := client.CreateOrUpdate(ctx, workspaceId.ResourceGroup, workspaceId.Name, actualKeyName, synapseKey) if err != nil { return fmt.Errorf("creating Synapse Workspace Key %q (Workspace %q): %+v", workspaceId.Name, workspaceId.Name, err) } @@ -144,6 +159,7 @@ func resourceSynapseWorkspaceKeyRead(d *pluginsdk.ResourceData, meta interface{} d.Set("synapse_workspace_id", workspaceID.ID()) d.Set("active", resp.KeyProperties.IsActiveCMK) d.Set("customer_managed_key_name", id.KeyName) + d.Set("cusomter_managed_key_name", id.KeyName) d.Set("customer_managed_key_versionless_id", resp.KeyProperties.KeyVaultURL) return nil From cc7282744ad26a740f91fb745001319d9114a544 Mon Sep 17 00:00:00 2001 From: kt Date: Thu, 28 Oct 2021 13:15:19 -0700 Subject: [PATCH 5/7] Update synapse_workspace_key_resource.go --- internal/services/synapse/synapse_workspace_key_resource.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/internal/services/synapse/synapse_workspace_key_resource.go b/internal/services/synapse/synapse_workspace_key_resource.go index a9b944e5998f..feb8eb5cf7c7 100644 --- a/internal/services/synapse/synapse_workspace_key_resource.go +++ b/internal/services/synapse/synapse_workspace_key_resource.go @@ -124,14 +124,14 @@ func resourceSynapseWorkspaceKeysCreateUpdate(d *pluginsdk.ResourceData, meta in // If the state of the key in the response (from Azure) is not equal to the desired target state (from plan/config), we'll wait until that change is complete if isActiveCMK != *keyresult.KeyProperties.IsActiveCMK { - updateWait := synapseKeysWaitForStateChange(ctx, meta, d.Timeout(pluginsdk.TimeoutUpdate), workspaceId.ResourceGroup, workspaceId.Name, keyName, strconv.FormatBool(*keyresult.KeyProperties.IsActiveCMK), strconv.FormatBool(isActiveCMK)) + updateWait := synapseKeysWaitForStateChange(ctx, meta, d.Timeout(pluginsdk.TimeoutUpdate), workspaceId.ResourceGroup, workspaceId.Name, actualKeyName, strconv.FormatBool(*keyresult.KeyProperties.IsActiveCMK), strconv.FormatBool(isActiveCMK)) if _, err := updateWait.WaitForStateContext(ctx); err != nil { - return fmt.Errorf("waiting for Synapse Keys to finish updating '%q' (Workspace Group %q): %v", keyName, workspaceId.Name, err) + return fmt.Errorf("waiting for Synapse Keys to finish updating '%q' (Workspace Group %q): %v", actualKeyName, workspaceId.Name, err) } } - id := parse.NewWorkspaceKeysID(workspaceId.SubscriptionId, workspaceId.ResourceGroup, workspaceId.Name, keyName) + id := parse.NewWorkspaceKeysID(workspaceId.SubscriptionId, workspaceId.ResourceGroup, workspaceId.Name, actualKeyName) d.SetId(id.ID()) return resourceSynapseWorkspaceKeyRead(d, meta) From 1573a98f6070dbd20c2b4d656a9b6f1ac859a394 Mon Sep 17 00:00:00 2001 From: kt Date: Fri, 29 Oct 2021 10:02:26 -0700 Subject: [PATCH 6/7] Update synapse_workspace_key_resource.go --- internal/services/synapse/synapse_workspace_key_resource.go | 2 ++ 1 file changed, 2 insertions(+) diff --git a/internal/services/synapse/synapse_workspace_key_resource.go b/internal/services/synapse/synapse_workspace_key_resource.go index feb8eb5cf7c7..6ac2a567c929 100644 --- a/internal/services/synapse/synapse_workspace_key_resource.go +++ b/internal/services/synapse/synapse_workspace_key_resource.go @@ -46,6 +46,7 @@ func resourceSynapseWorkspaceKey() *pluginsdk.Resource { "cusomter_managed_key_name": { Type: pluginsdk.TypeString, Optional: true, + Computed: true, Deprecated: "As this property name contained a typo originally, please switch to using 'customer_managed_key_name' instead.", AtLeastOneOf: []string{ "cusomter_managed_key_name", @@ -57,6 +58,7 @@ func resourceSynapseWorkspaceKey() *pluginsdk.Resource { "customer_managed_key_name": { Type: pluginsdk.TypeString, Optional: true, + Computed: true, ConflictsWith: []string{"cusomter_managed_key_name"}, AtLeastOneOf: []string{ "cusomter_managed_key_name", From 8e2f9cd08ade77d4b89b3ab3ba59a3be67de3c29 Mon Sep 17 00:00:00 2001 From: kt Date: Fri, 29 Oct 2021 10:39:00 -0700 Subject: [PATCH 7/7] Update synapse_workspace_key_resource.go --- internal/services/synapse/synapse_workspace_key_resource.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/internal/services/synapse/synapse_workspace_key_resource.go b/internal/services/synapse/synapse_workspace_key_resource.go index 6ac2a567c929..3735432ed276 100644 --- a/internal/services/synapse/synapse_workspace_key_resource.go +++ b/internal/services/synapse/synapse_workspace_key_resource.go @@ -58,7 +58,7 @@ func resourceSynapseWorkspaceKey() *pluginsdk.Resource { "customer_managed_key_name": { Type: pluginsdk.TypeString, Optional: true, - Computed: true, + Computed: true, ConflictsWith: []string{"cusomter_managed_key_name"}, AtLeastOneOf: []string{ "cusomter_managed_key_name",