目标:将 CloudWatch Group 的保留期设置为 7 天
问题:我正在使用
terraform-aws-modules/ecs
和服务子模块。当我设置 cloudwatch 日志组的保留并将 cloudwatch_log_group_retention_in_days
设置为 7
时,它不适用于以下代码。保留期默认为 12 个月。
cloudwatch_log_group_retention_in_days
对于此用例来说是正确的设置吗?我有什么遗漏的吗?
module "ecs_service" {
source = "terraform-aws-modules/ecs/aws//modules/service"
...
container_definitions = {
my_service = {
essential = true
cpu = var.cpu
memory = var.memory
image = var.container_image
port_mappings = [
{
name = var.service_name
containerPort = var.container_port
protocol = "tcp"
}
]
environment = var.environment
readonly_root_filesystem = false
# CloudWatch Log configuration
enable_cloudwatch_logging = true
create_cloudwatch_log_group = true
cloudwatch_log_group_use_name_prefix = true
cloudwatch_log_group_name = "/aws/ecs/my_cluster/my_service"
cloudwatch_log_group_retention_in_days = 7
log_configuration = {
logDriver = "awslogs"
}
}
}
...
}