Skip to content

Commit

Permalink
config: modify bucket policies to Deny HTTP requests
Browse files Browse the repository at this point in the history
  • Loading branch information
darneymartin committed Apr 26, 2022
1 parent 3a34dcf commit c74dbd1
Showing 1 changed file with 36 additions and 0 deletions.
36 changes: 36 additions & 0 deletions s3.tf
Original file line number Diff line number Diff line change
Expand Up @@ -47,3 +47,39 @@ resource "aws_s3_bucket_public_access_block" "bucket" {
block_public_policy = true
restrict_public_buckets = true
}

# Bucket Policy
resource "aws_s3_bucket_policy" "bucket_policy" {
bucket = aws_s3_bucket.bucket.id
policy = data.aws_iam_policy_document.bucket_policy_document.json
}



# Bucket Policy Document
data "aws_iam_policy_document" "bucket_policy_document" {
depends_on = [
aws_s3_bucket.bucket
]

# Deny Cleartext (HTTP) Communication

statement {
actions = ["s3:*"]
effect = "Deny"
resources = [
"${aws_s3_bucket.bucket.arn}",
"${aws_s3_bucket.bucket.arn}/*"
]
condition {
test = "Bool"
variable = "aws:SecureTransport"
values = ["false"]
}
principals {
type = "*"
identifiers = ["*"]
}
}
}

0 comments on commit c74dbd1

Please sign in to comment.