From 117c7d9a79a16ea7e59505bf7fff548975e14c6d Mon Sep 17 00:00:00 2001 From: Konstantin Kosinsky Date: Mon, 7 Jun 2021 14:12:31 -0700 Subject: [PATCH] Add identity attribute to the azurerm_synapse_workspace data source --- .../synapse/synapse_workspace_data_source.go | 26 +++++++++++++++++++ .../synapse_workspace_data_source_test.go | 2 ++ .../docs/d/synapse_workspace.html.markdown | 12 +++++++++ 3 files changed, 40 insertions(+) diff --git a/azurerm/internal/services/synapse/synapse_workspace_data_source.go b/azurerm/internal/services/synapse/synapse_workspace_data_source.go index c3f90b1b0100..377f28348780 100644 --- a/azurerm/internal/services/synapse/synapse_workspace_data_source.go +++ b/azurerm/internal/services/synapse/synapse_workspace_data_source.go @@ -41,6 +41,29 @@ func dataSourceSynapseWorkspace() *pluginsdk.Resource { }, }, + "identity": { + Type: pluginsdk.TypeList, + Computed: true, + Elem: &pluginsdk.Resource{ + Schema: map[string]*pluginsdk.Schema{ + "type": { + Type: pluginsdk.TypeString, + Computed: true, + }, + + "principal_id": { + Type: pluginsdk.TypeString, + Computed: true, + }, + + "tenant_id": { + Type: pluginsdk.TypeString, + Computed: true, + }, + }, + }, + }, + "tags": tags.SchemaDataSource(), }, } @@ -72,5 +95,8 @@ func dataSourceSynapseWorkspaceRead(d *pluginsdk.ResourceData, meta interface{}) if props := resp.WorkspaceProperties; props != nil { d.Set("connectivity_endpoints", utils.FlattenMapStringPtrString(props.ConnectivityEndpoints)) } + if err := d.Set("identity", flattenArmWorkspaceManagedIdentity(resp.Identity)); err != nil { + return fmt.Errorf("setting `identity`: %+v", err) + } return tags.FlattenAndSet(d, resp.Tags) } diff --git a/azurerm/internal/services/synapse/synapse_workspace_data_source_test.go b/azurerm/internal/services/synapse/synapse_workspace_data_source_test.go index 2e7ba588459b..d84a208f0a84 100644 --- a/azurerm/internal/services/synapse/synapse_workspace_data_source_test.go +++ b/azurerm/internal/services/synapse/synapse_workspace_data_source_test.go @@ -20,6 +20,8 @@ func TestAccDataSourceSynapseWorkspace_basic(t *testing.T) { check.That(data.ResourceName).Key("name").Exists(), check.That(data.ResourceName).Key("resource_group_name").Exists(), check.That(data.ResourceName).Key("connectivity_endpoints.%").Exists(), + check.That(data.ResourceName).Key("identity.#").HasValue("1"), + check.That(data.ResourceName).Key("identity.0.principal_id").Exists(), ), }, }) diff --git a/website/docs/d/synapse_workspace.html.markdown b/website/docs/d/synapse_workspace.html.markdown index fa8d1dd8637d..774e4fe54bc2 100644 --- a/website/docs/d/synapse_workspace.html.markdown +++ b/website/docs/d/synapse_workspace.html.markdown @@ -43,6 +43,18 @@ the following Attributes are exported: * `tags` - A mapping of tags assigned to the resource. +* `identity` - An `identity` block as defined below, which contains the Managed Service Identity information for this Synapse Workspace. + +--- + +The `identity` block exports the following: + +* `type` - The Identity Type for the Service Principal associated with the Managed Service Identity of this Synapse Workspace. + +* `principal_id` - The Principal ID for the Service Principal associated with the Managed Service Identity of this Synapse Workspace. + +* `tenant_id` - The Tenant ID for the Service Principal associated with the Managed Service Identity of this Synapse Workspace. + ## Timeouts The `timeouts` block allows you to specify [timeouts](https://www.terraform.io/docs/configuration/resources.html#timeouts) for certain actions: