Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 18 additions & 1 deletion infrastructure/modules/lambda/kms.tf
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ resource "aws_kms_key_policy" "lambda_cmk" {

data "aws_iam_policy_document" "lambda_cmk" {
statement {
sid = "Enable IAM User Permissions for s3 buckets"
sid = "Enable IAM User Permissions for Lambda CMK"
effect = "Allow"
principals {
type = "AWS"
Expand All @@ -27,4 +27,21 @@ data "aws_iam_policy_document" "lambda_cmk" {
actions = ["kms:*"]
resources = [aws_kms_key.lambda_cmk.arn]
}

statement {
sid = "AllowCloudWatchLogsUseOfTheKey"
effect = "Allow"
principals {
type = "Service"
identifiers = ["logs.${var.region}.amazonaws.com"]
}
actions = [
"kms:Encrypt",
"kms:Decrypt",
"kms:ReEncrypt*",
"kms:GenerateDataKey*",
"kms:DescribeKey"
]
resources = [aws_kms_key.lambda_cmk.arn]
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -72,15 +72,23 @@ resource "aws_iam_policy" "api_infrastructure" {
"kms:UpdateKeyDescription",
"kms:CreateGrant",
"kms:CreateAlias",

"kms:TagResource",
"kms:CreateKey",
"kms:EnableKeyRotation",
"kms:ScheduleKeyDeletion",
"kms:PutKeyPolicy",
"kms:Encrypt",

# Cloudwatch permissions
"logs:Describe*",
"logs:ListTagsForResource",
"logs:PutRetentionPolicy",
"logs:AssociateKmsKey",

#EC2 permissions
"ec2:Describe*",
"ec2:CreateTags",
"ec2:CreateNetworkAclEntry",

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