Skip to content

Commit

Permalink
feat: add log router dependency (#119)
Browse files Browse the repository at this point in the history
  • Loading branch information
mfroembgen authored Jun 20, 2024
1 parent c7710dc commit a5035fa
Show file tree
Hide file tree
Showing 3 changed files with 51 additions and 29 deletions.
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -138,9 +138,11 @@ Terraform module which creates a ecs app
| <a name="input_log_retention_in_days"></a> [log\_retention\_in\_days](#input\_log\_retention\_in\_days) | The number of days to retain logs for the log group | `number` | `1` | no |
| <a name="input_log_router_container_cpu"></a> [log\_router\_container\_cpu](#input\_log\_router\_container\_cpu) | The log router cpu reservation for the ECS task definition | `string` | `30` | no |
| <a name="input_log_router_container_memory_reservation"></a> [log\_router\_container\_memory\_reservation](#input\_log\_router\_container\_memory\_reservation) | The log router memory reservation for the ECS task definition | `string` | `64` | no |
| <a name="input_log_router_essential"></a> [log\_router\_essential](#input\_log\_router\_essential) | Determines whether all other containers in a task are stopped, if this container fails or stops for any reason. Due to how Terraform type casts booleans in json it is required to double quote this value | `bool` | `false` | no |
| <a name="input_log_router_image_repository"></a> [log\_router\_image\_repository](#input\_log\_router\_image\_repository) | Container registry repository url | `string` | n/a | yes |
| <a name="input_log_router_image_tag"></a> [log\_router\_image\_tag](#input\_log\_router\_image\_tag) | The default container image to use in container definition | `string` | `"stable-2.2.2"` | no |
| <a name="input_log_router_image_tag"></a> [log\_router\_image\_tag](#input\_log\_router\_image\_tag) | The default container image to use in container definition | `string` | `"stable-3.0.7"` | no |
| <a name="input_log_router_options"></a> [log\_router\_options](#input\_log\_router\_options) | The log router options to use | `map(string)` | <pre>{<br> "config-file-type": "file",<br> "config-file-value": "/fluent-bit/etc/extra.conf"<br>}</pre> | no |
| <a name="input_log_router_stop_timeout"></a> [log\_router\_stop\_timeout](#input\_log\_router\_stop\_timeout) | Time duration (in seconds) to wait before the container is forcefully killed if it doesn't exit normally on its own | `number` | `60` | no |
| <a name="input_log_router_type"></a> [log\_router\_type](#input\_log\_router\_type) | The log router type to use | `string` | `"fluentbit"` | no |
| <a name="input_metric_based_autoscaling_ignore_changes_min_max_capacity"></a> [metric\_based\_autoscaling\_ignore\_changes\_min\_max\_capacity](#input\_metric\_based\_autoscaling\_ignore\_changes\_min\_max\_capacity) | Whether or not to ignore min\_capacity/max\_capacity changes on the aws\_appautoscaling\_target of the metric based autoscaling module | `bool` | `false` | no |
| <a name="input_metric_enabled"></a> [metric\_enabled](#input\_metric\_enabled) | Defines if metrics should be written | `bool` | n/a | yes |
Expand Down
8 changes: 8 additions & 0 deletions main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,11 @@ module "container_definition" {
stop_timeout = var.container_stop_timeout
ulimits = var.ulimits
working_directory = var.working_directory

container_depends_on = [{
condition = "START"
containerName = "log_router"
}]
}

module "container_definition_fluentbit" {
Expand Down Expand Up @@ -173,6 +178,9 @@ module "container_definition_fluentbit" {
FLUENTD_PORT = 15000
TAG = "${module.this.environment}-${module.this.namespace}-${module.this.stage}-${module.this.name}"
}

essential = var.log_router_essential
stop_timeout = var.log_router_stop_timeout
}

module "service_task" {
Expand Down
68 changes: 40 additions & 28 deletions variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,16 @@ variable "alarm_kinsumer" {
description = "This can be used to override alarms for kinsumers. Keys are names of the kinsumers."
}

variable "alarm_service_resources_enabled" {
type = bool
default = false
description = "Defines if resource alarms should be created"
variable "alarm_scheduled" {
type = object({
alarm_description = optional(string)
datapoints_to_alarm = optional(number, 1)
evaluation_periods = optional(number, 1)
period = optional(number, 60)
threshold = optional(number, 0)
})
default = {}
description = "This can be used to override scheduled alarm"
}

variable "alarm_service_resources_cpu_average" {
Expand Down Expand Up @@ -78,6 +84,12 @@ variable "alarm_service_resources_cpu_maximum" {
}
}

variable "alarm_service_resources_enabled" {
type = bool
default = false
description = "Defines if resource alarms should be created"
}

variable "alarm_service_resources_memory_average" {
type = object({
datapoints_to_alarm = optional(number, 6)
Expand Down Expand Up @@ -116,18 +128,6 @@ variable "alarm_service_resources_treat_missing_data" {
description = "How to treat missing data, defaults to 'breaching'"
}

variable "alarm_scheduled" {
type = object({
alarm_description = optional(string)
datapoints_to_alarm = optional(number, 1)
evaluation_periods = optional(number, 1)
period = optional(number, 60)
threshold = optional(number, 0)
})
default = {}
description = "This can be used to override scheduled alarm"
}

variable "alb_health_check_interval" {
type = number
default = 30
Expand Down Expand Up @@ -390,12 +390,6 @@ variable "exec_enabled" {
default = true
}

variable "health_check_grace_period_seconds" {
type = number
description = "Seconds to ignore failing load balancer health checks on newly instantiated tasks to prevent premature shutdown, up to 7200. Only valid for services configured to use load balancers"
default = 0
}

variable "gosoline_metadata" {
type = object({
domain = optional(string),
Expand Down Expand Up @@ -432,6 +426,12 @@ variable "grafana_dashboard_url" {
default = null
}

variable "health_check_grace_period_seconds" {
type = number
description = "Seconds to ignore failing load balancer health checks on newly instantiated tasks to prevent premature shutdown, up to 7200. Only valid for services configured to use load balancers"
default = 0
}

variable "healthcheck" {
type = object({
command = list(string)
Expand Down Expand Up @@ -502,6 +502,12 @@ variable "log_router_container_memory_reservation" {
default = 64
}

variable "log_router_essential" {
type = bool
description = "Determines whether all other containers in a task are stopped, if this container fails or stops for any reason. Due to how Terraform type casts booleans in json it is required to double quote this value"
default = false
}

variable "log_router_image_repository" {
type = string
description = "Container registry repository url"
Expand All @@ -510,7 +516,7 @@ variable "log_router_image_repository" {
variable "log_router_image_tag" {
type = string
description = "The default container image to use in container definition"
default = "stable-2.2.2"
default = "stable-3.0.7"
}

variable "log_router_options" {
Expand All @@ -522,23 +528,29 @@ variable "log_router_options" {
}
}

variable "log_router_stop_timeout" {
type = number
description = "Time duration (in seconds) to wait before the container is forcefully killed if it doesn't exit normally on its own"
default = 60
}

variable "log_router_type" {
type = string
description = "The log router type to use"
default = "fluentbit"
}

variable "metric_enabled" {
type = bool
description = "Defines if metrics should be written"
}

variable "metric_based_autoscaling_ignore_changes_min_max_capacity" {
type = bool
description = "Whether or not to ignore min_capacity/max_capacity changes on the aws_appautoscaling_target of the metric based autoscaling module"
default = false
}

variable "metric_enabled" {
type = bool
description = "Defines if metrics should be written"
}

variable "monitoring_enabled" {
type = bool
default = true
Expand Down

0 comments on commit a5035fa

Please sign in to comment.