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 1 commit
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
481 changes: 0 additions & 481 deletions src/README.md

This file was deleted.

4 changes: 2 additions & 2 deletions src/cloud-map.tf
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ module "cloudmap_namespace" {
for_each = { for service_connect in var.service_connect_configurations : service_connect.namespace => service_connect }

source = "cloudposse/stack-config/yaml//modules/remote-state"
version = "1.8.0"
version = "1.5.0"

component = each.key

Expand All @@ -25,7 +25,7 @@ module "cloudmap_namespace_service_discovery" {
for_each = { for service_connect in var.service_registries : service_connect.namespace => service_connect }

source = "cloudposse/stack-config/yaml//modules/remote-state"
version = "1.8.0"
version = "1.5.0"

component = each.key

Expand Down
4 changes: 2 additions & 2 deletions src/context.tf
Original file line number Diff line number Diff line change
Expand Up @@ -264,8 +264,8 @@ variable "descriptor_formats" {
Describe additional descriptors to be output in the `descriptors` output map.
Map of maps. Keys are names of descriptors. Values are maps of the form
`{
format = string
labels = list(string)
format = string
labels = list(string)
}`
(Type is `any` so the map values can later be enhanced to provide additional options.)
`format` is a Terraform format string to be passed to the `format()` function.
Expand Down
44 changes: 37 additions & 7 deletions src/datadog-agent.tf
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,24 @@ 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_app_key_ssm_parameter_name" {
type = string
default = null
description = "The SSM Parameter Name containing the Datadog App Key"
}

variable "datadog_logging_tags" {
type = map(string)
default = null
Expand All @@ -28,6 +46,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 +70,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 All @@ -54,7 +84,7 @@ locals {

module "datadog_sidecar_logs" {
source = "cloudposse/cloudwatch-logs/aws"
version = "0.6.9"
version = "0.6.6"

# if we are using datadog firelens we don't need to create a log group
count = local.enabled && var.datadog_agent_sidecar_enabled && var.datadog_sidecar_containers_logs_enabled ? 1 : 0
Expand All @@ -76,7 +106,7 @@ module "datadog_sidecar_logs" {

module "datadog_container_definition" {
source = "cloudposse/ecs-container-definition/aws"
version = "0.61.2"
version = "0.58.1"

count = local.enabled && var.datadog_agent_sidecar_enabled ? 1 : 0

Expand All @@ -87,8 +117,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 Expand Up @@ -124,7 +154,7 @@ module "datadog_container_definition" {

module "datadog_fluent_bit_container_definition" {
source = "cloudposse/ecs-container-definition/aws"
version = "0.61.2"
version = "0.58.1"

count = local.enabled && var.datadog_agent_sidecar_enabled ? 1 : 0

Expand Down
12 changes: 6 additions & 6 deletions src/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ data "aws_s3_object" "task_definition" {

module "logs" {
source = "cloudposse/cloudwatch-logs/aws"
version = "0.6.9"
version = "0.6.8"

# if we are using datadog firelens we don't need to create a log group
count = local.enabled && (!var.datadog_agent_sidecar_enabled || !var.datadog_log_method_is_firelens) ? 1 : 0
Expand Down Expand Up @@ -182,7 +182,7 @@ locals {

module "container_definition" {
source = "cloudposse/ecs-container-definition/aws"
version = "0.61.2"
version = "0.61.1"

for_each = { for k, v in local.containers_priority_terraform : k => v if local.enabled }

Expand Down Expand Up @@ -254,7 +254,7 @@ locals {

module "ecs_alb_service_task" {
source = "cloudposse/ecs-alb-service-task/aws"
version = "0.78.0"
version = "0.72.0"

count = local.enabled ? 1 : 0

Expand Down Expand Up @@ -342,7 +342,7 @@ resource "aws_security_group_rule" "custom_sg_rules" {

module "alb_ingress" {
source = "cloudposse/alb-ingress/aws"
version = "0.30.0"
version = "0.28.0"

count = local.is_alb ? 1 : 0

Expand Down Expand Up @@ -443,7 +443,7 @@ module "vanity_alias" {

module "ecs_cloudwatch_autoscaling" {
source = "cloudposse/ecs-cloudwatch-autoscaling/aws"
version = "1.0.0"
version = "0.7.3"

count = local.enabled && var.task_enabled && var.autoscaling_enabled ? 1 : 0

Expand Down Expand Up @@ -475,7 +475,7 @@ locals {

module "ecs_cloudwatch_sns_alarms" {
source = "cloudposse/ecs-cloudwatch-sns-alarms/aws"
version = "0.13.2"
version = "0.12.3"
count = local.enabled && var.autoscaling_enabled ? 1 : 0

cluster_name = module.ecs_cluster.outputs.cluster_name
Expand Down
26 changes: 10 additions & 16 deletions src/remote-state.tf
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ locals {

module "vpc" {
source = "cloudposse/stack-config/yaml//modules/remote-state"
version = "1.8.0"
version = "1.5.0"

component = "vpc"

Expand All @@ -65,7 +65,7 @@ module "vpc" {
module "security_group" {
count = local.enabled && var.task_security_group_component != null ? 1 : 0
source = "cloudposse/stack-config/yaml//modules/remote-state"
version = "1.8.0"
version = "1.5.0"

component = var.task_security_group_component

Expand All @@ -75,7 +75,7 @@ module "security_group" {
module "rds" {
count = local.enabled && var.use_rds_client_sg && try(length(var.rds_name), 0) > 0 ? 1 : 0
source = "cloudposse/stack-config/yaml//modules/remote-state"
version = "1.8.0"
version = "1.5.0"

component = var.rds_name

Expand All @@ -84,7 +84,7 @@ module "rds" {

module "ecs_cluster" {
source = "cloudposse/stack-config/yaml//modules/remote-state"
version = "1.8.0"
version = "1.5.0"

component = coalesce(var.ecs_cluster_name, "ecs-cluster")

Expand All @@ -93,7 +93,7 @@ module "ecs_cluster" {

module "alb" {
source = "cloudposse/stack-config/yaml//modules/remote-state"
version = "1.8.0"
version = "1.5.0"

count = local.is_alb && local.use_external_lb ? 1 : 0

Expand All @@ -104,7 +104,7 @@ module "alb" {

module "nlb" {
source = "cloudposse/stack-config/yaml//modules/remote-state"
version = "1.8.0"
version = "1.5.0"

count = local.is_nlb ? 1 : 0

Expand All @@ -115,7 +115,7 @@ module "nlb" {

module "s3" {
source = "cloudposse/stack-config/yaml//modules/remote-state"
version = "1.8.0"
version = "1.5.0"

count = local.s3_mirroring_enabled ? 1 : 0

Expand All @@ -127,7 +127,7 @@ module "s3" {

module "service_domain" {
source = "cloudposse/stack-config/yaml//modules/remote-state"
version = "1.8.0"
version = "1.5.0"

component = var.zone_component

Expand All @@ -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 All @@ -169,7 +163,7 @@ data "aws_kms_alias" "selected" {

module "iam_role" {
source = "cloudposse/stack-config/yaml//modules/remote-state"
version = "1.8.0"
version = "1.5.0"
count = local.enabled && var.task_iam_role_component != null ? 1 : 0

component = var.task_iam_role_component
Expand All @@ -181,7 +175,7 @@ module "efs" {
for_each = local.efs_component_map

source = "cloudposse/stack-config/yaml//modules/remote-state"
version = "1.8.0"
version = "1.5.0"

# Here we can use [0] because aws only allows one efs volume configuration per volume
component = each.value.efs_volume_configuration[0].component
Expand Down
Loading