Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
198 changes: 198 additions & 0 deletions data.tf
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,18 @@ data "aws_iam_policy_document" "guardduty_bucket_policy" {
type = "Service"
identifiers = ["guardduty.amazonaws.com"]
}

condition {
test = "StringEquals"
variable = "aws:SourceAccount"
values = [data.aws_caller_identity.current.account_id]
}

condition {
test = "StringEquals"
variable = "aws:SourceArn"
values = [aws_guardduty_detector.primary.arn]
}
}

statement {
Expand All @@ -40,6 +52,87 @@ data "aws_iam_policy_document" "guardduty_bucket_policy" {
type = "Service"
identifiers = ["guardduty.amazonaws.com"]
}

condition {
test = "StringEquals"
variable = "aws:SourceAccount"
values = [data.aws_caller_identity.current.account_id]
}

condition {
test = "StringEquals"
variable = "aws:SourceArn"
values = [aws_guardduty_detector.primary.arn]
}
}

statement {
sid = "DenyUnencryptedObjectUploads"
effect = "Deny"
actions = [
"s3:PutObject"
]

resources = [
"${module.s3_bucket[0].s3_bucket_arn}/*"
]

principals {
type = "Service"
identifiers = ["guardduty.amazonaws.com"]
}

condition {
test = "StringNotEquals"
variable = "s3:x-amz-server-side-encryption"
values = ["aws:kms"]
}
}

statement {
sid = "DenyIncorrectEncryptionHeader"
effect = "Deny"
actions = [
"s3:PutObject"
]

resources = [
"${module.s3_bucket[0].s3_bucket_arn}/*"
]

principals {
type = "Service"
identifiers = ["guardduty.amazonaws.com"]
}

condition {
test = "StringNotEquals"
variable = "s3:x-amz-server-side-encryption-aws-kms-key-id"
values = [aws_kms_key.guardduty_key[0].arn]
}
}

statement {
sid = "DenyNonHttpsAccess"
effect = "Deny"
actions = [
"s3:*"
]

resources = [
"${module.s3_bucket[0].s3_bucket_arn}/*"
]

principals {
type = "*"
identifiers = ["*"]
}

condition {
test = "Bool"
variable = "aws:SecureTransport"
values = ["false"]
}
}
}

Expand All @@ -60,6 +153,18 @@ data "aws_iam_policy_document" "guardduty_replica_bucket_policy" {
type = "Service"
identifiers = ["guardduty.amazonaws.com"]
}

condition {
test = "StringEquals"
variable = "aws:SourceAccount"
values = [data.aws_caller_identity.current.account_id]
}

condition {
test = "StringEquals"
variable = "aws:SourceArn"
values = [aws_guardduty_detector.primary.arn]
}
}

statement {
Expand All @@ -76,6 +181,87 @@ data "aws_iam_policy_document" "guardduty_replica_bucket_policy" {
type = "Service"
identifiers = ["guardduty.amazonaws.com"]
}

condition {
test = "StringEquals"
variable = "aws:SourceAccount"
values = [data.aws_caller_identity.current.account_id]
}

condition {
test = "StringEquals"
variable = "aws:SourceArn"
values = [aws_guardduty_detector.primary.arn]
}
}

statement {
sid = "DenyUnencryptedObjectUploads"
effect = "Deny"
actions = [
"s3:PutObject"
]

resources = [
"${module.replica_bucket[0].s3_bucket_arn}/*"
]

principals {
type = "Service"
identifiers = ["guardduty.amazonaws.com"]
}

condition {
test = "StringNotEquals"
variable = "s3:x-amz-server-side-encryption"
values = ["aws:kms"]
}
}

statement {
sid = "DenyIncorrectEncryptionHeader"
effect = "Deny"
actions = [
"s3:PutObject"
]

resources = [
"${module.replica_bucket[0].s3_bucket_arn}/*"
]

principals {
type = "Service"
identifiers = ["guardduty.amazonaws.com"]
}

condition {
test = "StringNotEquals"
variable = "s3:x-amz-server-side-encryption-aws-kms-key-id"
values = [aws_kms_key.guardduty_key[0].arn]
}
}

statement {
sid = "DenyNonHttpsAccess"
effect = "Deny"
actions = [
"s3:*"
]

resources = [
"${module.replica_bucket[0].s3_bucket_arn}/*"
]

principals {
type = "*"
identifiers = ["*"]
}

condition {
test = "Bool"
variable = "aws:SecureTransport"
values = ["false"]
}
}
}

Expand All @@ -96,6 +282,18 @@ data "aws_iam_policy_document" "guardduty_kms_policy" {
type = "Service"
identifiers = ["guardduty.amazonaws.com"]
}

condition {
test = "StringEquals"
variable = "aws:SourceAccount"
values = [data.aws_caller_identity.current.account_id]
}

condition {
test = "StringEquals"
variable = "aws:SourceArn"
values = [aws_guardduty_detector.primary.arn]
}
}

statement {
Expand Down