Skip to content

remove datadog lookup #39

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

Merged
merged 5 commits into from
Jun 16, 2025
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
32 changes: 28 additions & 4 deletions src/datadog-agent.tf
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,18 @@ variable "datadog_sidecar_containers_logs_enabled" {
description = "Enable the Datadog Agent Sidecar to send logs to aws cloudwatch group, requires `datadog_agent_sidecar_enabled` to be true"
}

variable "datadog_api_key_ssm_parameter_name" {
type = string
default = null
description = "The SSM Parameter Name containing the Datadog API Key"
}

variable "datadog_site" {
type = string
default = "us5.datadoghq.com"
description = "The Datadog Site to send logs to"
}

variable "datadog_logging_tags" {
type = map(string)
default = null
Expand All @@ -28,6 +40,18 @@ variable "datadog_logging_default_tags_enabled" {
description = "Add Default tags to all logs sent to Datadog"
}

data "aws_ssm_parameter" "datadog_api_key" {
count = var.datadog_api_key_ssm_parameter_name != null && var.datadog_agent_sidecar_enabled ? 1 : 0

name = var.datadog_api_key_ssm_parameter_name
}

data "aws_ssm_parameter" "datadog_app_key" {
count = var.datadog_app_key_ssm_parameter_name != null && var.datadog_agent_sidecar_enabled ? 1 : 0

name = var.datadog_app_key_ssm_parameter_name
}

locals {
default_datadog_tags = var.datadog_logging_default_tags_enabled ? {
env = module.this.stage
Expand All @@ -40,8 +64,8 @@ locals {
logDriver = "awsfirelens"
options = var.datadog_agent_sidecar_enabled ? {
Name = "datadog",
apikey = module.datadog_configuration.datadog_api_key,
Host = format("http-intake.logs.%s", module.datadog_configuration.datadog_site)
apikey = one(data.aws_ssm_parameter.datadog_api_key[*].value),
Host = format("http-intake.logs.%s", var.datadog_site)
dd_service = module.this.name,
dd_tags = local.all_dd_tags,
dd_source = "ecs",
Expand Down Expand Up @@ -87,8 +111,8 @@ module "datadog_container_definition" {
essential = true
map_environment = {
"ECS_FARGATE" = var.task.launch_type == "FARGATE" ? true : false
"DD_API_KEY" = module.datadog_configuration.datadog_api_key
"DD_SITE" = module.datadog_configuration.datadog_site
"DD_API_KEY" = one(data.aws_ssm_parameter.datadog_api_key[*].value)
"DD_SITE" = var.datadog_site
"DD_ENV" = module.this.stage
"DD_LOGS_ENABLED" = true
"DD_LOGS_CONFIG_CONTAINER_COLLECT_ALL" = true
Expand Down
6 changes: 0 additions & 6 deletions src/remote-state.tf
Original file line number Diff line number Diff line change
Expand Up @@ -140,12 +140,6 @@ data "jq_query" "service_domain_query" {
query = var.zone_component_output
}

module "datadog_configuration" {
source = "github.com/cloudposse-terraform-components/aws-datadog-credentials//src/modules/datadog_keys?ref=tags/v1.535.2"
enabled = true
context = module.this.context
}

# This is purely a check to ensure this zone exists
# tflint-ignore: terraform_unused_declarations
data "aws_route53_zone" "selected" {
Expand Down
Loading