Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[datadog_integration_azure] Add resource_collection_enabled #2203

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .github/CODEOWNERS
Validating CODEOWNERS rules …
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ datadog/**/*datadog_api_key* @DataDog/integrations-tools-and-
datadog/**/*datadog_hosts* @DataDog/integrations-tools-and-libraries @DataDog/redapl-storage
datadog/**/*datadog_ip_ranges* @DataDog/integrations-tools-and-libraries @DataDog/team-aaa
datadog/**/*datadog_integration_aws* @DataDog/integrations-tools-and-libraries @DataDog/cloud-integrations
datadog/**/*datadog_integration_azure* @DataDog/integrations-tools-and-libraries @DataDog/azure-integrations
datadog/**/*datadog_integration_cloudflare* @DataDog/integrations-tools-and-libraries @Datadog/web-integrations
datadog/**/*datadog_integration_confluent* @DataDog/integrations-tools-and-libraries @Datadog/web-integrations
datadog/**/*datadog_integration_fastly* @DataDog/integrations-tools-and-libraries @Datadog/web-integrations
Expand Down
32 changes: 21 additions & 11 deletions datadog/fwprovider/resource_datadog_azure_integration.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,16 +30,17 @@ type integrationAzureResource struct {
}

type integrationAzureModel struct {
ID types.String `tfsdk:"id"`
AppServicePlanFilters types.String `tfsdk:"app_service_plan_filters"`
Automute types.Bool `tfsdk:"automute"`
ClientId types.String `tfsdk:"client_id"`
ClientSecret types.String `tfsdk:"client_secret"`
ContainerAppFilters types.String `tfsdk:"container_app_filters"`
CspmEnabled types.Bool `tfsdk:"cspm_enabled"`
CustomMetricsEnabled types.Bool `tfsdk:"custom_metrics_enabled"`
HostFilters types.String `tfsdk:"host_filters"`
TenantName types.String `tfsdk:"tenant_name"`
ID types.String `tfsdk:"id"`
AppServicePlanFilters types.String `tfsdk:"app_service_plan_filters"`
Automute types.Bool `tfsdk:"automute"`
ClientId types.String `tfsdk:"client_id"`
ClientSecret types.String `tfsdk:"client_secret"`
ContainerAppFilters types.String `tfsdk:"container_app_filters"`
ResourceCollectionEnabled types.Bool `tfsdk:"resource_collection_enabled"`
CspmEnabled types.Bool `tfsdk:"cspm_enabled"`
CustomMetricsEnabled types.Bool `tfsdk:"custom_metrics_enabled"`
HostFilters types.String `tfsdk:"host_filters"`
TenantName types.String `tfsdk:"tenant_name"`
}

