Skip to content

Feature Request: Ability to set the retention length on CloudWatch Log Group #22

@tkalus

Description

@tkalus

Feature Request for provisioning the expected CloudWatch Log Group in TF, allowing for a retention_in_days to be set.

Something like:
logs.tf

resource "aws_cloudwatch_log_group" "lambda" {
  count = var.attach_cloudwatch_logs_policy && var.lambda_at_edge ? 0 : 1
  name = "/aws/lambda/${var.function_name}"
  retention_in_days = var.cloudwatch_logs_retention
}

resource "aws_cloudwatch_log_group" "lambda-edge" {
  count = var.attach_cloudwatch_logs_policy && var.lambda_at_edge ? 1 : 0
  name = "/aws/lambda/us-east-1.${var.function_name}"
  retention_in_days = var.cloudwatch_logs_retention
}

...with a complementary flip of the local.log_group_arns and removal of the logs:CreateLogStream perms.

On the minus-side, retention_in_days needs a value to be set, but defaulting var.cloudwatch_logs_retention to 3653 more-or-less matches the current behavior of "Never".

On the positive side, a module output detailing the Log Group makes it easier to attach a subscriber and route the logs centrally.

Thoughts?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions