diff --git a/datadog/resource_datadog_synthetics_test_.go b/datadog/resource_datadog_synthetics_test_.go index eadd637b77..415f162c6e 100644 --- a/datadog/resource_datadog_synthetics_test_.go +++ b/datadog/resource_datadog_synthetics_test_.go @@ -867,6 +867,14 @@ func syntheticsTestOptionsList() *schema.Schema { Type: schema.TypeInt, Optional: true, }, + "blocked_request_patterns": { + Description: "Blocked URL patterns. Requests made to URLs matching any of the patterns listed here will be blocked.", + Type: schema.TypeList, + Optional: true, + Elem: &schema.Schema{ + Type: schema.TypeString, + }, + }, "http_version": syntheticsHttpVersionOption(), }, }, @@ -4340,6 +4348,10 @@ func buildDatadogTestOptions(d *schema.ResourceData) *datadogV1.SyntheticsTestOp options.SetInitialNavigationTimeout(int64(initialNavigationTimeout.(int))) } + if blockedRequestPatterns, ok := d.GetOk("options_list.0.blocked_request_patterns"); ok { + options.SetBlockedRequestPatterns(blockedRequestPatterns.([]string)) + } + if attr, ok := d.GetOk("device_ids"); ok { var deviceIds []string for _, s := range attr.([]interface{}) { @@ -4483,6 +4495,9 @@ func buildTerraformTestOptions(actualOptions datadogV1.SyntheticsTestOptions) [] if actualOptions.HasInitialNavigationTimeout() { localOptionsList["initial_navigation_timeout"] = actualOptions.GetInitialNavigationTimeout() } + if actualOptions.HasBlockedRequestPatterns() { + localOptionsList["blockedRequestPatterns"] = actualOptions.GetBlockedRequestPatterns() + } localOptionsLists := make([]map[string]interface{}, 1) localOptionsLists[0] = localOptionsList diff --git a/datadog/tests/resource_datadog_synthetics_test_test.go b/datadog/tests/resource_datadog_synthetics_test_test.go index a41d35d10e..6d9251080a 100644 --- a/datadog/tests/resource_datadog_synthetics_test_test.go +++ b/datadog/tests/resource_datadog_synthetics_test_test.go @@ -817,6 +817,7 @@ resource "datadog_synthetics_test" "test" { options_list { initial_navigation_timeout = 15 + blocked_request_patterns = ["https://example.com/*"] tick_every = 3600 retry { count = 0 @@ -970,6 +971,7 @@ resource "datadog_synthetics_test" "test" { options_list { initial_navigation_timeout = 15 + blocked_request_patterns = ["https://example.com/*"] tick_every = 3600 retry { count = 0 @@ -4032,6 +4034,10 @@ func createSyntheticsBrowserTestStep(ctx context.Context, accProvider *schema.Pr "datadog_synthetics_test.bar", "options_list.0.disable_cors", "true"), resource.TestCheckResourceAttr( "datadog_synthetics_test.bar", "options_list.0.initial_navigation_timeout", "150"), + resource.TestCheckResourceAttr( + "datadog_synthetics_test.bar", "options_list.0.blocked_request_patterns.#", "1"), + resource.TestCheckResourceAttr( + "datadog_synthetics_test.bar", "options_list.0.blocked_request_patterns.0", "https://example.com/*"), resource.TestCheckResourceAttr( "datadog_synthetics_test.bar", "name", testName), resource.TestCheckResourceAttr( @@ -4172,6 +4178,7 @@ resource "datadog_synthetics_test" "bar" { disable_csp = true disable_cors = true initial_navigation_timeout = 150 + blocked_request_patterns = ["https://example.com/*"] } name = "%[1]s" diff --git a/docs/resources/synthetics_test.md b/docs/resources/synthetics_test.md index 9885925ef5..2da805c11f 100644 --- a/docs/resources/synthetics_test.md +++ b/docs/resources/synthetics_test.md @@ -1441,6 +1441,7 @@ Optional: - `accept_self_signed` (Boolean) For SSL tests, whether or not the test should allow self signed certificates. - `allow_insecure` (Boolean) Allows loading insecure content for a request in an API test or in a multistep API test step. +- `blocked_request_patterns` (List of String) Blocked URL patterns. Requests made to URLs matching any of the patterns listed here will be blocked. - `check_certificate_revocation` (Boolean) For SSL tests, whether or not the test should fail on revoked certificate in stapled OCSP. - `ci` (Block List, Max: 1) CI/CD options for a Synthetic test. (see [below for nested schema](#nestedblock--options_list--ci)) - `disable_aia_intermediate_fetching` (Boolean) For SSL tests, whether or not the test should disable fetching intermediate certificates from AIA diff --git a/go.mod b/go.mod index a311affc23..92c9b42fec 100644 --- a/go.mod +++ b/go.mod @@ -1,7 +1,7 @@ module github.com/terraform-providers/terraform-provider-datadog require ( - github.com/DataDog/datadog-api-client-go/v2 v2.47.0 + github.com/DataDog/datadog-api-client-go/v2 v2.47.1-0.20251002133952-772851d54caa github.com/DataDog/dd-sdk-go-testing v0.0.0-20211116174033-1cd082e322ad github.com/Masterminds/semver/v3 v3.3.1 github.com/google/go-cmp v0.7.0 diff --git a/go.sum b/go.sum index 1a57df4d0b..4b2f70a10c 100644 --- a/go.sum +++ b/go.sum @@ -2,8 +2,8 @@ cloud.google.com/go v0.26.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMT dario.cat/mergo v1.0.0 h1:AGCNq9Evsj31mOgNPcLyXc+4PNABt905YmuqPYYpBWk= dario.cat/mergo v1.0.0/go.mod h1:uNxQE+84aUszobStD9th8a29P2fMDhsBdgRYvZOxGmk= github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU= -github.com/DataDog/datadog-api-client-go/v2 v2.47.0 h1:bhPu0F6BGUGBaDw4h576asJcffFatYufy8w3/39prqA= -github.com/DataDog/datadog-api-client-go/v2 v2.47.0/go.mod h1:d3tOEgUd2kfsr9uuHQdY+nXrWp4uikgTgVCPdKNK30U= +github.com/DataDog/datadog-api-client-go/v2 v2.47.1-0.20251002133952-772851d54caa h1:Go4bOZ3uslzTEIohbndaF0g7MqUqfT4jcuh6CYKK/70= +github.com/DataDog/datadog-api-client-go/v2 v2.47.1-0.20251002133952-772851d54caa/go.mod h1:d3tOEgUd2kfsr9uuHQdY+nXrWp4uikgTgVCPdKNK30U= github.com/DataDog/datadog-go v4.4.0+incompatible/go.mod h1:LButxg5PwREeZtORoXG3tL4fMGNddJ+vMq1mwgfaqoQ= github.com/DataDog/datadog-go v4.8.3+incompatible h1:fNGaYSuObuQb5nzeTQqowRAd9bpDIRRV4/gUtIBjh8Q= github.com/DataDog/datadog-go v4.8.3+incompatible/go.mod h1:LButxg5PwREeZtORoXG3tL4fMGNddJ+vMq1mwgfaqoQ=