Skip to content

Commit 9349e22

Browse files
committed
[datadog_logs_archive] Add partitioning_attributes and lookup_attributes to Log Archives resource
1 parent 626ba03 commit 9349e22

7 files changed

Lines changed: 65 additions & 27 deletions

datadog/resource_datadog_logs_archive.go

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,18 @@ func resourceDatadogLogsArchive() *schema.Resource {
116116
Default: string(datadogV2.LOGSARCHIVEATTRIBUTESCOMPRESSIONMETHOD_GZIP),
117117
ValidateDiagFunc: validators.ValidateEnumValue(datadogV2.NewLogsArchiveAttributesCompressionMethodFromValue),
118118
},
119+
"partitioning_attributes": {
120+
Description: "An array of attributes to use as partition keys for the archive. The attribute used most frequently for querying should be first.",
121+
Type: schema.TypeList,
122+
Optional: true,
123+
Elem: &schema.Schema{Type: schema.TypeString},
124+
},
125+
"lookup_attributes": {
126+
Description: "An array of attributes to use as lookup keys for the archive.",
127+
Type: schema.TypeList,
128+
Optional: true,
129+
Elem: &schema.Schema{Type: schema.TypeString},
130+
},
119131
}
120132
},
121133
}
@@ -180,6 +192,14 @@ func updateLogsArchiveState(d *schema.ResourceData, ddArchive *datadogV2.LogsArc
180192
}
181193
}
182194

195+
if err = d.Set("partitioning_attributes", ddArchive.Data.Attributes.GetPartitioningAttributes()); err != nil {
196+
return diag.FromErr(err)
197+
}
198+
199+
if err = d.Set("lookup_attributes", ddArchive.Data.Attributes.GetLookupAttributes()); err != nil {
200+
return diag.FromErr(err)
201+
}
202+
183203
return nil
184204
}
185205

