Skip to content

Commit

Permalink
feat(log group): add retention variable
Browse files Browse the repository at this point in the history
  • Loading branch information
sleistner committed May 18, 2020
1 parent 5fea5a5 commit b36ee07
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
9 changes: 7 additions & 2 deletions main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,9 @@ locals {
}

resource "aws_cloudwatch_log_group" "main" {
name = local.lambda_log_group_name
tags = var.tags
name = local.lambda_log_group_name
retention_in_days = var.cloudwatch_retention_in_days
tags = var.tags
}

resource "aws_cloudwatch_log_subscription_filter" "main" {
Expand All @@ -23,6 +24,10 @@ resource "aws_cloudwatch_log_subscription_filter" "main" {
name = "${var.function_name}-${var.cloudwatch_log_subscription_filter[count.index].name}"
filter_pattern = var.cloudwatch_log_subscription_filter[count.index].filter_pattern
destination_arn = var.cloudwatch_log_subscription_filter[count.index].destination_arn

depends_on = [
aws_cloudwatch_log_group.main
]
}

resource "aws_lambda_function" "main" {
Expand Down
5 changes: 5 additions & 0 deletions variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -149,3 +149,8 @@ variable "cloudwatch_log_subscription_filter" {
description = "(Optional) A list of CloudWatch Logs subscription filter."
default = null
}

variable "cloudwatch_retention_in_days" {
default = null
description = "(Optional) Specifies the number of days you want to retain log events in the specified log group."
}

0 comments on commit b36ee07

Please sign in to comment.