Skip to content

Commit

Permalink
add default endpoints and update docs for #24151 (#24153)
Browse files Browse the repository at this point in the history
  • Loading branch information
djryanj authored Dec 11, 2023
1 parent 654f6c3 commit 3b01a2c
Show file tree
Hide file tree
Showing 4 changed files with 86 additions and 40 deletions.
46 changes: 33 additions & 13 deletions internal/services/monitor/monitor_workspace_data_source.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,14 @@ type WorkspaceDataSource struct{}
var _ sdk.DataSource = WorkspaceDataSource{}

type WorkspaceDataSourceModel 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"`
Name string `tfschema:"name"`
ResourceGroupName string `tfschema:"resource_group_name"`
QueryEndpoint string `tfschema:"query_endpoint"`
PublicNetworkAccessEnabled bool `tfschema:"public_network_access_enabled"`
DefaultDataCollectionEndpointId string `tfschema:"default_data_collection_endpoint_id"`
DefaultDataCollectionRuleId string `tfschema:"default_data_collection_rule_id"`
Location string `tfschema:"location"`
Tags map[string]string `tfschema:"tags"`
}

func (d WorkspaceDataSource) ModelObject() interface{} {
Expand Down Expand Up @@ -63,6 +65,14 @@ func (d WorkspaceDataSource) Attributes() map[string]*pluginsdk.Schema {
Type: pluginsdk.TypeBool,
Computed: true,
},
"default_data_collection_endpoint_id": {
Type: pluginsdk.TypeString,
Computed: true,
},
"default_data_collection_rule_id": {
Type: pluginsdk.TypeString,
Computed: true,
},

"tags": commonschema.TagsDataSource(),
}
Expand Down Expand Up @@ -91,7 +101,7 @@ func (d WorkspaceDataSource) Read() sdk.ResourceFunc {
}

var enablePublicNetWorkAccess bool
var location, queryEndpoint string
var location, queryEndpoint, defaultDataCollectionEndpointId, defaultDataCollectionRuleId string
var tag map[string]string

if model := resp.Model; model != nil {
Expand All @@ -105,18 +115,28 @@ func (d WorkspaceDataSource) Read() sdk.ResourceFunc {
if props.Metrics != nil && props.Metrics.PrometheusQueryEndpoint != nil {
queryEndpoint = *props.Metrics.PrometheusQueryEndpoint
}
if props.DefaultIngestionSettings != nil {
if props.DefaultIngestionSettings.DataCollectionEndpointResourceId != nil {
defaultDataCollectionEndpointId = *props.DefaultIngestionSettings.DataCollectionEndpointResourceId
}
if props.DefaultIngestionSettings.DataCollectionRuleResourceId != nil {
defaultDataCollectionRuleId = *props.DefaultIngestionSettings.DataCollectionRuleResourceId
}
}
}
}

metadata.SetID(id)

return metadata.Encode(&WorkspaceDataSourceModel{
Location: location,
Name: id.AccountName,
PublicNetworkAccessEnabled: enablePublicNetWorkAccess,
QueryEndpoint: queryEndpoint,
ResourceGroupName: id.ResourceGroupName,
Tags: tag,
Location: location,
Name: id.AccountName,
PublicNetworkAccessEnabled: enablePublicNetWorkAccess,
QueryEndpoint: queryEndpoint,
DefaultDataCollectionEndpointId: defaultDataCollectionEndpointId,
DefaultDataCollectionRuleId: defaultDataCollectionRuleId,
ResourceGroupName: id.ResourceGroupName,
Tags: tag,
})
},
}
Expand Down
31 changes: 25 additions & 6 deletions internal/services/monitor/monitor_workspace_resource.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,14 @@ 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"`
Name string `tfschema:"name"`
ResourceGroupName string `tfschema:"resource_group_name"`
QueryEndpoint string `tfschema:"query_endpoint"`
DefaultDataCollectionEndpointId string `tfschema:"default_data_collection_endpoint_id"`
DefaultDataCollectionRuleId string `tfschema:"default_data_collection_rule_id"`
PublicNetworkAccessEnabled bool `tfschema:"public_network_access_enabled"`
Location string `tfschema:"location"`
Tags map[string]string `tfschema:"tags"`
}

type WorkspaceResource struct{}
Expand Down Expand Up @@ -72,6 +74,14 @@ func (r WorkspaceResource) Attributes() map[string]*pluginsdk.Schema {
Type: pluginsdk.TypeString,
Computed: true,
},
"default_data_collection_endpoint_id": {
Type: pluginsdk.TypeString,
Computed: true,
},
"default_data_collection_rule_id": {
Type: pluginsdk.TypeString,
Computed: true,
},
}
}

Expand Down Expand Up @@ -210,6 +220,15 @@ func (r WorkspaceResource) Read() sdk.ResourceFunc {
if properties.Metrics != nil && properties.Metrics.PrometheusQueryEndpoint != nil {
state.QueryEndpoint = *properties.Metrics.PrometheusQueryEndpoint
}

if properties.DefaultIngestionSettings != nil {
if properties.DefaultIngestionSettings.DataCollectionEndpointResourceId != nil {
state.DefaultDataCollectionEndpointId = *properties.DefaultIngestionSettings.DataCollectionEndpointResourceId
}
if properties.DefaultIngestionSettings.DataCollectionRuleResourceId != nil {
state.DefaultDataCollectionRuleId = *properties.DefaultIngestionSettings.DataCollectionRuleResourceId
}
}
}
}