@@ -321,6 +341,14 @@ func buildDatadogArchiveCreateReq(d *schema.ResourceData) (*datadogV2.LogsArchiv
321341
compressionMethod := d.Get("compression_method").(string)
322342
attributes.SetCompressionMethod(datadogV2.LogsArchiveAttributesCompressionMethod(compressionMethod))
323343

344+
if v, ok := d.GetOk("partitioning_attributes"); ok {
345+
attributes.SetPartitioningAttributes(expandStringList(v.([]interface{})))
346+
}
347+
348+
if v, ok := d.GetOk("lookup_attributes"); ok {
349+
attributes.SetLookupAttributes(expandStringList(v.([]interface{})))
350+
}
351+
324352
definition := datadogV2.NewLogsArchiveCreateRequestDefinitionWithDefaults()
325353
definition.SetAttributes(*attributes)
326354
archive.SetData(*definition)

datadog/tests/cassettes/TestAccDatadogLogsArchiveAzure_basic.freeze

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

datadog/tests/cassettes/TestAccDatadogLogsArchiveAzure_basic.yaml

Lines changed: 23 additions & 23 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

datadog/tests/resource_datadog_logs_archive_test.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -185,6 +185,8 @@ resource "datadog_logs_archive" "my_s3_archive" {
185185
include_tags = true
186186
rehydration_max_scan_size_in_gb = 123
187187
compression_method = "ZSTD"
188+
partitioning_attributes = ["host", "service"]
189+
lookup_attributes = ["trace_id"]
188190
}`, uniq, uniq, encryption)
189191
}
190192

@@ -231,6 +233,12 @@ func TestAccDatadogLogsArchiveS3_basic(t *testing.T) {
231233
"datadog_logs_archive.my_s3_archive", "rehydration_max_scan_size_in_gb", "123"),
232234
resource.TestCheckResourceAttr(
233235
"datadog_logs_archive.my_s3_archive", "compression_method", "ZSTD"),
236+
resource.TestCheckResourceAttr(
237+
"datadog_logs_archive.my_s3_archive", "partitioning_attributes.0", "host"),
238+
resource.TestCheckResourceAttr(
239+
"datadog_logs_archive.my_s3_archive", "partitioning_attributes.1", "service"),
240+
resource.TestCheckResourceAttr(
241+
"datadog_logs_archive.my_s3_archive", "lookup_attributes.0", "trace_id"),
234242
),
235243
},
236244
},

docs/resources/logs_archive.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,8 @@ resource "datadog_logs_archive" "my_s3_archive" {
3939
- `compression_method` (String) The compression method for the archive. Valid values are `GZIP`, `ZSTD`. Defaults to `"GZIP"`.
4040
- `gcs_archive` (Block List, Max: 1) Definition of a GCS archive. (see [below for nested schema](#nestedblock--gcs_archive))
4141
- `include_tags` (Boolean) To store the tags in the archive, set the value `true`. If it is set to `false`, the tags will be dropped when the logs are sent to the archive. Defaults to `false`.
42+
- `lookup_attributes` (List of String) An array of attributes to use as lookup keys for the archive.
43+
- `partitioning_attributes` (List of String) An array of attributes to use as partition keys for the archive. The attribute used most frequently for querying should be first.
4244
- `rehydration_max_scan_size_in_gb` (Number) To limit the rehydration scan size for the archive, set a value in GB.
4345
- `rehydration_tags` (List of String) An array of tags to add to rehydrated logs from an archive.
4446
- `s3_archive` (Block List, Max: 1) Definition of an s3 archive. (see [below for nested schema](#nestedblock--s3_archive))

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
module github.com/terraform-providers/terraform-provider-datadog
22

33
require (
4-
github.com/DataDog/datadog-api-client-go/v2 v2.60.1-0.20260529072814-6fdb70862f77
4+
github.com/DataDog/datadog-api-client-go/v2 v2.60.1-0.20260603114614-30670a13d419
55
github.com/DataDog/dd-sdk-go-testing v0.0.0-20211116174033-1cd082e322ad
66
github.com/Masterminds/semver/v3 v3.3.1
77
github.com/google/go-cmp v0.7.0

go.sum

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@ dario.cat/mergo v1.0.0/go.mod h1:uNxQE+84aUszobStD9th8a29P2fMDhsBdgRYvZOxGmk=
44
github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU=
55
github.com/BurntSushi/toml v1.2.1 h1:9F2/+DoOYIOksmaJFPw1tGFy1eDnIJXg+UHjuD8lTak=
66
github.com/BurntSushi/toml v1.2.1/go.mod h1:CxXYINrC8qIiEnFrOxCa7Jy5BFHlXnUU2pbicEuybxQ=
7-
github.com/DataDog/datadog-api-client-go/v2 v2.60.1-0.20260529072814-6fdb70862f77 h1:Kevvk3qWhQV83KL4CeO5w27qe2mO9oZyGELyjmnD+AA=
8-
github.com/DataDog/datadog-api-client-go/v2 v2.60.1-0.20260529072814-6fdb70862f77/go.mod h1:d3tOEgUd2kfsr9uuHQdY+nXrWp4uikgTgVCPdKNK30U=
7+
github.com/DataDog/datadog-api-client-go/v2 v2.60.1-0.20260603114614-30670a13d419 h1:ISgA/ny2jYXAiLih3pxkGQkMJ3Fl15M+tgcesGGjLMA=
8+
github.com/DataDog/datadog-api-client-go/v2 v2.60.1-0.20260603114614-30670a13d419/go.mod h1:d3tOEgUd2kfsr9uuHQdY+nXrWp4uikgTgVCPdKNK30U=
99
github.com/DataDog/datadog-go v4.4.0+incompatible/go.mod h1:LButxg5PwREeZtORoXG3tL4fMGNddJ+vMq1mwgfaqoQ=
1010
github.com/DataDog/datadog-go v4.8.3+incompatible h1:fNGaYSuObuQb5nzeTQqowRAd9bpDIRRV4/gUtIBjh8Q=
1111
github.com/DataDog/datadog-go v4.8.3+incompatible/go.mod h1:LButxg5PwREeZtORoXG3tL4fMGNddJ+vMq1mwgfaqoQ=

0 commit comments

Comments
 (0)