From a79a67d0309631ca79e2221fec3bfd5efdb83271 Mon Sep 17 00:00:00 2001 From: Saef Taher Date: Thu, 11 Jan 2024 13:49:54 +0100 Subject: [PATCH] feat(envoy): add dependsOn on logging side car if present --- envoy.tf | 1 + fluentbit.tf | 14 +++++++++++++- variables.tf | 1 + 3 files changed, 15 insertions(+), 1 deletion(-) diff --git a/envoy.tf b/envoy.tf index 9a6d03a..9ab9ead 100644 --- a/envoy.tf +++ b/envoy.tf @@ -1,6 +1,7 @@ locals { // optional envoy container for AWS AppMesh envoy_container_defaults = { + dependsOn = var.firelens.enabled ? [{ containerName = var.firelens.container_name, condition = "HEALTHY" }] : [] name = var.app_mesh.container_name image = "${data.aws_caller_identity.current.account_id}.dkr.ecr.${data.aws_region.current.name}.amazonaws.com/ecr-public/appmesh/aws-appmesh-envoy:v1.24.0.0-prod" essential = true diff --git a/fluentbit.tf b/fluentbit.tf index d70000b..650a976 100644 --- a/fluentbit.tf +++ b/fluentbit.tf @@ -1,7 +1,7 @@ locals { // optional FluentBit container for log aggregation fluentbit_container_defaults = { - name = "fluentbit" + name = var.firelens.container_name image = "${data.aws_caller_identity.current.account_id}.dkr.ecr.${data.aws_region.current.name}.amazonaws.com/ecr-public/aws-observability/aws-for-fluent-bit:2.29.0" essential = true mountPoints = [] @@ -15,6 +15,18 @@ locals { { name = " FLB_LOG_LEVEL", value = "error" } ], + healthCheck = { + retries = 3 + command = [ + "CMD-SHELL", + "curl -s http://localhost:2020/api/v1/uptime | grep uptime_hr | grep -q running" + ] + timeout = 2 + interval = 5 + startPeriod = 10 + } + + firelensConfiguration = { type = "fluentbit" options = { diff --git a/variables.tf b/variables.tf index df65090..5dc9396 100644 --- a/variables.tf +++ b/variables.tf @@ -276,6 +276,7 @@ variable "firelens" { description = "Configuration for optional custom log routing using FireLens over fluentbit sidecar." default = {} type = object({ + container_name = optional(string, "fluentbit") container_definition = optional(any, {}) enabled = optional(bool, false) opensearch_host = optional(string, "")