Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add managed_resources block to purview_account 14814 #14865

Merged
merged 5 commits into from
Jan 13, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
51 changes: 51 additions & 0 deletions internal/services/purview/purview_account_resource.go
Original file line number Diff line number Diff line change
Expand Up @@ -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_id": {
Type: pluginsdk.TypeString,
Computed: true,
},
"storage_account_id": {
Type: pluginsdk.TypeString,
Computed: true,
},
"event_hub_namespace_id": {
Type: pluginsdk.TypeString,
Computed: true,
},
},
},
},

"catalog_endpoint": {
Type: pluginsdk.TypeString,
Computed: true,
Expand Down Expand Up @@ -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)

Expand Down Expand Up @@ -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_id": resourceGroup,
"storage_account_id": storageAccount,
"event_hub_namespace_id": eventHubNamespace,
},
}
}
12 changes: 12 additions & 0 deletions website/docs/r/purview_account.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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_id` - The ID of the managed event hub namespace.

* `resource_group_id` - The ID of the managed resource group.

* `storage_account_id` - 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:
Expand Down