Skip to content

Commit d9520d5

Browse files
authored
Revert "[datadog_azure_integration] Support metric filitering (#2757)" (#2778)
This reverts commit 468f5ff.
1 parent b1894bc commit d9520d5

File tree

2 files changed

+11
-90
lines changed

2 files changed

+11
-90
lines changed

datadog/fwprovider/resource_datadog_azure_integration.go

Lines changed: 11 additions & 78 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,11 @@ import (
66
"sync"
77

88
"github.com/DataDog/datadog-api-client-go/v2/api/datadogV1"
9-
"github.com/hashicorp/terraform-plugin-framework/attr"
109
"github.com/hashicorp/terraform-plugin-framework/diag"
1110
frameworkPath "github.com/hashicorp/terraform-plugin-framework/path"
1211
"github.com/hashicorp/terraform-plugin-framework/resource"
1312
"github.com/hashicorp/terraform-plugin-framework/resource/schema"
1413
"github.com/hashicorp/terraform-plugin-framework/resource/schema/booldefault"
15-
"github.com/hashicorp/terraform-plugin-framework/resource/schema/listdefault"
1614
"github.com/hashicorp/terraform-plugin-framework/resource/schema/stringdefault"
1715
"github.com/hashicorp/terraform-plugin-framework/types"
1816

@@ -31,27 +29,18 @@ type integrationAzureResource struct {
3129
Auth context.Context
3230
}
3331

34-
type ResourceProviderConfigModel struct {
35-
Namespace types.String `tfsdk:"namespace"`
36-
MetricsEnabled types.Bool `tfsdk:"metrics_enabled"`
37-
}
38-
3932
type integrationAzureModel struct {
40-
ID types.String `tfsdk:"id"`
41-
AppServicePlanFilters types.String `tfsdk:"app_service_plan_filters"`
42-
Automute types.Bool `tfsdk:"automute"`
43-
ClientId types.String `tfsdk:"client_id"`
44-
ClientSecret types.String `tfsdk:"client_secret"`
45-
ContainerAppFilters types.String `tfsdk:"container_app_filters"`
46-
ResourceCollectionEnabled types.Bool `tfsdk:"resource_collection_enabled"`
47-
CspmEnabled types.Bool `tfsdk:"cspm_enabled"`
48-
CustomMetricsEnabled types.Bool `tfsdk:"custom_metrics_enabled"`
49-
HostFilters types.String `tfsdk:"host_filters"`
50-
TenantName types.String `tfsdk:"tenant_name"`
51-
MetricsEnabled types.Bool `tfsdk:"metrics_enabled"`
52-
MetricsEnabledDefault types.Bool `tfsdk:"metrics_enabled_default"`
53-
UsageMetricsEnabled types.Bool `tfsdk:"usage_metrics_enabled"`
54-
ResourceProviderConfigs []*ResourceProviderConfigModel `tfsdk:"resource_provider_configs"`
33+
ID types.String `tfsdk:"id"`
34+
AppServicePlanFilters types.String `tfsdk:"app_service_plan_filters"`
35+
Automute types.Bool `tfsdk:"automute"`
36+
ClientId types.String `tfsdk:"client_id"`
37+
ClientSecret types.String `tfsdk:"client_secret"`
38+
ContainerAppFilters types.String `tfsdk:"container_app_filters"`
39+
ResourceCollectionEnabled types.Bool `tfsdk:"resource_collection_enabled"`
40+
CspmEnabled types.Bool `tfsdk:"cspm_enabled"`
41+
CustomMetricsEnabled types.Bool `tfsdk:"custom_metrics_enabled"`
42+
HostFilters types.String `tfsdk:"host_filters"`
43+
TenantName types.String `tfsdk:"tenant_name"`
5544
}
5645

5746
func NewIntegrationAzureResource() resource.Resource {
@@ -68,13 +57,6 @@ func (r *integrationAzureResource) Metadata(_ context.Context, request resource.
6857
response.TypeName = "integration_azure"
6958
}
7059

71-
var ResourceProviderConfigSchemaType = types.ObjectType{
72-
AttrTypes: map[string]attr.Type{
73-
"namespace": types.StringType,
74-
"metrics_enabled": types.BoolType,
75-
},
76-
}
77-
7860
func (r *integrationAzureResource) Schema(_ context.Context, _ resource.SchemaRequest, response *resource.SchemaResponse) {
7961
response.Schema = schema.Schema{
8062
Description: "Provides a Datadog - Microsoft Azure integration resource. This can be used to create and manage the integrations.",
@@ -133,31 +115,6 @@ func (r *integrationAzureResource) Schema(_ context.Context, _ resource.SchemaRe
133115
Description: "This comma-separated list of tags (in the form `key:value,key:value`) defines a filter that Datadog uses when collecting metrics from Azure App Service Plans. Only App Service Plans that match one of the defined tags are imported into Datadog. The rest, including the apps and functions running on them, are ignored. This also filters the metrics for any App or Function running on the App Service Plan(s).",
134116
Default: stringdefault.StaticString(""),
135117
},
136-
"metrics_enabled": schema.BoolAttribute{
137-
Computed: true,
138-
Default: booldefault.StaticBool(true),
139-
Optional: true,
140-
Description: "Enable Azure metrics for your organization.",
141-
},
142-
"metrics_enabled_default": schema.BoolAttribute{
143-
Computed: true,
144-
Default: booldefault.StaticBool(true),
145-
Optional: true,
146-
Description: "Enable Azure metrics for your organization for resource providers where no resource provider config is specified.",
147-
},
148-
"usage_metrics_enabled": schema.BoolAttribute{
149-
Computed: true,
150-
Default: booldefault.StaticBool(true),
151-
Optional: true,
152-
Description: "Enable azure.usage metrics for your organization.",
153-
},
154-
"resource_provider_configs": schema.ListAttribute{
155-
Computed: true,
156-
Optional: true,
157-
Default: listdefault.StaticValue(types.ListNull(ResourceProviderConfigSchemaType)),
158-
Description: "Configuration settings applied to resources from the specified Azure resource providers.",
159-
ElementType: ResourceProviderConfigSchemaType,
160-
},
161118
"id": utils.ResourceIDAttribute(),
162119
},
163120
}
@@ -300,18 +257,6 @@ func (r *integrationAzureResource) updateState(ctx context.Context, state *integ
300257
state.ResourceCollectionEnabled = types.BoolValue(account.GetResourceCollectionEnabled())
301258
state.CspmEnabled = types.BoolValue(account.GetCspmEnabled())
302259
state.CustomMetricsEnabled = types.BoolValue(account.GetCustomMetricsEnabled())
303-
state.MetricsEnabled = types.BoolValue(account.GetMetricsEnabled())
304-
state.MetricsEnabledDefault = types.BoolValue(account.GetMetricsEnabledDefault())
305-
state.UsageMetricsEnabled = types.BoolValue(account.GetUsageMetricsEnabled())
306-
307-
resourceProviderConfigs := account.GetResourceProviderConfigs()
308-
state.ResourceProviderConfigs = make([]*ResourceProviderConfigModel, 0, len(resourceProviderConfigs))
309-
for _, resourceProviderConfig := range resourceProviderConfigs {
310-
state.ResourceProviderConfigs = append(state.ResourceProviderConfigs, &ResourceProviderConfigModel{
311-
Namespace: types.StringValue(resourceProviderConfig.GetNamespace()),
312-
MetricsEnabled: types.BoolValue(resourceProviderConfig.GetMetricsEnabled()),
313-
})
314-
}
315260

316261
hostFilters, exists := account.GetHostFiltersOk()
317262
if exists {
@@ -371,18 +316,6 @@ func (r *integrationAzureResource) buildIntegrationAzureRequestBody(ctx context.
371316
}
372317
datadogDefinition.SetCspmEnabled(state.CspmEnabled.ValueBool())
373318
datadogDefinition.SetCustomMetricsEnabled(state.CustomMetricsEnabled.ValueBool())
374-
datadogDefinition.SetMetricsEnabled(state.MetricsEnabled.ValueBool())
375-
datadogDefinition.SetMetricsEnabledDefault(state.MetricsEnabledDefault.ValueBool())
376-
datadogDefinition.SetUsageMetricsEnabled(state.UsageMetricsEnabled.ValueBool())
377-
378-
resourceProviderConfigsPayload := make([]datadogV1.ResourceProviderConfig, 0, len(state.ResourceProviderConfigs))
379-
for _, resourceProviderConfig := range state.ResourceProviderConfigs {
380-
resourceProviderConfigsPayload = append(resourceProviderConfigsPayload, datadogV1.ResourceProviderConfig{
381-
Namespace: resourceProviderConfig.Namespace.ValueStringPointer(),
382-
MetricsEnabled: resourceProviderConfig.MetricsEnabled.ValueBoolPointer(),
383-
})
384-
}
385-
datadogDefinition.SetResourceProviderConfigs(resourceProviderConfigsPayload)
386319

387320
if !state.ClientSecret.IsNull() {
388321
datadogDefinition.SetClientSecret(state.ClientSecret.ValueString())

docs/resources/integration_azure.md

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -45,24 +45,12 @@ resource "datadog_integration_azure" "sandbox" {
4545
Note: This requires `resource_collection_enabled` to be set to true. Defaults to `false`.
4646
- `custom_metrics_enabled` (Boolean) Enable custom metrics for your organization. Defaults to `false`.
4747
- `host_filters` (String) String of host tag(s) (in the form `key:value,key:value`) defines a filter that Datadog will use when collecting metrics from Azure. Limit the Azure instances that are pulled into Datadog by using tags. Only hosts that match one of the defined tags are imported into Datadog. e.x. `env:production,deploymentgroup:red` Defaults to `""`.
48-
- `metrics_enabled` (Boolean) Enable Azure metrics for your organization. Defaults to `true`.
49-
- `metrics_enabled_default` (Boolean) Enable Azure metrics for your organization for resource providers where no resource provider config is specified. Defaults to `true`.
5048
- `resource_collection_enabled` (Boolean) When enabled, Datadog collects metadata and configuration info from cloud resources (such as compute instances, databases, and load balancers) monitored by this app registration.
51-
- `resource_provider_configs` (List of Object) Configuration settings applied to resources from the specified Azure resource providers. (see [below for nested schema](#nestedatt--resource_provider_configs))
52-
- `usage_metrics_enabled` (Boolean) Enable azure.usage metrics for your organization. Defaults to `true`.
5349

5450
### Read-Only
5551

5652
- `id` (String) The ID of this resource.
5753

58-
<a id="nestedatt--resource_provider_configs"></a>
59-
### Nested Schema for `resource_provider_configs`
60-
61-
Optional:
62-
63-
- `metrics_enabled` (Boolean)
64-
- `namespace` (String)
65-
6654
## Import
6755

6856
Import is supported using the following syntax:

0 commit comments

Comments
 (0)