Skip to content

Commit 209d8e3

Browse files
committed
refactor: ensure consistent naming for IAM action keys in Terraform module
1 parent 1cf13e7 commit 209d8e3

File tree

1 file changed

+10
-10
lines changed

1 file changed

+10
-10
lines changed

modules/config-lambda/resources.tf

+10-10
Original file line numberDiff line numberDiff line change
@@ -56,15 +56,15 @@ locals {
5656
for resource in try(definition.resources, []) : {
5757
bucketId = resource.s3.bucketId
5858
actions = resource.s3.actions
59-
iamActions = try(flatten([resource.dynamodb.iamActions]), [])
59+
iam_actions = try(flatten([resource.dynamodb.iamActions]), [])
6060
actions_string = join(",", sort(toset(flatten([resource.s3.actions, try(resource.s3.iamActions, [])]))))
6161
} if try(resource.s3, null) != null
6262
]
6363
dynamodb = [
6464
for resource in try(definition.resources, []) : {
6565
tableId = resource.dynamodb.tableId
6666
actions = resource.dynamodb.actions
67-
iamActions = try(flatten([resource.dynamodb.iamActions]), [])
67+
iam_actions = try(flatten([resource.dynamodb.iamActions]), [])
6868
actions_string = join(",", sort(toset(flatten([resource.dynamodb.actions, try(resource.dynamodb.iamActions, [])]))))
6969
} if try(resource.dynamodb, null) != null
7070
]
@@ -153,27 +153,27 @@ data "aws_iam_policy_document" "s3_access" {
153153
for_each = merge([
154154
for bucket in each.value : zipmap(
155155
[bucket.actions_string],
156-
[bucket.actions]
156+
[{ actions = table.actions, iam_actions = table.iam_actions }]
157157
)
158158
]...)
159159

160160
content {
161161
effect = "Allow"
162162

163163
actions = toset(concat(
164-
anytrue([for action in ["read", "get"] : contains(statement.value, action)]) ? [
164+
anytrue([for action in ["read", "get"] : contains(statement.value.actions, action)]) ? [
165165
"s3:GetObject",
166166
] : [],
167-
anytrue([for action in ["read", "list"] : contains(statement.value, action)]) ? [
167+
anytrue([for action in ["read", "list"] : contains(statement.value.actions, action)]) ? [
168168
"s3:ListBucket",
169169
] : [],
170-
contains(statement.value, "write") ? [
170+
contains(statement.value.actions, "write") ? [
171171
"s3:PutObject",
172172
] : [],
173-
contains(statement.value, "delete") ? [
173+
contains(statement.value.actions, "delete") ? [
174174
"s3:DeleteObject",
175175
] : [],
176-
statement.value.iamActions,
176+
statement.value.iam_actions,
177177
))
178178

179179
resources = flatten([
@@ -193,7 +193,7 @@ data "aws_iam_policy_document" "dynamodb_access" {
193193
for_each = merge([
194194
for table in each.value : zipmap(
195195
[table.actions_string],
196-
[{ actions = table.actions, iamActions = table.iamActions }]
196+
[{ actions = table.actions, iam_actions = table.iam_actions }]
197197
)
198198
]...)
199199

@@ -219,7 +219,7 @@ data "aws_iam_policy_document" "dynamodb_access" {
219219
contains(statement.value.actions, "scan") ? [
220220
"dynamodb:Scan",
221221
] : [],
222-
statement.value.iamActions,
222+
statement.value.iam_actions,
223223
))
224224

225225
resources = flatten([

0 commit comments

Comments
 (0)