Skip to content

Commit 1cf13e7

Browse files
authored
feat: add custom IAM actions to S3 resources (#11)
1 parent 4312794 commit 1cf13e7

File tree

4 files changed

+15
-1
lines changed

4 files changed

+15
-1
lines changed

modules/config-lambda/resources.tf

+3-1
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,8 @@ locals {
5656
for resource in try(definition.resources, []) : {
5757
bucketId = resource.s3.bucketId
5858
actions = resource.s3.actions
59-
actions_string = join(",", sort(toset(resource.s3.actions)))
59+
iamActions = try(flatten([resource.dynamodb.iamActions]), [])
60+
actions_string = join(",", sort(toset(flatten([resource.s3.actions, try(resource.s3.iamActions, [])]))))
6061
} if try(resource.s3, null) != null
6162
]
6263
dynamodb = [
@@ -172,6 +173,7 @@ data "aws_iam_policy_document" "s3_access" {
172173
contains(statement.value, "delete") ? [
173174
"s3:DeleteObject",
174175
] : [],
176+
statement.value.iamActions,
175177
))
176178

177179
resources = flatten([

src/definition/resources/s3.schema.ts

+1
Original file line numberDiff line numberDiff line change
@@ -4,5 +4,6 @@ export const s3Resource = $object({
44
s3: $object({
55
bucketId: $string().describe('The ID of the bucket.'),
66
actions: $enum(['read', 'write', 'delete', 'get', 'list']).array({ minItems: 1 }),
7+
iamActions: $string().array().optional().describe('Custom IAM actions to add to the role.'),
78
}).describe('An S3 bucket that is used by the function.'),
89
}).describe('An S3 bucket that is used by the function.')

src/definition/resources/s3.type.ts

+4
Original file line numberDiff line numberDiff line change
@@ -19,5 +19,9 @@ export interface S3Resource {
1919
*/
2020
bucketId: string
2121
actions: [S3ResourceActionsArray, ...S3ResourceActionsArray[]]
22+
/**
23+
* Custom IAM actions to add to the role.
24+
*/
25+
iamActions?: string[] | undefined
2226
}
2327
}

src/definition/schemas/star-chart-handler.schema.json

+7
Original file line numberDiff line numberDiff line change
@@ -608,6 +608,13 @@
608608
"enum": ["read", "write", "delete", "get", "list"]
609609
},
610610
"minItems": 1
611+
},
612+
"iamActions": {
613+
"type": "array",
614+
"description": "Custom IAM actions to add to the role.",
615+
"items": {
616+
"type": "string"
617+
}
611618
}
612619
},
613620
"required": ["actions", "bucketId"],

0 commit comments

Comments
 (0)