Skip to content

Commit 052846d

Browse files
authored
Merge pull request #134 from NHSDigital/bugfix/eja-eli-238-fixing-permissions-and-lambda-cloudwatch-kms
eli-238 - bugfix - fixing github and cloudwatch permissions
2 parents 93e7725 + f6d6de7 commit 052846d

File tree

2 files changed

+27
-2
lines changed

2 files changed

+27
-2
lines changed

infrastructure/modules/lambda/kms.tf

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ resource "aws_kms_key_policy" "lambda_cmk" {
1818

1919
data "aws_iam_policy_document" "lambda_cmk" {
2020
statement {
21-
sid = "Enable IAM User Permissions for s3 buckets"
21+
sid = "Enable IAM User Permissions for Lambda CMK"
2222
effect = "Allow"
2323
principals {
2424
type = "AWS"
@@ -27,4 +27,21 @@ data "aws_iam_policy_document" "lambda_cmk" {
2727
actions = ["kms:*"]
2828
resources = [aws_kms_key.lambda_cmk.arn]
2929
}
30+
31+
statement {
32+
sid = "AllowCloudWatchLogsUseOfTheKey"
33+
effect = "Allow"
34+
principals {
35+
type = "Service"
36+
identifiers = ["logs.${var.region}.amazonaws.com"]
37+
}
38+
actions = [
39+
"kms:Encrypt",
40+
"kms:Decrypt",
41+
"kms:ReEncrypt*",
42+
"kms:GenerateDataKey*",
43+
"kms:DescribeKey"
44+
]
45+
resources = [aws_kms_key.lambda_cmk.arn]
46+
}
3047
}

infrastructure/stacks/iams-developer-roles/github_actions_policies.tf

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,15 +72,23 @@ resource "aws_iam_policy" "api_infrastructure" {
7272
"kms:UpdateKeyDescription",
7373
"kms:CreateGrant",
7474
"kms:CreateAlias",
75-
75+
"kms:TagResource",
76+
"kms:CreateKey",
77+
"kms:EnableKeyRotation",
78+
"kms:ScheduleKeyDeletion",
79+
"kms:PutKeyPolicy",
80+
"kms:Encrypt",
7681

7782
# Cloudwatch permissions
7883
"logs:Describe*",
7984
"logs:ListTagsForResource",
85+
"logs:PutRetentionPolicy",
86+
"logs:AssociateKmsKey",
8087

8188
#EC2 permissions
8289
"ec2:Describe*",
8390
"ec2:CreateTags",
91+
"ec2:CreateNetworkAclEntry",
8492

8593
# IAM permissions (scoped to resources with specific path prefix)
8694
"iam:Get*",

0 commit comments

Comments
 (0)