Skip to content

Commit

Permalink
Require SSL for export bucket; rafactor policy resource for cloudwatc…
Browse files Browse the repository at this point in the history
…h and logging buckets.
  • Loading branch information
Matthew-Grayson committed Oct 1, 2023
1 parent 0e5cfea commit a31aeae
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 5 deletions.
6 changes: 3 additions & 3 deletions infrastructure/cloudwatch.tf
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ resource "aws_s3_bucket_policy" "cloudwatch_bucket" {
"Service" : "logs.amazonaws.com"
},
"Action" : "s3:GetBucketAcl",
"Resource" : "arn:aws:s3:::${var.cloudwatch_bucket_name}"
"Resource" : aws_s3_bucket.cloudwatch_bucket.arn
},
{
"Sid" : "Allow Cloudwatch to write to bucket",
Expand All @@ -39,8 +39,8 @@ resource "aws_s3_bucket_policy" "cloudwatch_bucket" {
},
"Action" : "s3:PutObject",
"Resource" : [
"arn:aws:s3:::${var.cloudwatch_bucket_name}",
"arn:aws:s3:::${var.cloudwatch_bucket_name}/*"
aws_s3_bucket.cloudwatch_bucket.arn,
"${aws_s3_bucket.cloudwatch_bucket.arn}/*"
],
"Condition" : {
"StringEquals" : {
Expand Down
4 changes: 2 additions & 2 deletions infrastructure/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,8 @@ resource "aws_s3_bucket_policy" "logging_bucket" {
"Sid" : "Require SSL for requests",
"Effect" : "Deny",
"Resource" : [
"arn:aws:s3:::${var.logging_bucket_name}",
"arn:aws:s3:::${var.logging_bucket_name}/*"
aws_s3_bucket.logging_bucket.arn,
"${aws_s3_bucket.logging_bucket.arn}/*"
],
"Condition" : {
"Bool" : {
Expand Down
24 changes: 24 additions & 0 deletions infrastructure/worker.tf
Original file line number Diff line number Diff line change
Expand Up @@ -351,6 +351,30 @@ resource "aws_s3_bucket" "export_bucket" {
}
}

resource "aws_s3_bucket_policy" "export_bucket" {
bucket = var.export_bucket_name
policy = jsonencode({
"Version" = "2012-10-17"
"Statement" = [
{
Sid = "Require SSL for Requests"
Effect = "Deny"
Principal = "*"
Action = "s3:*"
Resource = [
aws_s3_bucket.export_bucket.arn,
"${aws_s3_bucket.export_bucket.arn}/*"
]
Condition = {
Bool = {
"aws:SecureTransport": false
}
}
}
]
})
}

resource "aws_s3_bucket_acl" "export_bucket" {
bucket = aws_s3_bucket.export_bucket.id
acl = "private"
Expand Down

0 comments on commit a31aeae

Please sign in to comment.