From 80061ff350ea681d3f43d0fed75fa5a0877df23b Mon Sep 17 00:00:00 2001 From: djryanj Date: Thu, 7 Dec 2023 11:56:07 -0700 Subject: [PATCH] add default endpoints and update docs for #24151 --- .../monitor/monitor_workspace_data_source.go | 46 +++++++++++++------ .../monitor/monitor_workspace_resource.go | 31 ++++++++++--- .../docs/d/monitor_workspace.html.markdown | 23 ++++++---- .../docs/r/monitor_workspace.html.markdown | 26 ++++++----- 4 files changed, 86 insertions(+), 40 deletions(-) diff --git a/internal/services/monitor/monitor_workspace_data_source.go b/internal/services/monitor/monitor_workspace_data_source.go index 5f0c7f389f14..7ce69edb119a 100644 --- a/internal/services/monitor/monitor_workspace_data_source.go +++ b/internal/services/monitor/monitor_workspace_data_source.go @@ -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{} { @@ -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(), } @@ -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 { @@ -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, }) }, } diff --git a/internal/services/monitor/monitor_workspace_resource.go b/internal/services/monitor/monitor_workspace_resource.go index d4fb418fd7fe..12052860f44e 100644 --- a/internal/services/monitor/monitor_workspace_resource.go +++ b/internal/services/monitor/monitor_workspace_resource.go @@ -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{} @@ -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, + }, } } @@ -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 + } + } } } diff --git a/website/docs/d/monitor_workspace.html.markdown b/website/docs/d/monitor_workspace.html.markdown index b0cc2f3ee539..467585244e60 100644 --- a/website/docs/d/monitor_workspace.html.markdown +++ b/website/docs/d/monitor_workspace.html.markdown @@ -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 @@ -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. diff --git a/website/docs/r/monitor_workspace.html.markdown b/website/docs/r/monitor_workspace.html.markdown index d906f07a400a..eeb48cba4d58 100644 --- a/website/docs/r/monitor_workspace.html.markdown +++ b/website/docs/r/monitor_workspace.html.markdown @@ -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