Expand Down
23 changes: 13 additions & 10 deletions website/docs/d/monitor_workspace.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ layout: "azurerm"
page_title: "Azure Resource Manager: azurerm_monitor_data_collection_endpoint"
description: |-
Get information about the specified Workspace.
---

# Data Source: azurerm_monitor_workspace
Expand All @@ -26,26 +25,30 @@ output "query_endpoint" {

## Argument Reference

* `name` - Specifies the name of the Workspace.
- `name` - Specifies the name of the Workspace.

* `resource_group_name` - Specifies the name of the resource group the Workspace is located in.
- `resource_group_name` - Specifies the name of the resource group the Workspace is located in.

## Attributes Reference

* `id` - The ID of the Resource.
- `id` - The ID of the Resource.

- `kind` - The kind of the Workspace. Possible values are `Linux` and `Windows`.

- `location` - The Azure Region where the Workspace is located.

* `kind` - The kind of the Workspace. Possible values are `Linux` and `Windows`.
- `query_endpoint` - The query endpoint for the Azure Monitor Workspace.

* `location` - The Azure Region where the Workspace is located.
- `public_network_access_enabled` - Whether network access from public internet to the Workspace are allowed.

* `query_endpoint` - The query endpoint for the Azure Monitor Workspace.
- `default_data_collection_endpoint_id` - The ID of the managed default Data Collection Endpoint created with the Azure Monitor Workspace.

* `public_network_access_enabled` - Whether network access from public internet to the Workspace are allowed.
- `default_data_collection_rule_id` - The ID of the managed default Data Collection Rule created with the Azure Monitor Workspace.

* `tags` - A mapping of tags that are assigned to the Workspace.
- `tags` - A mapping of tags that are assigned to the Workspace.

## Timeouts

The `timeouts` block allows you to specify [timeouts](https://www.terraform.io/language/resources/syntax#operation-timeouts) for certain actions:

* `read` - (Defaults to 5 minutes) Used when retrieving the Workspace.
- `read` - (Defaults to 5 minutes) Used when retrieving the Workspace.
26 changes: 15 additions & 11 deletions website/docs/r/monitor_workspace.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -32,32 +32,36 @@ resource "azurerm_monitor_workspace" "example" {

The following arguments are supported:

* `name` - (Required) Specifies the name which should be used for this Azure Monitor Workspace. Changing this forces a new resource to be created.
- `name` - (Required) Specifies the name which should be used for this Azure Monitor Workspace. Changing this forces a new resource to be created.

* `resource_group_name` - (Required) Specifies the name of the Resource Group where the Azure Monitor Workspace should exist. Changing this forces a new resource to be created.
- `resource_group_name` - (Required) Specifies the name of the Resource Group where the Azure Monitor Workspace should exist. Changing this forces a new resource to be created.

* `location` - (Required) Specifies the Azure Region where the Azure Monitor Workspace should exist. Changing this forces a new resource to be created.
- `location` - (Required) Specifies the Azure Region where the Azure Monitor Workspace should exist. Changing this forces a new resource to be created.

* `public_network_access_enabled` - (Optional) Is public network access enabled? Defaults to `true`.
- `public_network_access_enabled` - (Optional) Is public network access enabled? Defaults to `true`.

* `tags` - (Optional) A mapping of tags which should be assigned to the Azure Monitor Workspace.
- `tags` - (Optional) A mapping of tags which should be assigned to the Azure Monitor Workspace.

## Attributes Reference

In addition to the Arguments listed above - the following Attributes are exported:

* `id` - The ID of the Azure Monitor Workspace.
- `id` - The ID of the Azure Monitor Workspace.

* `query_endpoint` - The query endpoint for the Azure Monitor Workspace.
- `query_endpoint` - The query endpoint for the Azure Monitor Workspace.

- `default_data_collection_endpoint_id` - The ID of the managed default Data Collection Endpoint created with the Azure Monitor Workspace.

- `default_data_collection_rule_id` - The ID of the managed default Data Collection Rule created with 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:

* `create` - (Defaults to 30 minutes) Used when creating the Azure Monitor Workspace.
* `read` - (Defaults to 5 minutes) Used when retrieving the Azure Monitor Workspace.
* `update` - (Defaults to 30 minutes) Used when updating the Azure Monitor Workspace.
* `delete` - (Defaults to 30 minutes) Used when deleting the Azure Monitor Workspace.
- `create` - (Defaults to 30 minutes) Used when creating the Azure Monitor Workspace.
- `read` - (Defaults to 5 minutes) Used when retrieving the Azure Monitor Workspace.
- `update` - (Defaults to 30 minutes) Used when updating the Azure Monitor Workspace.
- `delete` - (Defaults to 30 minutes) Used when deleting the Azure Monitor Workspace.

## Import

Expand Down

0 comments on commit 3b01a2c

Please sign in to comment.