Skip to content

Commit

Permalink
fix: Pass CloudWatch log group name from the service module to the co…
Browse files Browse the repository at this point in the history
…ntainer definition module (#168)

* fix: Custom CW Log Group name definition from service module

* example of custom CW log group name definition

* move custom CW log group name to autoscaling example
  • Loading branch information
ivan-sukhomlyn authored Feb 19, 2024
1 parent 8b97783 commit 9a7c9da
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
12 changes: 12 additions & 0 deletions examples/ec2-autoscaling/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,18 @@ module "ecs_service" {

# Example image used requires access to write to root filesystem
readonly_root_filesystem = false

enable_cloudwatch_logging = true
create_cloudwatch_log_group = true
cloudwatch_log_group_name = "/aws/ecs/${local.name}/${local.container_name}"
cloudwatch_log_group_retention_in_days = 7

log_configuration = {
logDriver = "awslogs"
options = {
awslogs-region = local.region
}
}
}
}

Expand Down
1 change: 1 addition & 0 deletions modules/service/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -572,6 +572,7 @@ module "container_definition" {
service = var.name
enable_cloudwatch_logging = try(each.value.enable_cloudwatch_logging, var.container_definition_defaults.enable_cloudwatch_logging, true)
create_cloudwatch_log_group = try(each.value.create_cloudwatch_log_group, var.container_definition_defaults.create_cloudwatch_log_group, true)
cloudwatch_log_group_name = try(each.value.cloudwatch_log_group_name, var.container_definition_defaults.cloudwatch_log_group_name, null)
cloudwatch_log_group_use_name_prefix = try(each.value.cloudwatch_log_group_use_name_prefix, var.container_definition_defaults.cloudwatch_log_group_use_name_prefix, false)
cloudwatch_log_group_retention_in_days = try(each.value.cloudwatch_log_group_retention_in_days, var.container_definition_defaults.cloudwatch_log_group_retention_in_days, 14)
cloudwatch_log_group_kms_key_id = try(each.value.cloudwatch_log_group_kms_key_id, var.container_definition_defaults.cloudwatch_log_group_kms_key_id, null)
Expand Down

0 comments on commit 9a7c9da

Please sign in to comment.