func NewIntegrationAzureResource() resource.Resource {
Expand Down Expand Up @@ -79,11 +80,16 @@ func (r *integrationAzureResource) Schema(_ context.Context, _ resource.SchemaRe
Optional: true,
Description: "Silence monitors for expected Azure VM shutdowns.",
},
"resource_collection_enabled": schema.BoolAttribute{
Computed: true,
Optional: true,
Description: "When enabled, Datadog collects metadata and configuration info from cloud resources (such as compute instances, databases, and load balancers) monitored by this app registration.",
},
"cspm_enabled": schema.BoolAttribute{
Computed: true,
Default: booldefault.StaticBool(false),
Optional: true,
Description: "Enable Cloud Security Management Misconfigurations for your organization.",
Description: "When enabled, Datadog’s Cloud Security Management product scans resource configurations monitored by this app registration.\nNote: This requires `resource_collection_enabled` to be set to true.",
},
"custom_metrics_enabled": schema.BoolAttribute{
Computed: true,
Expand Down Expand Up @@ -248,6 +254,7 @@ func (r *integrationAzureResource) updateState(ctx context.Context, state *integ
state.TenantName = types.StringValue(account.GetTenantName())
state.ClientId = types.StringValue(account.GetClientId())
state.Automute = types.BoolValue(account.GetAutomute())
state.ResourceCollectionEnabled = types.BoolValue(account.GetResourceCollectionEnabled())
state.CspmEnabled = types.BoolValue(account.GetCspmEnabled())
state.CustomMetricsEnabled = types.BoolValue(account.GetCustomMetricsEnabled())

Expand Down Expand Up @@ -308,6 +315,9 @@ func (r *integrationAzureResource) buildIntegrationAzureRequestBody(ctx context.
datadogDefinition.SetAppServicePlanFilters(state.AppServicePlanFilters.ValueString())
datadogDefinition.SetContainerAppFilters(state.ContainerAppFilters.ValueString())
datadogDefinition.SetAutomute(state.Automute.ValueBool())
if !state.ResourceCollectionEnabled.IsUnknown() {
datadogDefinition.SetResourceCollectionEnabled(state.ResourceCollectionEnabled.ValueBool())
}
datadogDefinition.SetCspmEnabled(state.CspmEnabled.ValueBool())
datadogDefinition.SetCustomMetricsEnabled(state.CustomMetricsEnabled.ValueBool())

Expand Down
Original file line number Diff line number Diff line change
@@ -1 +1 @@
2023-10-27T10:18:52.967801-04:00
2023-12-08T15:48:29.420187-05:00
37 changes: 19 additions & 18 deletions datadog/tests/cassettes/TestAccDatadogIntegrationAzure.yaml

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -1 +1 @@
2023-10-27T11:14:21.361243-04:00
2023-12-08T15:50:12.653586-05:00
33 changes: 17 additions & 16 deletions datadog/tests/cassettes/TestAccDatadogLogsArchiveAzure_basic.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ version: 1
interactions:
- request:
body: |
{"app_service_plan_filters":"","automute":false,"client_id":"a75fbdd2-ade6-43d0-a810-4d886c53871e","client_secret":"testingx./Sw*g/Y33t..R1cH+hScMDt","container_app_filters":"","cspm_enabled":false,"custom_metrics_enabled":false,"host_filters":"","tenant_name":"3d2c804e-b5a4-123e-a31b-497a3298097b"}
{"app_service_plan_filters":"","automute":false,"client_id":"a75fbdd2-ade6-43d0-a810-4d886c53871e","client_secret":"testingx./Sw*g/Y33t..R1cH+hScMDt","container_app_filters":"","cspm_enabled":false,"custom_metrics_enabled":false,"host_filters":"","tenant_name":"fc657aee-46a0-6b5e-b69f-0bcb0b27468c"}
form: {}
headers:
Accept:
Expand Down Expand Up @@ -31,7 +31,7 @@ interactions:
method: GET
response:
body: |
[{"tenant_name":"3d2c804e-b5a4-123e-a31b-497a3298097b","client_id":"a75fbdd2-ade6-43d0-a810-4d886c53871e","container_app_filters":"","host_filters":"","app_service_plan_filters":"","automute":false,"cspm_enabled":false,"custom_metrics_enabled":false,"errors":[],"warnings":[]}]
[{"tenant_name":"17020631-0000-0000-0000-170206317900","client_id":"17020631-0000-0000-0000-170206317900","app_service_plan_filters":"key:value,filter:example","host_filters":"key:value,filter:example","container_app_filters":"key:value,filter:example","automute":true,"cspm_enabled":true,"custom_metrics_enabled":true,"resource_collection_enabled":true,"errors":["Invalid credentials. Datadog could not authenticate with Azure."],"warnings":[]},{"tenant_name":"5c18e51c-fa6f-4c6a-a092-ec44e749e327","client_id":"5c18e51c-fa6f-4c6a-a092-ec44e749e327","app_service_plan_filters":"key:value,filter:example","host_filters":"key:value,filter:example","container_app_filters":"key:value,filter:example","automute":true,"cspm_enabled":true,"custom_metrics_enabled":true,"resource_collection_enabled":true,"errors":["Invalid credentials. Datadog could not authenticate with Azure."],"warnings":[]},{"tenant_name":"fc657aee-46a0-6b5e-b69f-0bcb0b27468c","client_id":"a75fbdd2-ade6-43d0-a810-4d886c53871e","app_service_plan_filters":"","host_filters":"","container_app_filters":"","automute":false,"cspm_enabled":false,"custom_metrics_enabled":false,"resource_collection_enabled":false,"errors":[],"warnings":[]},{"tenant_name":"aaaaaaaa-bbbb-cccc-dddd-1699351983ff","client_id":"testc7f6-1234-5678-9101-uu1699351983","app_service_plan_filters":"","host_filters":"filter:foo,test:bar","container_app_filters":"","automute":true,"cspm_enabled":false,"custom_metrics_enabled":false,"resource_collection_enabled":false,"errors":["Invalid credentials. Datadog could not authenticate with Azure."],"warnings":[]}]
headers:
Content-Type:
- application/json
Expand All @@ -40,7 +40,7 @@ interactions:
duration: ""
- request:
body: |
{"data":{"attributes":{"destination":{"container":"my-container","integration":{"client_id":"a75fbdd2-ade6-43d0-a810-4d886c53871e","tenant_id":"3d2c804e-b5a4-123e-a31b-497a3298097b"},"path":"/path/blou","storage_account":"storageaccount","type":"azure"},"include_tags":false,"name":"my first azure archive","query":"service:toto","rehydration_max_scan_size_in_gb":null,"rehydration_tags":[]},"type":"archives"}}
{"data":{"attributes":{"destination":{"container":"my-container","integration":{"client_id":"a75fbdd2-ade6-43d0-a810-4d886c53871e","tenant_id":"fc657aee-46a0-6b5e-b69f-0bcb0b27468c"},"path":"/path/blou","storage_account":"storageaccount","type":"azure"},"include_tags":false,"name":"my first azure archive","query":"service:toto","rehydration_max_scan_size_in_gb":null,"rehydration_tags":[]},"type":"archives"}}
form: {}
headers:
Accept:
Expand All @@ -51,7 +51,7 @@ interactions:
method: POST
response:
body: |
{"data":{"type":"archives","id":"j0FZmzs-QjusCqvWcPSSsQ","attributes":{"name":"my first azure archive","query":"service:toto","state":"UNKNOWN","destination":{"container":"my-container","storage_account":"storageaccount","path":"/path/blou","type":"azure","integration":{"tenant_id":"3d2c804e-b5a4-123e-a31b-497a3298097b","client_id":"a75fbdd2-ade6-43d0-a810-4d886c53871e"}},"rehydration_tags":[],"include_tags":false,"rehydration_max_scan_size_in_gb":null}}}
{"data":{"type":"archives","id":"TemS66yFTX2jvUedlwglhQ","attributes":{"name":"my first azure archive","query":"service:toto","state":"UNKNOWN","destination":{"container":"my-container","storage_account":"storageaccount","path":"/path/blou","type":"azure","integration":{"tenant_id":"fc657aee-46a0-6b5e-b69f-0bcb0b27468c","client_id":"a75fbdd2-ade6-43d0-a810-4d886c53871e"}},"rehydration_tags":[],"include_tags":false,"rehydration_max_scan_size_in_gb":null}}}
headers:
Content-Type:
- application/json
Expand All @@ -64,11 +64,11 @@ interactions:
headers:
Accept:
- application/json
url: https://api.datadoghq.com/api/v2/logs/config/archives/j0FZmzs-QjusCqvWcPSSsQ
url: https://api.datadoghq.com/api/v2/logs/config/archives/TemS66yFTX2jvUedlwglhQ
method: GET
response:
body: |
{"data":{"type":"archives","id":"j0FZmzs-QjusCqvWcPSSsQ","attributes":{"name":"my first azure archive","query":"service:toto","state":"UNKNOWN","destination":{"container":"my-container","storage_account":"storageaccount","path":"/path/blou","type":"azure","integration":{"tenant_id":"3d2c804e-b5a4-123e-a31b-497a3298097b","client_id":"a75fbdd2-ade6-43d0-a810-4d886c53871e"}},"rehydration_tags":[],"include_tags":false,"rehydration_max_scan_size_in_gb":null}}}
{"data":{"type":"archives","id":"TemS66yFTX2jvUedlwglhQ","attributes":{"name":"my first azure archive","query":"service:toto","state":"UNKNOWN","destination":{"container":"my-container","storage_account":"storageaccount","path":"/path/blou","type":"azure","integration":{"tenant_id":"fc657aee-46a0-6b5e-b69f-0bcb0b27468c","client_id":"a75fbdd2-ade6-43d0-a810-4d886c53871e"}},"rehydration_tags":[],"include_tags":false,"rehydration_max_scan_size_in_gb":null}}}
headers:
Content-Type:
- application/json
Expand All @@ -85,7 +85,7 @@ interactions:
method: GET
response:
body: |
[{"tenant_name":"3d2c804e-b5a4-123e-a31b-497a3298097b","client_id":"a75fbdd2-ade6-43d0-a810-4d886c53871e","app_service_plan_filters":"","container_app_filters":"","host_filters":"","automute":false,"cspm_enabled":false,"custom_metrics_enabled":false,"errors":[],"warnings":[]}]
[{"tenant_name":"17020631-0000-0000-0000-170206317900","client_id":"17020631-0000-0000-0000-170206317900","app_service_plan_filters":"key:value,filter:example","host_filters":"key:value,filter:example","container_app_filters":"key:value,filter:example","automute":true,"cspm_enabled":true,"custom_metrics_enabled":true,"resource_collection_enabled":true,"errors":["Invalid credentials. Datadog could not authenticate with Azure."],"warnings":[]},{"tenant_name":"5c18e51c-fa6f-4c6a-a092-ec44e749e327","client_id":"5c18e51c-fa6f-4c6a-a092-ec44e749e327","app_service_plan_filters":"key:value,filter:example","host_filters":"key:value,filter:example","container_app_filters":"key:value,filter:example","automute":true,"cspm_enabled":true,"custom_metrics_enabled":true,"resource_collection_enabled":true,"errors":["Invalid credentials. Datadog could not authenticate with Azure."],"warnings":[]},{"tenant_name":"fc657aee-46a0-6b5e-b69f-0bcb0b27468c","client_id":"a75fbdd2-ade6-43d0-a810-4d886c53871e","app_service_plan_filters":"","host_filters":"","container_app_filters":"","automute":false,"cspm_enabled":false,"custom_metrics_enabled":false,"resource_collection_enabled":false,"errors":[],"warnings":[]},{"tenant_name":"aaaaaaaa-bbbb-cccc-dddd-1699351983ff","client_id":"testc7f6-1234-5678-9101-uu1699351983","app_service_plan_filters":"","host_filters":"filter:foo,test:bar","container_app_filters":"","automute":true,"cspm_enabled":false,"custom_metrics_enabled":false,"resource_collection_enabled":false,"errors":["Invalid credentials. Datadog could not authenticate with Azure."],"warnings":[]}]
headers:
Content-Type:
- application/json
Expand All @@ -98,11 +98,11 @@ interactions:
headers:
Accept:
- application/json
url: https://api.datadoghq.com/api/v2/logs/config/archives/j0FZmzs-QjusCqvWcPSSsQ
url: https://api.datadoghq.com/api/v2/logs/config/archives/TemS66yFTX2jvUedlwglhQ
method: GET
response:
body: |
{"data":{"type":"archives","id":"j0FZmzs-QjusCqvWcPSSsQ","attributes":{"name":"my first azure archive","query":"service:toto","state":"UNKNOWN","destination":{"container":"my-container","storage_account":"storageaccount","path":"/path/blou","type":"azure","integration":{"tenant_id":"3d2c804e-b5a4-123e-a31b-497a3298097b","client_id":"a75fbdd2-ade6-43d0-a810-4d886c53871e"}},"rehydration_tags":[],"include_tags":false,"rehydration_max_scan_size_in_gb":null}}}
{"data":{"type":"archives","id":"TemS66yFTX2jvUedlwglhQ","attributes":{"name":"my first azure archive","query":"service:toto","state":"UNKNOWN","destination":{"container":"my-container","storage_account":"storageaccount","path":"/path/blou","type":"azure","integration":{"tenant_id":"fc657aee-46a0-6b5e-b69f-0bcb0b27468c","client_id":"a75fbdd2-ade6-43d0-a810-4d886c53871e"}},"rehydration_tags":[],"include_tags":false,"rehydration_max_scan_size_in_gb":null}}}
headers:
Content-Type:
- application/json
Expand All @@ -115,7 +115,7 @@ interactions:
headers:
Accept:
- '*/*'
url: https://api.datadoghq.com/api/v2/logs/config/archives/j0FZmzs-QjusCqvWcPSSsQ
url: https://api.datadoghq.com/api/v2/logs/config/archives/TemS66yFTX2jvUedlwglhQ
method: DELETE
response:
body: ""
Expand All @@ -125,7 +125,7 @@ interactions:
duration: ""
- request:
body: |
{"app_service_plan_filters":"","automute":false,"client_id":"a75fbdd2-ade6-43d0-a810-4d886c53871e","client_secret":"testingx./Sw*g/Y33t..R1cH+hScMDt","container_app_filters":"","cspm_enabled":false,"custom_metrics_enabled":false,"host_filters":"","tenant_name":"3d2c804e-b5a4-123e-a31b-497a3298097b"}
{"app_service_plan_filters":"","automute":false,"client_id":"a75fbdd2-ade6-43d0-a810-4d886c53871e","client_secret":"testingx./Sw*g/Y33t..R1cH+hScMDt","container_app_filters":"","cspm_enabled":false,"custom_metrics_enabled":false,"host_filters":"","resource_collection_enabled":false,"tenant_name":"fc657aee-46a0-6b5e-b69f-0bcb0b27468c"}
form: {}
headers:
Accept:
Expand All @@ -149,10 +149,10 @@ interactions:
headers:
Accept:
- application/json
url: https://api.datadoghq.com/api/v2/logs/config/archives/j0FZmzs-QjusCqvWcPSSsQ
url: https://api.datadoghq.com/api/v2/logs/config/archives/TemS66yFTX2jvUedlwglhQ
method: GET
response:
body: '{"errors":["Archive j0FZmzs-QjusCqvWcPSSsQ not found"]}'
body: '{"errors":["Archive TemS66yFTX2jvUedlwglhQ not found"]}'
headers:
Content-Type:
- application/json
Expand All @@ -168,10 +168,11 @@ interactions:
url: https://api.datadoghq.com/api/v1/integration/azure
method: GET
response:
body: '{"errors":["Azure Integration not yet installed. Please install before performing this action."]}'
body: |
[{"tenant_name":"17020631-0000-0000-0000-170206317900","client_id":"17020631-0000-0000-0000-170206317900","app_service_plan_filters":"key:value,filter:example","container_app_filters":"key:value,filter:example","host_filters":"key:value,filter:example","automute":true,"cspm_enabled":true,"custom_metrics_enabled":true,"resource_collection_enabled":true,"errors":["Invalid credentials. Datadog could not authenticate with Azure."],"warnings":[]},{"tenant_name":"5c18e51c-fa6f-4c6a-a092-ec44e749e327","client_id":"5c18e51c-fa6f-4c6a-a092-ec44e749e327","app_service_plan_filters":"key:value,filter:example","container_app_filters":"key:value,filter:example","host_filters":"key:value,filter:example","automute":true,"cspm_enabled":true,"custom_metrics_enabled":true,"resource_collection_enabled":true,"errors":["Invalid credentials. Datadog could not authenticate with Azure."],"warnings":[]},{"tenant_name":"aaaaaaaa-bbbb-cccc-dddd-1699351983ff","client_id":"testc7f6-1234-5678-9101-uu1699351983","app_service_plan_filters":"","container_app_filters":"","host_filters":"filter:foo,test:bar","automute":true,"cspm_enabled":false,"custom_metrics_enabled":false,"resource_collection_enabled":false,"errors":["Invalid credentials. Datadog could not authenticate with Azure."],"warnings":[]}]
headers:
Content-Type:
- application/json
status: 400 Bad Request
code: 400
status: 200 OK
code: 200
duration: ""
Loading