Skip to content

Commit

Permalink
adding Module to test if Logs for ALB work
Browse files Browse the repository at this point in the history
  • Loading branch information
Miguel Elhaiek committed Apr 9, 2024
1 parent 021c825 commit 8ad5d8c
Showing 1 changed file with 49 additions and 7 deletions.
56 changes: 49 additions & 7 deletions terraform/modules/alb_logging/main.tf
Original file line number Diff line number Diff line change
@@ -1,3 +1,38 @@
# resource "aws_s3_bucket" "logging_bucket" {
# bucket = var.bucket_name
# }

# resource "aws_s3_bucket_server_side_encryption_configuration" "logging_bucket_encryption" {
# bucket = aws_s3_bucket.logging_bucket.id

# rule {
# apply_server_side_encryption_by_default {
# sse_algorithm = "AES256"
# }
# }
# }



# data "aws_iam_policy_document" "bucket_policy" {
# statement {
# actions = ["s3:PutObject"]
# resources = ["${aws_s3_bucket.logging_bucket.arn}/*"]

# principals {
# type = "AWS"
# identifiers = ["arn:aws:iam::127311923021:root"] // ELB service account for US East (N. Virginia)
# }
# }

# // Add any additional statements here if needed
# }

# resource "aws_s3_bucket_policy" "logging_bucket_policy" {
# bucket = aws_s3_bucket.logging_bucket.id
# policy = data.aws_iam_policy_document.bucket_policy.json
# }

resource "aws_s3_bucket" "logging_bucket" {
bucket = var.bucket_name
}
Expand All @@ -11,19 +46,26 @@ data "aws_iam_policy_document" "bucket_policy" {
type = "AWS"
identifiers = ["arn:aws:iam::127311923021:root"] // ELB service account for US East (N. Virginia)
}
}

// Add any additional statements here if needed
condition {
test = "Null"
variable = "s3:x-amz-server-side-encryption"
values = ["true"]
}
}
}

resource "aws_s3_bucket_policy" "logging_bucket_policy" {
bucket = aws_s3_bucket.logging_bucket.id
policy = data.aws_iam_policy_document.bucket_policy.json
}

resource "aws_s3_bucket_server_side_encryption_configuration" "logging_bucket_encryption" {
bucket = aws_s3_bucket.logging_bucket.id


# resource "aws_s3_bucket_policy" "bucket_policy" {
# bucket = aws_s3_bucket.logging_bucket.id
# policy = data.aws_iam_policy_document.bucket_policy.json
# }
rule {
apply_server_side_encryption_by_default {
sse_algorithm = "AES256"
}
}
}

0 comments on commit 8ad5d8c

Please sign in to comment.