We’ve seen current practice on create log group is on application level and using our internal building block (created by BEI). So, the instance role have permission logs:CreateLogGroup
. Currently our building block is not support in create tags when the application create log group name.
There are no hard technical issue on updating the building block to support tagging when creating log group. The downside if we put the capability of create log group name in instance (application) level are:
Based on those reasons, we ask you guys to import it for cwl log group in tvlk-prod
.
Also we have a plan to take out logs:CreateLogGroup
policy from CommonEC2 in future (we will announce it together with BEI). Currently, we are still on stage of analyze it and creating safe strategy to roll-out in multi-account, since its also impact to multi-account. The issue can be see here.
resource "aws_cloudwatch_log_group" "app_application_log" {
name = "/tvlk/app-java/abc123/application.log"
retention_in_days = "14"
tags = {
Environment = "production"
Service = "abc123"
ProductDomain = "abc"
ManagedBy = "terraform"
}
}
Log group naming follows site infra convention: CWL Logs Groups Naming.
Example:
Import on flat terraform configawsudo -u <profile> -- terraform import aws_cloudwatch_log_group.<resource_name> /tvlk/app-java/abc123/application.log
Import inside module (if you use this Terraform MongoDB Module for create log group)
General: awsudo -u <profile> – terraform import module.<your_terraform_config_module_name>.aws_cloudwatch_log_group.<resources_name_inside_module> <log group name>
awsudo -u <profile> – terraform import module.loggroup.aws_cloudwatch_log_group.mongodb_log /tvlk/mongod/abc123/mongod.log
If your existing log group haven’t following naming convention, please update it.
Reference: CWL Logs Groups Naming.
We will decommission log group name in tvlk-prod
which do not have ProductDomain Tag on:
If you have any questions, feel free to ask in this thread or in #infra-mentorship channel.
Thank you :tada: