Skip to content

Commit

Permalink
export query endpoint (#23629)
Browse files Browse the repository at this point in the history
  • Loading branch information
teowa authored Oct 20, 2023
1 parent a543b5c commit dbf1097
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 1 deletion.
12 changes: 11 additions & 1 deletion internal/services/monitor/monitor_workspace_resource.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"`
Expand Down Expand Up @@ -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 {
Expand Down Expand Up @@ -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
}
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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(),
Expand Down
2 changes: 2 additions & 0 deletions website/docs/r/monitor_workspace.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down

0 comments on commit dbf1097

Please sign in to comment.