diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index fe078fb..91f6626 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -11,7 +11,7 @@ repos: args: - "--args=--only=terraform_deprecated_interpolation" - "--args=--only=terraform_deprecated_index" - # - "--args=--only=terraform_unused_declarations" + - "--args=--only=terraform_unused_declarations" - "--args=--only=terraform_comment_syntax" - "--args=--only=terraform_documented_outputs" - "--args=--only=terraform_documented_variables" diff --git a/main.tf b/main.tf index 3161838..0a1452a 100644 --- a/main.tf +++ b/main.tf @@ -35,6 +35,14 @@ locals { resource "aws_ecs_cluster" "this" { name = format("%s-cluster", local.cluster_name) + dynamic "setting" { + for_each = var.is_enable_container_insights ? [true] : [] + content { + name = "containerInsights" + value = "enabled" + } + } + tags = merge( local.tags, { "Name" = format("%s-cluster", local.cluster_name) } diff --git a/variables.tf b/variables.tf index 360e3dd..b8a2462 100644 --- a/variables.tf +++ b/variables.tf @@ -23,7 +23,16 @@ variable "tags" { } /* -------------------------------------------------------------------------- */ -/* SEcurity Group */ +/* ECS Cluster */ +/* -------------------------------------------------------------------------- */ +variable "is_enable_container_insights" { + description = "Whether to be used to enable CloudWatch Container Insights for a cluster." + type = bool + default = true +} + +/* -------------------------------------------------------------------------- */ +/* Security Group */ /* -------------------------------------------------------------------------- */ variable "additional_security_group_ingress_rules" { description = "Map of ingress and any specific/overriding attributes to be created"