Skip to content

Commit 0a30885

Browse files
authored
skip dynamodb in policy when dne (#43)
1 parent da5c2d4 commit 0a30885

File tree

2 files changed

+11
-5
lines changed

2 files changed

+11
-5
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,3 +76,4 @@ github/
7676
*.ovpn
7777

7878
*.zip
79+
account-map/

src/policy-TerraformUpdateAccess.tf

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -34,11 +34,16 @@ data "aws_iam_policy_document" "terraform_update_access" {
3434
"${module.tfstate.outputs.tfstate_backend_s3_bucket_arn}/*"
3535
] : []
3636
}
37-
statement {
38-
sid = "TerraformStateBackendDynamoDbTable"
39-
effect = "Allow"
40-
actions = ["dynamodb:GetItem", "dynamodb:PutItem", "dynamodb:DeleteItem"]
41-
resources = module.this.enabled ? [module.tfstate.outputs.tfstate_backend_dynamodb_table_arn] : []
37+
38+
dynamic "statement" {
39+
for_each = (module.this.enabled && module.tfstate.outputs.tfstate_backend_dynamodb_table_arn != "") ? [1] : []
40+
41+
content {
42+
sid = "TerraformStateBackendDynamoDbTable"
43+
effect = "Allow"
44+
actions = ["dynamodb:GetItem", "dynamodb:PutItem", "dynamodb:DeleteItem"]
45+
resources = [module.tfstate.outputs.tfstate_backend_dynamodb_table_arn]
46+
}
4247
}
4348
}
4449

0 commit comments

Comments
 (0)