Skip to content

Commit

Permalink
fix: Missing log group
Browse files Browse the repository at this point in the history
  • Loading branch information
oliversalzburg committed Nov 30, 2024
1 parent 72c8014 commit 880dda1
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 2 deletions.
1 change: 1 addition & 0 deletions terraform/modules/kitten-science-website/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ No modules.
| [aws_acm_certificate.this](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/acm_certificate) | resource |
| [aws_acm_certificate_validation.this](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/acm_certificate_validation) | resource |
| [aws_cloudfront_distribution.this](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/cloudfront_distribution) | resource |
| [aws_cloudwatch_log_group.redirect](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/cloudwatch_log_group) | resource |
| [aws_iam_policy.lambda_logging](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/iam_policy) | resource |
| [aws_iam_role.redirect](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/iam_role) | resource |
| [aws_iam_role_policy_attachment.aws_xray_write_only_access](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/iam_role_policy_attachment) | resource |
Expand Down
22 changes: 20 additions & 2 deletions terraform/modules/kitten-science-website/lambda-edge.tf
Original file line number Diff line number Diff line change
Expand Up @@ -40,15 +40,21 @@ resource "aws_iam_policy" "lambda_logging" {
path = "/"
description = "IAM policy for logging from a Lambda"
policy = data.aws_iam_policy_document.lambda_logging.json

provider = aws.global
}

resource "aws_iam_role_policy_attachment" "lambda_logs" {
role = aws_iam_role.redirect.name
policy_arn = aws_iam_policy.lambda_logging.arn

provider = aws.global
}
resource "aws_iam_role_policy_attachment" "aws_xray_write_only_access" {
role = aws_iam_role.redirect.name
policy_arn = data.aws_iam_policy.aws_xray_write_only_access.arn

provider = aws.global
}

resource "aws_iam_role" "redirect" {
Expand All @@ -75,9 +81,17 @@ resource "aws_lambda_permission" "edgelambda" {
provider = aws.global
}

resource "aws_cloudwatch_log_group" "redirect" {
name = "/aws/lambda/${var.lambda_function_name}"
retention_in_days = 14

provider = aws.global
}

resource "aws_lambda_function" "redirect" {
depends_on = [
aws_iam_role_policy_attachment.lambda_logs
aws_iam_role_policy_attachment.lambda_logs,
aws_cloudwatch_log_group.redirect
]

description = "Redirects requests to release URLs"
Expand All @@ -86,9 +100,13 @@ resource "aws_lambda_function" "redirect" {
handler = "redirect.handler"
publish = true
role = aws_iam_role.redirect.arn
runtime = "nodejs20.x"
runtime = "nodejs22.x"
source_code_hash = data.archive_file.redirect.output_base64sha256

logging_config {
log_format = "Text"
}

tracing_config {
mode = "Active"
}
Expand Down

0 comments on commit 880dda1

Please sign in to comment.