-
Notifications
You must be signed in to change notification settings - Fork 389
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_logs_archives] Handle encryption field for S3 destinations for Logs Archives #2740
base: master
Are you sure you want to change the base?
Changes from 13 commits
0b3fc25
1d97952
a9766fa
a863d0e
c94b4ee
c194f0f
d0da016
170795c
dcd3296
55f644e
9509b26
cf35c9a
a2db65a
b2a921e
a6f01b9
a3fe5bb
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -43,7 +43,9 @@ func resourceDatadogLogsArchive() *schema.Resource { | |
Required: true, | ||
ValidateDiagFunc: validators.ValidateAWSAccountID, | ||
}, | ||
"role_name": {Description: "Your AWS role name", Type: schema.TypeString, Required: true}, | ||
"role_name": {Description: "Your AWS role name", Type: schema.TypeString, Required: true}, | ||
"encryption_type": {Description: "The type of encryption on your archive.", Type: schema.TypeString, Optional: true, Default: "NO_OVERRIDE"}, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think these should be in its own
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It should not conflict. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I created the optional encryption block. I was originally getting errors when testing a resource that didn't have any encryption information, since it's not required to provide it (the first step in The terraform error output displays |
||
"encryption_key": {Description: "The AWS KMS encryption key.", Type: schema.TypeString, Optional: true}, | ||
}, | ||
}, | ||
}, | ||
|
@@ -253,8 +255,15 @@ func buildGCSMap(destination datadogV2.LogsArchiveDestinationGCS) map[string]int | |
func buildS3Map(destination datadogV2.LogsArchiveDestinationS3) map[string]interface{} { | ||
result := make(map[string]interface{}) | ||
integration := destination.GetIntegration() | ||
encryption := destination.GetEncryption() | ||
result["account_id"] = integration.GetAccountId() | ||
result["role_name"] = integration.GetRoleName() | ||
if encryptionType, ok := encryption.GetTypeOk(); ok { | ||
result["encryption_type"] = encryptionType | ||
} | ||
if encryptionKey, ok := encryption.GetKeyOk(); ok { | ||
result["encryption_key"] = encryptionKey | ||
} | ||
result["bucket"] = destination.GetBucket() | ||
result["path"] = destination.GetPath() | ||
return result | ||
|
@@ -426,6 +435,17 @@ func buildS3Destination(dest interface{}) (*datadogV2.LogsArchiveDestinationS3, | |
*integration, | ||
datadogV2.LOGSARCHIVEDESTINATIONS3TYPE_S3, | ||
) | ||
encryptionType, ok := d["encryption_type"] | ||
if ok && encryptionType != "" { | ||
encryption := datadogV2.NewLogsArchiveEncryptionS3( | ||
datadogV2.LogsArchiveEncryptionS3Type(encryptionType.(string)), | ||
) | ||
encryptionKey, ok := d["encryption_key"] | ||
if ok && encryptionKey != "" { | ||
encryption.SetKey(encryptionKey.(string)) | ||
} | ||
destination.SetEncryption(*encryption) | ||
} | ||
destination.Path = datadog.PtrString(path.(string)) | ||
return destination, nil | ||
} | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
2021-03-12T17:11:37.185942-05:00 | ||
2025-01-23T18:41:36.656668-05:00 |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,90 +1,181 @@ | ||
--- | ||
version: 2 | ||
interactions: | ||
- request: | ||
body: | | ||
{"data":{"attributes":{"archive_ids":[]},"type":"archive_order"}} | ||
form: {} | ||
headers: | ||
Accept: | ||
- application/json | ||
Content-Type: | ||
- application/json | ||
url: https://api.datadoghq.com/api/v2/logs/config/archive-order | ||
method: PUT | ||
id: 0 | ||
response: | ||
body: '{"errors":["Missing order for archive FDhaAaBtQ9yXG41RPzHFzQ"]}' | ||
headers: | ||
Content-Type: | ||
- application/json | ||
status: 422 Unprocessable Entity | ||
code: 422 | ||
duration: "0ms" | ||
- request: | ||
body: "" | ||
form: {} | ||
headers: | ||
Accept: | ||
- application/json | ||
url: https://api.datadoghq.com/api/v2/logs/config/archive-order | ||
method: GET | ||
id: 1 | ||
response: | ||
body: '{"data":{"type":"archive_order","attributes":{"archive_ids":["FDhaAaBtQ9yXG41RPzHFzQ"]}}}' | ||
headers: | ||
Content-Type: | ||
- application/json | ||
status: 200 OK | ||
code: 200 | ||
duration: "0ms" | ||
- request: | ||
body: "" | ||
form: {} | ||
headers: | ||
Accept: | ||
- application/json | ||
url: https://api.datadoghq.com/api/v2/logs/config/archive-order | ||
method: GET | ||
id: 2 | ||
response: | ||
body: '{"data":{"type":"archive_order","attributes":{"archive_ids":["FDhaAaBtQ9yXG41RPzHFzQ"]}}}' | ||
headers: | ||
Content-Type: | ||
- application/json | ||
status: 200 OK | ||
code: 200 | ||
duration: "0ms" | ||
- request: | ||
body: "" | ||
form: {} | ||
headers: | ||
Accept: | ||
- application/json | ||
url: https://api.datadoghq.com/api/v2/logs/config/archive-order | ||
method: GET | ||
id: 3 | ||
response: | ||
body: '{"data":{"type":"archive_order","attributes":{"archive_ids":["FDhaAaBtQ9yXG41RPzHFzQ"]}}}' | ||
headers: | ||
Content-Type: | ||
- application/json | ||
status: 200 OK | ||
code: 200 | ||
duration: "0ms" | ||
- request: | ||
body: "" | ||
form: {} | ||
headers: | ||
Accept: | ||
- application/json | ||
url: https://api.datadoghq.com/api/v2/logs/config/archive-order | ||
method: GET | ||
id: 4 | ||
response: | ||
body: '{"data":{"type":"archive_order","attributes":{"archive_ids":["FDhaAaBtQ9yXG41RPzHFzQ"]}}}' | ||
headers: | ||
Content-Type: | ||
- application/json | ||
status: 200 OK | ||
code: 200 | ||
duration: "0ms" | ||
- id: 0 | ||
request: | ||
proto: HTTP/1.1 | ||
proto_major: 1 | ||
proto_minor: 1 | ||
content_length: 66 | ||
transfer_encoding: [] | ||
trailer: {} | ||
host: api.datadoghq.com | ||
remote_addr: "" | ||
request_uri: "" | ||
body: | | ||
{"data":{"attributes":{"archive_ids":[]},"type":"archive_order"}} | ||
form: {} | ||
headers: | ||
Accept: | ||
- application/json | ||
Content-Type: | ||
- application/json | ||
url: https://api.datadoghq.com/api/v2/logs/config/archive-order | ||
method: PUT | ||
response: | ||
proto: HTTP/1.1 | ||
proto_major: 1 | ||
proto_minor: 1 | ||
transfer_encoding: | ||
- chunked | ||
trailer: {} | ||
content_length: -1 | ||
uncompressed: true | ||
body: | | ||
{"errors":["Missing order for archive BKmiim5bQXC9RDfsaq9bjQ"]} | ||
headers: | ||
Content-Type: | ||
- application/json | ||
status: 422 Unprocessable Entity | ||
code: 422 | ||
duration: 147.416375ms | ||
- id: 1 | ||
request: | ||
proto: HTTP/1.1 | ||
proto_major: 1 | ||
proto_minor: 1 | ||
content_length: 0 | ||
transfer_encoding: [] | ||
trailer: {} | ||
host: api.datadoghq.com | ||
remote_addr: "" | ||
request_uri: "" | ||
body: "" | ||
form: {} | ||
headers: | ||
Accept: | ||
- application/json | ||
url: https://api.datadoghq.com/api/v2/logs/config/archive-order | ||
method: GET | ||
response: | ||
proto: HTTP/1.1 | ||
proto_major: 1 | ||
proto_minor: 1 | ||
transfer_encoding: | ||
- chunked | ||
trailer: {} | ||
content_length: -1 | ||
uncompressed: true | ||
body: | | ||
{"data":{"type":"archive_order","attributes":{"archive_ids":["FDhaAaBtQ9yXG41RPzHFzQ","k97y1-gSTWKLXkJwfmNVbQ","s8blIHa5QmmFJZkyYK-MQg","CbNClyqUTbaVHga-YXGkIQ","BKmiim5bQXC9RDfsaq9bjQ","eEXtNWT_TamG48WUDiyGNQ"]}}} | ||
headers: | ||
Content-Type: | ||
- application/json | ||
status: 200 OK | ||
code: 200 | ||
duration: 70.391916ms | ||
- id: 2 | ||
request: | ||
proto: HTTP/1.1 | ||
proto_major: 1 | ||
proto_minor: 1 | ||
content_length: 0 | ||
transfer_encoding: [] | ||
trailer: {} | ||
host: api.datadoghq.com | ||
remote_addr: "" | ||
request_uri: "" | ||
body: "" | ||
form: {} | ||
headers: | ||
Accept: | ||
- application/json | ||
url: https://api.datadoghq.com/api/v2/logs/config/archive-order | ||
method: GET | ||
response: | ||
proto: HTTP/1.1 | ||
proto_major: 1 | ||
proto_minor: 1 | ||
transfer_encoding: | ||
- chunked | ||
trailer: {} | ||
content_length: -1 | ||
uncompressed: true | ||
body: | | ||
{"data":{"type":"archive_order","attributes":{"archive_ids":["FDhaAaBtQ9yXG41RPzHFzQ","k97y1-gSTWKLXkJwfmNVbQ","s8blIHa5QmmFJZkyYK-MQg","CbNClyqUTbaVHga-YXGkIQ","BKmiim5bQXC9RDfsaq9bjQ","eEXtNWT_TamG48WUDiyGNQ"]}}} | ||
headers: | ||
Content-Type: | ||
- application/json | ||
status: 200 OK | ||
code: 200 | ||
duration: 77.23625ms | ||
- id: 3 | ||
request: | ||
proto: HTTP/1.1 | ||
proto_major: 1 | ||
proto_minor: 1 | ||
content_length: 0 | ||
transfer_encoding: [] | ||
trailer: {} | ||
host: api.datadoghq.com | ||
remote_addr: "" | ||
request_uri: "" | ||
body: "" | ||
form: {} | ||
headers: | ||
Accept: | ||
- application/json | ||
url: https://api.datadoghq.com/api/v2/logs/config/archive-order | ||
method: GET | ||
response: | ||
proto: HTTP/1.1 | ||
proto_major: 1 | ||
proto_minor: 1 | ||
transfer_encoding: | ||
- chunked | ||
trailer: {} | ||
content_length: -1 | ||
uncompressed: true | ||
body: | | ||
{"data":{"type":"archive_order","attributes":{"archive_ids":["FDhaAaBtQ9yXG41RPzHFzQ","k97y1-gSTWKLXkJwfmNVbQ","s8blIHa5QmmFJZkyYK-MQg","CbNClyqUTbaVHga-YXGkIQ","BKmiim5bQXC9RDfsaq9bjQ","eEXtNWT_TamG48WUDiyGNQ"]}}} | ||
headers: | ||
Content-Type: | ||
- application/json | ||
status: 200 OK | ||
code: 200 | ||
duration: 66.465667ms | ||
- id: 4 | ||
request: | ||
proto: HTTP/1.1 | ||
proto_major: 1 | ||
proto_minor: 1 | ||
content_length: 0 | ||
transfer_encoding: [] | ||
trailer: {} | ||
host: api.datadoghq.com | ||
remote_addr: "" | ||
request_uri: "" | ||
body: "" | ||
form: {} | ||
headers: | ||
Accept: | ||
- application/json | ||
url: https://api.datadoghq.com/api/v2/logs/config/archive-order | ||
method: GET | ||
response: | ||
proto: HTTP/1.1 | ||
proto_major: 1 | ||
proto_minor: 1 | ||
transfer_encoding: | ||
- chunked | ||
trailer: {} | ||
content_length: -1 | ||
uncompressed: true | ||
body: | | ||
{"data":{"type":"archive_order","attributes":{"archive_ids":["FDhaAaBtQ9yXG41RPzHFzQ","k97y1-gSTWKLXkJwfmNVbQ","s8blIHa5QmmFJZkyYK-MQg","CbNClyqUTbaVHga-YXGkIQ","BKmiim5bQXC9RDfsaq9bjQ","eEXtNWT_TamG48WUDiyGNQ"]}}} | ||
headers: | ||
Content-Type: | ||
- application/json | ||
status: 200 OK | ||
code: 200 | ||
duration: 69.449ms |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
2021-03-12T17:11:39.333811-05:00 | ||
2025-01-23T18:43:49.757164-05:00 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does sending a default value all the time without an encryption key change the behavior in any way?