File tree Expand file tree Collapse file tree 1 file changed +26
-1
lines changed
modules/agentless-s3-bucket Expand file tree Collapse file tree 1 file changed +26
-1
lines changed Original file line number Diff line number Diff line change @@ -36,7 +36,6 @@ resource "aws_s3_bucket_lifecycle_configuration" "bucket_lifecycle" {
3636}
3737
3838data "aws_iam_policy_document" "bucket_access_policy_document" {
39- # TODO: add statement to deny access to everyone except the scanner roles
4039 statement {
4140 sid = " DatadogAgentlessScannerBucketPolicy"
4241 effect = " Allow"
@@ -92,6 +91,32 @@ data "aws_iam_policy_document" "bucket_access_policy_document" {
9291 ]
9392 }
9493 }
94+
95+ statement {
96+ sid = " DenyAllOtherAccess"
97+ effect = " Deny"
98+ actions = [
99+ " s3:GetObject*" ,
100+ " s3:ListBucket" ,
101+ " s3:PutObject*" ,
102+ ]
103+ resources = [
104+ aws_s3_bucket . bucket . arn ,
105+ " ${ aws_s3_bucket . bucket . arn } /*" ,
106+ ]
107+ principals {
108+ type = " AWS"
109+ identifiers = [" *" ]
110+ }
111+ condition {
112+ test = " ArnNotEquals"
113+ variable = " aws:PrincipalArn"
114+ values = [
115+ var . iam_delegate_role_arn ,
116+ var . rds_service_role_arn ,
117+ ]
118+ }
119+ }
95120}
96121
97122resource "aws_s3_bucket_policy" "bucket_access_policy" {
You can’t perform that action at this time.
0 commit comments