Skip to content

Commit 9049e98

Browse files
committed
Set custom tags in the agent configuration file
JIRA: SEC-16411
1 parent b2767aa commit 9049e98

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

modules/user_data/main.tf

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,23 @@ locals {
33
Datadog = "true"
44
DatadogAgentlessScanner = "true"
55
}
6+
dd_tags_list = [for k, v in local.dd_tags : "${k}:${v}"]
67
}
78

89
data "aws_region" "current" {}
910

1011
locals {
1112
api_key_secret_arn = var.api_key_secret_arn != null ? var.api_key_secret_arn : aws_secretsmanager_secret.api_key[0].arn
13+
# Add custom tags to the agent configuration.
14+
custom_agent_configuration = merge(
15+
var.agent_configuration,
16+
{
17+
tags = concat(
18+
lookup(var.agent_configuration, "tags", []), # Safely get existing tags or default to an empty list
19+
local.dd_tags_list
20+
)
21+
}
22+
)
1223
}
1324

1425
resource "aws_secretsmanager_secret" "api_key" {
@@ -37,7 +48,7 @@ resource "terraform_data" "template" {
3748
scanner_version = var.scanner_version,
3849
scanner_channel = var.scanner_channel,
3950
scanner_configuration = var.scanner_configuration,
40-
agent_configuration = var.agent_configuration,
51+
agent_configuration = local.custom_agent_configuration,
4152
region = data.aws_region.current.name,
4253
})
4354
}

0 commit comments

Comments
 (0)