Skip to content

Commit 932daae

Browse files
committed
refactor: move queue policy to sqs policy instead off ssm
1 parent 3f1fada commit 932daae

File tree

3 files changed

+19
-18
lines changed

3 files changed

+19
-18
lines changed

modules/webhook/policies/lambda-publish-sqs-policy.json

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,16 @@
55
"Effect": "Allow",
66
"Action": ["sqs:SendMessage", "sqs:GetQueueAttributes"],
77
"Resource": ${sqs_resource_arns}
8+
%{ if kms_key_arn != "" ~}
9+
},
10+
{
11+
"Effect": "Allow",
12+
"Action": [
13+
"kms:Decrypt",
14+
"kms:GenerateDataKey"
15+
],
16+
"Resource": "${kms_key_arn}"
17+
%{ endif ~}
818
}
919
]
1020
}

modules/webhook/policies/lambda-ssm.json

Lines changed: 7 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -2,23 +2,13 @@
22
"Version": "2012-10-17",
33
"Statement": [
44
{
5-
"Effect": "Allow",
6-
"Action": [
7-
"ssm:GetParameter"
8-
],
9-
"Resource": [
10-
"${github_app_webhook_secret_arn}"
11-
]
12-
%{ if kms_key_arn != "" ~}
13-
},
14-
{
15-
"Effect": "Allow",
16-
"Action": [
17-
"kms:Decrypt",
18-
"kms:GenerateDataKey"
19-
],
20-
"Resource": "${kms_key_arn}"
21-
%{ endif ~}
5+
"Effect": "Allow",
6+
"Action": [
7+
"ssm:GetParameter"
8+
],
9+
"Resource": [
10+
"${github_app_webhook_secret_arn}"
11+
]
2212
}
2313
]
2414
}

modules/webhook/webhook.tf

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,7 @@ resource "aws_iam_role_policy" "webhook_sqs" {
8888

8989
policy = templatefile("${path.module}/policies/lambda-publish-sqs-policy.json", {
9090
sqs_resource_arns = jsonencode([for k, v in var.runner_config : v.arn])
91+
kms_key_arn = var.kms_key_arn != null ? var.kms_key_arn : ""
9192
})
9293
}
9394

@@ -98,6 +99,7 @@ resource "aws_iam_role_policy" "webhook_workflow_job_sqs" {
9899

99100
policy = templatefile("${path.module}/policies/lambda-publish-sqs-policy.json", {
100101
sqs_resource_arns = jsonencode([var.sqs_workflow_job_queue.arn])
102+
kms_key_arn = var.kms_key_arn != null ? var.kms_key_arn : ""
101103
})
102104
}
103105

@@ -107,6 +109,5 @@ resource "aws_iam_role_policy" "webhook_ssm" {
107109

108110
policy = templatefile("${path.module}/policies/lambda-ssm.json", {
109111
github_app_webhook_secret_arn = var.github_app_parameters.webhook_secret.arn,
110-
kms_key_arn = var.kms_key_arn != null ? var.kms_key_arn : ""
111112
})
112113
}

0 commit comments

Comments
 (0)