Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Pass CloudWatch log group name from the service module to the container definition module #168

Merged
merged 3 commits into from
Feb 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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}"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I still don't get it 😅 🤷🏽

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's an example with available variables 🙂
Thanks for reviewing!

For example, I want to create a CW log group with the /aws/ecs/${local.name}/service/${local.container_name} pattern and it was not possible in current implementation.
It was a possibility to create it additionally and pass through the variable, but I saw the same functionality for IAM roles and decided to make this small improvement to manage all required resources for ECS service logging inside the module.

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
Loading