Skip to content

Commit 7abc181

Browse files
authored
feat: add new statement
1 parent a3c9a85 commit 7abc181

File tree

1 file changed

+19
-1
lines changed

1 file changed

+19
-1
lines changed

main.tf

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -520,9 +520,27 @@ data "aws_iam_policy_document" "bucket_policy" {
520520
values = var.source_ip_allow_list
521521
}
522522
}
523-
524523
}
525524

525+
dynamic "statement" {
526+
for_each = length(var.source_ip_allow_list_s3_objects) > 0 ? [1] : []
527+
528+
content {
529+
sid = "AllowIPPrincipalsOnObjects"
530+
effect = "Deny"
531+
actions = ["s3:*"]
532+
resources = ["${local.bucket_arn}/*"]
533+
principals {
534+
identifiers = ["*"]
535+
type = "*"
536+
}
537+
condition {
538+
test = "NotIpAddress"
539+
variable = "aws:SourceIp"
540+
values = var.source_ip_allow_list_s3_objects
541+
}
542+
}
543+
}
526544
}
527545

528546
data "aws_iam_policy_document" "aggregated_policy" {

0 commit comments

Comments
 (0)