Skip to content

Commit 66b273c

Browse files
committed
feat(modules/s3-bucket): statement sids for s3 bucket policies
1 parent b11e7c8 commit 66b273c

File tree

3 files changed

+8
-0
lines changed

3 files changed

+8
-0
lines changed

modules/s3-bucket/main.tf

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ data "aws_iam_policy_document" "this" {
2929
for_each = each.value.statements
3030

3131
content {
32+
sid = statement.value.sid
3233
actions = statement.value.actions
3334
effect = statement.value.effect
3435
resources = statement.value.resources

modules/s3-bucket/variables.tf

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ variable "bucket_policies" {
3939
id = optional(string, null)
4040
version = optional(string, null)
4141
statements = optional(list(object({
42+
sid = optional(string, null)
4243
actions = optional(set(string), [])
4344
effect = optional(string, "Allow")
4445
resources = optional(set(string), [])

tests/s3_bucket_unit_tests.tftest.hcl

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,7 @@ run "iam_policy_document_attributes_match" {
7878

7979
statements = [
8080
{
81+
sid = "example-sid"
8182
actions = [
8283
"s3:PutObject"
8384
]
@@ -118,6 +119,11 @@ run "iam_policy_document_attributes_match" {
118119
error_message = "Statement count mismatch"
119120
}
120121

122+
assert {
123+
condition = data.aws_iam_policy_document.this["example-policy"].statement[0].sid == var.bucket_policies["example-policy"].statements[0].sid
124+
error_message = "Statement sid mismatch"
125+
}
126+
121127
assert {
122128
condition = data.aws_iam_policy_document.this["example-policy"].statement[0].actions == var.bucket_policies["example-policy"].statements[0].actions
123129
error_message = "Statement actions mismatch"

0 commit comments

Comments
 (0)