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: