From 4dc55e3697a78c79544a476afa4139957af2f833 Mon Sep 17 00:00:00 2001 From: Noel Jones Date: Sun, 9 Jan 2022 17:26:45 +0000 Subject: [PATCH 1/4] Add managed_resources block to purview_account 14814 Signed-off-by: Noel Jones --- .../purview/purview_account_resource.go | 51 +++++++++++++++++++ website/docs/r/purview_account.html.markdown | 12 +++++ 2 files changed, 63 insertions(+) diff --git a/internal/services/purview/purview_account_resource.go b/internal/services/purview/purview_account_resource.go index 216c6ee86175..289443d6bb97 100644 --- a/internal/services/purview/purview_account_resource.go +++ b/internal/services/purview/purview_account_resource.go @@ -94,6 +94,27 @@ func resourcePurviewAccount() *pluginsdk.Resource { }, }, + "managed_resources": { + Type: pluginsdk.TypeList, + Computed: true, + Elem: &pluginsdk.Resource{ + Schema: map[string]*pluginsdk.Schema{ + "resource_group": { + Type: pluginsdk.TypeString, + Computed: true, + }, + "storage_account": { + Type: pluginsdk.TypeString, + Computed: true, + }, + "event_hub_namespace": { + Type: pluginsdk.TypeString, + Computed: true, + }, + }, + }, + }, + "catalog_endpoint": { Type: pluginsdk.TypeString, Computed: true, @@ -209,6 +230,10 @@ func resourcePurviewAccountRead(d *pluginsdk.ResourceData, meta interface{}) err return fmt.Errorf("flattening `identity`: %+v", err) } + if err := d.Set("managed_resources", flattenPurviewAccountManagedResources(resp.ManagedResources)); err != nil { + return fmt.Errorf("flattening `managed_resources`: %+v", err) + } + if props := resp.AccountProperties; props != nil { d.Set("public_network_enabled", props.PublicNetworkAccess == purview.PublicNetworkAccessEnabled) @@ -278,3 +303,29 @@ func flattenPurviewAccountIdentity(identity *purview.Identity) interface{} { }, } } + +func flattenPurviewAccountManagedResources(managedResources *purview.AccountPropertiesManagedResources) interface{} { + if managedResources == nil { + return make([]interface{}, 0) + } + + resourceGroup := "" + if managedResources.ResourceGroup != nil { + resourceGroup = *managedResources.ResourceGroup + } + storageAccount := "" + if managedResources.StorageAccount != nil { + storageAccount = *managedResources.StorageAccount + } + eventHubNamespace := "" + if managedResources.EventHubNamespace != nil { + eventHubNamespace = *managedResources.EventHubNamespace + } + return []interface{}{ + map[string]interface{}{ + "resource_group": resourceGroup, + "storage_account": storageAccount, + "event_hub_namespace": eventHubNamespace, + }, + } +} diff --git a/website/docs/r/purview_account.html.markdown b/website/docs/r/purview_account.html.markdown index 496f39c86ac8..9bc1ef1b66fc 100644 --- a/website/docs/r/purview_account.html.markdown +++ b/website/docs/r/purview_account.html.markdown @@ -63,6 +63,8 @@ In addition to the Arguments listed above - the following Attributes are exporte * `identity` - A `identity` block as defined below. +* `managed_resources` - A `managed_resources` block as defined below. + --- A `identity` block exports the following: @@ -73,6 +75,16 @@ A `identity` block exports the following: * `type` - The type of Managed Identity assigned to this Purview Account. +--- + +A `managed_resources` block exports the following: + +* `event_hub_namespace` - The ID of the managed event hub namespace. + +* `resource_group` - The ID of the managed resource group. + +* `storage_account` - The ID of the managed storage account. + ## Timeouts The `timeouts` block allows you to specify [timeouts](https://www.terraform.io/docs/configuration/resources.html#timeouts) for certain actions: From ef5e1ba4bed32bc94c5b1d63181a4f2078522bbd Mon Sep 17 00:00:00 2001 From: Noel Jones <31277326+Noel-Jones@users.noreply.github.com> Date: Thu, 13 Jan 2022 08:58:39 +0000 Subject: [PATCH 2/4] Update internal/services/purview/purview_account_resource.go Co-authored-by: Tom Harvey --- internal/services/purview/purview_account_resource.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/internal/services/purview/purview_account_resource.go b/internal/services/purview/purview_account_resource.go index 289443d6bb97..bcde893af881 100644 --- a/internal/services/purview/purview_account_resource.go +++ b/internal/services/purview/purview_account_resource.go @@ -99,15 +99,15 @@ func resourcePurviewAccount() *pluginsdk.Resource { Computed: true, Elem: &pluginsdk.Resource{ Schema: map[string]*pluginsdk.Schema{ - "resource_group": { + "resource_group_id": { Type: pluginsdk.TypeString, Computed: true, }, - "storage_account": { + "storage_account_id": { Type: pluginsdk.TypeString, Computed: true, }, - "event_hub_namespace": { + "event_hub_namespace_id": { Type: pluginsdk.TypeString, Computed: true, }, From 09cfeb0545323566568057a23a8013bdf3b7fc6c Mon Sep 17 00:00:00 2001 From: Noel Jones <31277326+Noel-Jones@users.noreply.github.com> Date: Thu, 13 Jan 2022 09:00:17 +0000 Subject: [PATCH 3/4] Update internal/services/purview/purview_account_resource.go Co-authored-by: Tom Harvey --- internal/services/purview/purview_account_resource.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/internal/services/purview/purview_account_resource.go b/internal/services/purview/purview_account_resource.go index bcde893af881..26b06f8aadbb 100644 --- a/internal/services/purview/purview_account_resource.go +++ b/internal/services/purview/purview_account_resource.go @@ -323,9 +323,9 @@ func flattenPurviewAccountManagedResources(managedResources *purview.AccountProp } return []interface{}{ map[string]interface{}{ - "resource_group": resourceGroup, - "storage_account": storageAccount, - "event_hub_namespace": eventHubNamespace, + "resource_group_id": resourceGroup, + "storage_account_id": storageAccount, + "event_hub_namespace_id": eventHubNamespace, }, } } From f125ed128b53ac100ebadedf3b75e2eed3939cc7 Mon Sep 17 00:00:00 2001 From: Noel Jones <31277326+Noel-Jones@users.noreply.github.com> Date: Thu, 13 Jan 2022 09:00:35 +0000 Subject: [PATCH 4/4] Update website/docs/r/purview_account.html.markdown Co-authored-by: Tom Harvey --- website/docs/r/purview_account.html.markdown | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/website/docs/r/purview_account.html.markdown b/website/docs/r/purview_account.html.markdown index 9bc1ef1b66fc..4f668b912e49 100644 --- a/website/docs/r/purview_account.html.markdown +++ b/website/docs/r/purview_account.html.markdown @@ -79,11 +79,11 @@ A `identity` block exports the following: A `managed_resources` block exports the following: -* `event_hub_namespace` - The ID of the managed event hub namespace. +* `event_hub_namespace_id` - The ID of the managed event hub namespace. -* `resource_group` - The ID of the managed resource group. +* `resource_group_id` - The ID of the managed resource group. -* `storage_account` - The ID of the managed storage account. +* `storage_account_id` - The ID of the managed storage account. ## Timeouts