diff --git a/example/modules/application/ecs.tf b/example/modules/application/ecs.tf index 89c3323..e7c6675 100644 --- a/example/modules/application/ecs.tf +++ b/example/modules/application/ecs.tf @@ -52,17 +52,17 @@ resource "aws_ecs_service" "service" { } -# Uncomment below to enable load balancer support for your application. -# You'll have to create variables & pass the list of target group ARNs to the module. -# dynamic "load_balancer" { -# for_each = var.target_group_arns -# -# content { -# target_group_arn = load_balancer.value -# container_name = local.ecs_service_name -# container_port = 8080 -# } -# } + # Uncomment below to enable load balancer support for your application. + # You'll have to create variables & pass the list of target group ARNs to the module. + # dynamic "load_balancer" { + # for_each = var.target_group_arns + # + # content { + # target_group_arn = load_balancer.value + # container_name = local.ecs_service_name + # container_port = 8080 + # } + # } lifecycle { ignore_changes = [ @@ -171,11 +171,16 @@ resource "aws_ecs_task_definition" "task_definition" { # This duplicates the configuration in the CloudMap service resource ("aws_service_discovery_service.service_discovery") # just to show how to set the same configuration at the ECS Task level. These configuration are resolved in a specific order. # See appsettings.json for more details. - "METRICS_PORT" = "8080" - "METRICS_PATH" = "/metrics" - "METRICS_NAME" = "/application" - "METRICS_PORT_ECS" = "9779" - "METRICS_PATH_ECS" = "/metrics" - "METRICS_NAME_ECS" = "ecs-exporter" + "METRICS_PORT" = "8080" + "METRICS_PATH" = "/metrics" + "METRICS_NAME" = "/application" + "METRICS_PORT_ECS" = "9779" + "METRICS_PATH_ECS" = "/metrics" + "METRICS_NAME_ECS" = "ecs-exporter" + # This needs to alight with the "DiscoveryOptions__EcsServiceSelectorTags" + # in the "aws-ecs-cloudmap-prometheus-discovery" application. + # This allows to discover and scrape only those applications, + # which you're interested in. + "PROMETHEUS_TARGET" = "true" }) } diff --git a/example/modules/monitoring/ecs.tf b/example/modules/monitoring/ecs.tf index ecf03f2..4ef49cb 100644 --- a/example/modules/monitoring/ecs.tf +++ b/example/modules/monitoring/ecs.tf @@ -65,6 +65,7 @@ resource "aws_ecs_task_definition" "task_definition" { value = var.ecs_cluster_name }, { + name = "DiscoveryOptions__EcsServiceSelectorTags" value = "PROMETHEUS_TARGET=true" }, @@ -73,6 +74,13 @@ resource "aws_ecs_task_definition" "task_definition" { value = local.region } ] + healthCheck = { + command = ["CMD-SHELL", "curl -f http://localhost:9001/health || exit 1"] + interval = 30 + timeout = 5 + retries = 3 + start_period = 60 + } logConfiguration = { logDriver = "awslogs" options = {