diff --git a/internal/services/monitor/monitor_workspace_resource.go b/internal/services/monitor/monitor_workspace_resource.go index 5386892a62ed..d4fb418fd7fe 100644 --- a/internal/services/monitor/monitor_workspace_resource.go +++ b/internal/services/monitor/monitor_workspace_resource.go @@ -21,6 +21,7 @@ import ( type WorkspaceResourceModel struct { Name string `tfschema:"name"` ResourceGroupName string `tfschema:"resource_group_name"` + QueryEndpoint string `tfschema:"query_endpoint"` PublicNetworkAccessEnabled bool `tfschema:"public_network_access_enabled"` Location string `tfschema:"location"` Tags map[string]string `tfschema:"tags"` @@ -66,7 +67,12 @@ func (r WorkspaceResource) Arguments() map[string]*pluginsdk.Schema { } func (r WorkspaceResource) Attributes() map[string]*pluginsdk.Schema { - return map[string]*pluginsdk.Schema{} + return map[string]*pluginsdk.Schema{ + "query_endpoint": { + Type: pluginsdk.TypeString, + Computed: true, + }, + } } func (r WorkspaceResource) Create() sdk.ResourceFunc { @@ -200,6 +206,10 @@ func (r WorkspaceResource) Read() sdk.ResourceFunc { publicNetworkAccess = azuremonitorworkspaces.PublicNetworkAccessEnabled == *properties.PublicNetworkAccess } state.PublicNetworkAccessEnabled = publicNetworkAccess + + if properties.Metrics != nil && properties.Metrics.PrometheusQueryEndpoint != nil { + state.QueryEndpoint = *properties.Metrics.PrometheusQueryEndpoint + } } } diff --git a/internal/services/monitor/monitor_workspace_resource_test.go b/internal/services/monitor/monitor_workspace_resource_test.go index 6a55c0e71d2c..ebc1d09ef1fa 100644 --- a/internal/services/monitor/monitor_workspace_resource_test.go +++ b/internal/services/monitor/monitor_workspace_resource_test.go @@ -27,6 +27,7 @@ func TestMonitorWorkspace_basic(t *testing.T) { Config: r.basic(data), Check: acceptance.ComposeTestCheckFunc( check.That(data.ResourceName).ExistsInAzure(r), + check.That(data.ResourceName).Key("query_endpoint").IsNotEmpty(), ), }, data.ImportStep(), diff --git a/website/docs/r/monitor_workspace.html.markdown b/website/docs/r/monitor_workspace.html.markdown index bd870697b14f..d906f07a400a 100644 --- a/website/docs/r/monitor_workspace.html.markdown +++ b/website/docs/r/monitor_workspace.html.markdown @@ -48,6 +48,8 @@ In addition to the Arguments listed above - the following Attributes are exporte * `id` - The ID of the Azure Monitor Workspace. +* `query_endpoint` - The query endpoint for the Azure Monitor Workspace. + ## Timeouts The `timeouts` block allows you to specify [timeouts](https://www.terraform.io/docs/configuration/resources.html#timeouts) for certain actions: