Terraform: Disabled the log processor lambda

This commit is contained in:
Jocelyn Badgley (Twipped) 2020-09-21 10:40:12 -07:00
parent e9c6f98f3d
commit 2e16bdfe3c

View File

@ -3,79 +3,79 @@
# ----------------------------------------------------------------------------------------------------------- # -----------------------------------------------------------------------------------------------------------
# Grant the log parsing lambda access to the logs bucket # Grant the log parsing lambda access to the logs bucket
resource "aws_lambda_permission" "allow_bucket" { # resource "aws_lambda_permission" "allow_bucket" {
statement_id = "AllowExecutionFromS3Bucket" # statement_id = "AllowExecutionFromS3Bucket"
action = "lambda:InvokeFunction" # action = "lambda:InvokeFunction"
function_name = aws_lambda_function.logs_parser.arn # function_name = aws_lambda_function.logs_parser.arn
principal = "s3.amazonaws.com" # principal = "s3.amazonaws.com"
source_arn = aws_s3_bucket.logs.arn # source_arn = aws_s3_bucket.logs.arn
} # }
# ----------------------------------------------------------------------------------------------------------- # -----------------------------------------------------------------------------------------------------------
# Log Parsing Lambda # Log Parsing Lambda
data "archive_file" "logs_parser" { # data "archive_file" "logs_parser" {
type = "zip" # type = "zip"
source_dir = "${path.module}/files/decorate" # source_dir = "${path.module}/files/decorate"
output_path = "${path.module}/files/decorate.zip" # output_path = "${path.module}/files/decorate.zip"
} # }
resource "aws_lambda_function" "logs_parser" { # resource "aws_lambda_function" "logs_parser" {
filename = data.archive_file.logs_parser.output_path # filename = data.archive_file.logs_parser.output_path
function_name = "${var.site}-logs-decorator" # function_name = "${var.site}-logs-decorator"
handler = "index.handler" # handler = "index.handler"
source_code_hash = data.archive_file.logs_parser.output_base64sha256 # source_code_hash = data.archive_file.logs_parser.output_base64sha256
runtime = "nodejs12.x" # runtime = "nodejs12.x"
memory_size = "128" # memory_size = "128"
timeout = "5" # timeout = "5"
role = aws_iam_role.lambda.arn # role = aws_iam_role.lambda.arn
tags = { # tags = {
Name = "${var.site}-log-dist" # Name = "${var.site}-log-dist"
Site = var.site # Site = var.site
} # }
} # }
resource "aws_s3_bucket_notification" "bucket_notification" { # resource "aws_s3_bucket_notification" "bucket_notification" {
bucket = aws_s3_bucket.logs.id # bucket = aws_s3_bucket.logs.id
lambda_function { # lambda_function {
lambda_function_arn = aws_lambda_function.logs_parser.arn # lambda_function_arn = aws_lambda_function.logs_parser.arn
events = ["s3:ObjectCreated:*"] # events = ["s3:ObjectCreated:*"]
filter_prefix = "RAW/" # filter_prefix = "RAW/"
filter_suffix = ".gz" # filter_suffix = ".gz"
} # }
} # }
# Reduce log retention to two weeks # Reduce log retention to two weeks
resource "aws_cloudwatch_log_group" "logs_parser" { # resource "aws_cloudwatch_log_group" "logs_parser" {
name = "/aws/lambda/${aws_lambda_function.logs_parser.function_name}" # name = "/aws/lambda/${aws_lambda_function.logs_parser.function_name}"
retention_in_days = 14 # retention_in_days = 14
} # }
# ----------------------------------------------------------------------------------------------------------- # -----------------------------------------------------------------------------------------------------------
# Athena Configuration # Athena Configuration
resource "aws_s3_bucket" "athena" { # resource "aws_s3_bucket" "athena" {
bucket = "${var.site}-athena" # bucket = "${var.site}-athena"
acl = "private" # acl = "private"
tags = { # tags = {
Name = "${var.site}-athena" # Name = "${var.site}-athena"
Site = var.site # Site = var.site
} # }
} # }
resource "aws_athena_workgroup" "wg" { # resource "aws_athena_workgroup" "wg" {
name = "${var.site}-wg" # name = "${var.site}-wg"
tags = { # tags = {
Name = "${var.site}-wg" # Name = "${var.site}-wg"
Site = var.site # Site = var.site
} # }
} # }
resource "aws_athena_database" "db" { # resource "aws_athena_database" "db" {
name = var.site # name = var.site
bucket = aws_s3_bucket.athena.id # bucket = aws_s3_bucket.athena.id
} # }