Skip to content

Commit c1c0fe7

Browse files
CCM-8237 sqs resource policy overlaod
1 parent 1addcbc commit c1c0fe7

3 files changed

Lines changed: 10 additions & 35 deletions

File tree

infrastructure/modules/sqs/data_iam_policy_document_sqs_queue.tf

Lines changed: 0 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -19,36 +19,4 @@ data "aws_iam_policy_document" "sqs_queue" {
1919
identifiers = [var.aws_account_id]
2020
}
2121
}
22-
23-
dynamic "statement" {
24-
for_each = var.sns_source_arn != null ? [1] : []
25-
26-
content {
27-
effect = "Allow"
28-
29-
principals {
30-
type = "Service"
31-
identifiers = [
32-
"sns.amazonaws.com"
33-
]
34-
}
35-
36-
actions = [
37-
"sqs:SendMessage",
38-
"sqs:SendMessageBatch",
39-
]
40-
41-
condition {
42-
test = "ArnEquals"
43-
variable = "aws:SourceArn"
44-
values = [
45-
var.sns_source_arn
46-
]
47-
}
48-
49-
resources = [
50-
aws_sqs_queue.sqs_queue.arn,
51-
]
52-
}
53-
}
5422
}
Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
11
resource "aws_sqs_queue_policy" "sqs_queue_policy" {
22
queue_url = aws_sqs_queue.sqs_queue.id
3-
policy = data.aws_iam_policy_document.sqs_queue.json
3+
policy = jsonencode([
4+
data.aws_iam_policy_document.sqs_queue.json,
5+
var.sqs_policy_overload,
6+
])
47
}

infrastructure/modules/sqs/variables.tf

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,10 +57,14 @@ variable "sqs_kms_key_arn" {
5757
description = "ARN of the KMS key to encrypt SQS queue messages"
5858
}
5959

60-
variable "sns_source_arn" {
60+
variable "sqs_policy_overload" {
6161
type = string
62-
description = "ARN of an sns resource allowed to send to this resource"
62+
description = "Optional additional policy to extend the SQS Resource Policy"
6363
default = null
64+
validation {
65+
condition = can(jsondecode(var.sqs_policy_overload))
66+
error_message = "sqs_policy_overload must be a valid JSON."
67+
}
6468
}
6569

6670
variable "allowed_arns" {

0 commit comments

Comments
 (0)