Skip to content

Commit

Permalink
add encryption enforcement
Browse files Browse the repository at this point in the history
  • Loading branch information
ashle001 committed Jun 22, 2020
1 parent d7f3ab6 commit cdb73b6
Showing 1 changed file with 32 additions and 0 deletions.
32 changes: 32 additions & 0 deletions main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,38 @@ resource "aws_s3_bucket" "this" {
prevent_destroy = true
}

data "aws_iam_policy_document" "t26_s3" {
statement {
sid = "DenyIncorrectEncryptionHeader"
effect = "Deny"
actions = ["s3:PutObject"]
principals {
type = "AWS"
identifiers = ["*"]
}
resources = ["${aws_s3_bucket.t26.arn}/*"]
condition {
test = "StringNotEquals"
variable = "s3:x-amz-server-side-encryption"
values = ["aws:kms"]
}
}
statement {
sid = "DenyUnEncryptedObjectUploads"
effect = "Deny"
actions = ["s3:PutObject"]
principals {
type = "AWS"
identifiers = ["*"]
}
resources = ["${aws_s3_bucket.t26.arn}/*"]
condition {
test = "Null"
variable = "s3:x-amz-server-side-encryption"
values = ["true"]
}
}

tags = merge(
var.tags,
local.enforced_tags,
Expand Down

0 comments on commit cdb73b6

Please sign in to comment.