Skip to content

Commit

Permalink
add cloudwatch retention
Browse files Browse the repository at this point in the history
  • Loading branch information
akerl committed Apr 3, 2024
1 parent cfa9666 commit 0b063b9
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
6 changes: 5 additions & 1 deletion main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,11 @@ resource "aws_lambda_function" "this" {
}
}

resource "aws_cloudwatch_log_group" "this" {
name = "/aws/lambda/${var.function_name}"
retention_in_days = var.cloudwatch_retention_in_days
}

resource "aws_lambda_permission" "allow_source" {
function_name = aws_lambda_function.this.function_name
statement_id = "AllowExecutionFrom${title(var.source_types[count.index])}"
Expand All @@ -61,4 +66,3 @@ resource "aws_iam_role" "lambda" {
name = var.function_name
assume_role_policy = data.aws_iam_policy_document.trust.json
}

5 changes: 5 additions & 0 deletions variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -65,3 +65,8 @@ variable "source_arns" {
type = list(string)
}

variable "cloudwatch_retention_in_days" {
description = "Days to retain cloudwatch logs"
type = number
default = 0
}

0 comments on commit 0b063b9

Please sign in to comment.