Skip to content

Commit c4188b7

Browse files
feat: Added sns_kms_arns parameter for granular kms access inside sns aws_iam_policy resource (#129)
1 parent 9cfedbf commit c4188b7

File tree

3 files changed

+19
-8
lines changed

3 files changed

+19
-8
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -529,6 +529,7 @@ No modules.
529529
| <a name="input_schedules"></a> [schedules](#input\_schedules) | A map of objects with EventBridge Schedule definitions. | `map(any)` | `{}` | no |
530530
| <a name="input_schemas_discoverer_description"></a> [schemas\_discoverer\_description](#input\_schemas\_discoverer\_description) | Default schemas discoverer description | `string` | `"Auto schemas discoverer event"` | no |
531531
| <a name="input_sfn_target_arns"></a> [sfn\_target\_arns](#input\_sfn\_target\_arns) | The Amazon Resource Name (ARN) of the StepFunctions you want to use as EventBridge targets | `list(string)` | `[]` | no |
532+
| <a name="input_sns_kms_arns"></a> [sns\_kms\_arns](#input\_sns\_kms\_arns) | The Amazon Resource Name (ARN) of the AWS KMS's configured for AWS SNS you want Decrypt/GenerateDataKey for | `list(string)` | <pre>[<br> "*"<br>]</pre> | no |
532533
| <a name="input_sns_target_arns"></a> [sns\_target\_arns](#input\_sns\_target\_arns) | The Amazon Resource Name (ARN) of the AWS SNS's you want to use as EventBridge targets | `list(string)` | `[]` | no |
533534
| <a name="input_sqs_target_arns"></a> [sqs\_target\_arns](#input\_sqs\_target\_arns) | The Amazon Resource Name (ARN) of the AWS SQS Queues you want to use as EventBridge targets | `list(string)` | `[]` | no |
534535
| <a name="input_tags"></a> [tags](#input\_tags) | A map of tags to assign to resources. | `map(string)` | `{}` | no |

iam.tf

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -190,14 +190,18 @@ data "aws_iam_policy_document" "sns" {
190190
resources = var.sns_target_arns
191191
}
192192

193-
statement {
194-
sid = "SNSKMSAccess"
195-
effect = "Allow"
196-
actions = [
197-
"kms:Decrypt",
198-
"kms:GenerateDataKey"
199-
]
200-
resources = ["*"]
193+
dynamic "statement" {
194+
for_each = length(var.sns_kms_arns) > 0 ? [1] : []
195+
196+
content {
197+
sid = "SNSKMSAccess"
198+
effect = "Allow"
199+
actions = [
200+
"kms:Decrypt",
201+
"kms:GenerateDataKey"
202+
]
203+
resources = var.sns_kms_arns
204+
}
201205
}
202206

203207
}

variables.tf

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -332,6 +332,12 @@ variable "sns_target_arns" {
332332
default = []
333333
}
334334

335+
variable "sns_kms_arns" {
336+
description = "The Amazon Resource Name (ARN) of the AWS KMS's configured for AWS SNS you want Decrypt/GenerateDataKey for"
337+
type = list(string)
338+
default = ["*"]
339+
}
340+
335341
variable "ecs_target_arns" {
336342
description = "The Amazon Resource Name (ARN) of the AWS ECS Tasks you want to use as EventBridge targets"
337343
type = list(string)

0 commit comments

Comments
 (0)