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

Add support for Azure resource automute option #1262

Merged
merged 7 commits into from
Nov 9, 2021
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
9 changes: 9 additions & 0 deletions datadog/resource_datadog_integration_azure.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,12 @@ func resourceDatadogIntegrationAzure() *schema.Resource {
Type: schema.TypeString,
Optional: true,
},
"automute": {
Description: "Silence monitors for expected Azure VM shutdowns.",
Type: schema.TypeBool,
Default: false,
Optional: true,
},
},
}
}
Expand All @@ -72,6 +78,7 @@ func resourceDatadogIntegrationAzureRead(ctx context.Context, d *schema.Resource
if integration.GetTenantName() == tenantName && integration.GetClientId() == clientId {
d.Set("tenant_name", integration.GetTenantName())
d.Set("client_id", integration.GetClientId())
d.Set("automute", integration.GetAutomute())
hostFilters, exists := integration.GetHostFiltersOk()
if exists {
d.Set("host_filters", hostFilters)
Expand Down Expand Up @@ -157,6 +164,8 @@ func buildDatadogAzureIntegrationDefinition(terraformDefinition *schema.Resource
// Optional params
hostFilters := terraformDefinition.Get("host_filters")
datadogDefinition.SetHostFilters(hostFilters.(string))
automute := terraformDefinition.Get("automute")
datadogDefinition.SetAutomute(automute.(bool))

clientSecret, exists := terraformDefinition.GetOk("client_secret")
if exists {
Expand Down
Original file line number Diff line number Diff line change
@@ -1 +1 @@
2021-10-28T16:26:13.057136-04:00
2021-11-09T17:40:54.549623+01:00
136 changes: 83 additions & 53 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 @@
2021-06-29T17:45:38.413586+02:00
2021-11-01T16:22:40.665642-04:00
112 changes: 49 additions & 63 deletions datadog/tests/cassettes/TestAccDatadogLogsArchiveAzure_basic.yaml

Large diffs are not rendered by default.

9 changes: 8 additions & 1 deletion datadog/tests/resource_datadog_integration_azure_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ resource "datadog_integration_azure" "an_azure_integration" {
}

resource "datadog_integration_azure" "an_azure_integration_two" {
depends_on = [datadog_integration_azure.an_azure_integration]
tenant_name = "%[1]s"
client_id = "testc7f6-1234-5678-9101-3fcbf123test"
client_secret = "testingx./Sw*g/Y33t..R1cH+hScMDt"
Expand All @@ -38,6 +39,7 @@ resource "datadog_integration_azure" "an_azure_integration" {
tenant_name = "%s"
client_id = "testc7f6-1234-5678-9101-3fcbf464test"
client_secret = "testingx./Sw*g/Y33t..R1cH+hScMDt"
automute = true
}`, uniq)
}

Expand Down Expand Up @@ -68,7 +70,9 @@ func TestAccDatadogIntegrationAzure(t *testing.T) {
"datadog_integration_azure.an_azure_integration",
"host_filters", "foo:bar,buzz:lightyear"),
resource.TestCheckResourceAttr(
"datadog_integration_azure.an_azure_integration_two",
"datadog_integration_azure.an_azure_integration",
"automute", "false"),
resource.TestCheckResourceAttr("datadog_integration_azure.an_azure_integration_two",
"tenant_name", tenantName),
resource.TestCheckResourceAttr(
"datadog_integration_azure.an_azure_integration_two",
Expand All @@ -91,6 +95,9 @@ func TestAccDatadogIntegrationAzure(t *testing.T) {
resource.TestCheckResourceAttr(
"datadog_integration_azure.an_azure_integration",
"host_filters", ""),
resource.TestCheckResourceAttr(
"datadog_integration_azure.an_azure_integration",
"automute", "true"),
),
},
},
Expand Down
1 change: 1 addition & 0 deletions docs/resources/integration_azure.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ resource "datadog_integration_azure" "sandbox" {

### Optional

- **automute** (Boolean) Silence monitors for expected Azure VM shutdowns.
- **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`

### Read-Only
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
module github.com/terraform-providers/terraform-provider-datadog

require (
github.com/DataDog/datadog-api-client-go v1.5.1-0.20211029133749-06561356b31c
github.com/DataDog/datadog-api-client-go v1.5.1-0.20211108111632-ecc1a63727e3
github.com/DataDog/datadog-go v4.8.2+incompatible // indirect
github.com/DataDog/dd-sdk-go-testing v0.0.0-20210929140144-5d69f0a9bd49
github.com/DataDog/sketches-go v1.2.1 // indirect
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,8 @@ cloud.google.com/go/storage v1.10.0/go.mod h1:FLPqc6j+Ki4BU591ie1oL6qBQGu2Bl/tZ9
dmitri.shuralyov.com/gpu/mtl v0.0.0-20190408044501-666a987793e9/go.mod h1:H6x//7gZCb22OMCxBHrMx7a5I7Hp++hsVxbQ4BYO7hU=
github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU=
github.com/BurntSushi/xgb v0.0.0-20160522181843-27f122750802/go.mod h1:IVnqGOEym/WlBOVXweHU+Q+/VP0lqqI8lqeDx9IjBqo=
github.com/DataDog/datadog-api-client-go v1.5.1-0.20211029133749-06561356b31c h1:DVH7uKElGRSwyYW4NUR2UGbII94Ea5TVTcvYcWMEoxY=
github.com/DataDog/datadog-api-client-go v1.5.1-0.20211029133749-06561356b31c/go.mod h1:QzaQF1cDO1/BIQG1fz14VrY+6RECUGkiwzDCtVbfP5c=
github.com/DataDog/datadog-api-client-go v1.5.1-0.20211108111632-ecc1a63727e3 h1:xfexyqtjwydx/uy7N1g5Y8B4UfTLZyrHqzU51faDRKE=
github.com/DataDog/datadog-api-client-go v1.5.1-0.20211108111632-ecc1a63727e3/go.mod h1:QzaQF1cDO1/BIQG1fz14VrY+6RECUGkiwzDCtVbfP5c=
github.com/DataDog/datadog-go v4.4.0+incompatible/go.mod h1:LButxg5PwREeZtORoXG3tL4fMGNddJ+vMq1mwgfaqoQ=
github.com/DataDog/datadog-go v4.8.2+incompatible h1:qbcKSx29aBLD+5QLvlQZlGmRMF/FfGqFLFev/1TDzRo=
github.com/DataDog/datadog-go v4.8.2+incompatible/go.mod h1:LButxg5PwREeZtORoXG3tL4fMGNddJ+vMq1mwgfaqoQ=
Expand Down