Skip to content

Commit e6c67d4

Browse files
Fix patch lambda permissions
1 parent 26489d3 commit e6c67d4

File tree

3 files changed

+23
-8
lines changed

3 files changed

+23
-8
lines changed

infrastructure/terraform/components/api/module_lambda_get_letters.tf

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -62,13 +62,9 @@ data "aws_iam_policy_document" "get_letters_lambda" {
6262

6363
actions = [
6464
"dynamodb:BatchGetItem",
65-
"dynamodb:BatchWriteItem",
66-
"dynamodb:DeleteItem",
6765
"dynamodb:GetItem",
68-
"dynamodb:PutItem",
6966
"dynamodb:Query",
7067
"dynamodb:Scan",
71-
"dynamodb:UpdateItem",
7268
]
7369

7470
resources = [

infrastructure/terraform/components/api/module_lambda_patch_letters.tf

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ module "patch_letters" {
99
environment = var.environment
1010
project = var.project
1111
region = var.region
12-
1312
group = var.group
1413

1514
log_retention_in_days = var.log_retention_in_days
@@ -37,6 +36,8 @@ module "patch_letters" {
3736
log_subscription_role_arn = local.acct.log_subscription_role_arn
3837

3938
lambda_env_vars = {
39+
LETTERS_TABLE_NAME = aws_dynamodb_table.letters.name,
40+
LETTER_TTL_HOURS = 24
4041
}
4142
}
4243

@@ -54,4 +55,23 @@ data "aws_iam_policy_document" "patch_letters_lambda" {
5455
module.kms.key_arn, ## Requires shared kms module
5556
]
5657
}
58+
59+
statement {
60+
sid = "AllowDynamoDBAccess"
61+
effect = "Allow"
62+
63+
actions = [
64+
"dynamodb:BatchGetItem",
65+
"dynamodb:BatchWriteItem",
66+
"dynamodb:GetItem",
67+
"dynamodb:PutItem",
68+
"dynamodb:Query",
69+
"dynamodb:Scan",
70+
"dynamodb:UpdateItem",
71+
]
72+
73+
resources = [
74+
aws_dynamodb_table.letters.arn,
75+
]
76+
}
5777
}

lambdas/api-handler/src/services/__tests__/letter-operations.test.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
1-
import { Letter, LetterStatus } from '../../../../../internal/datastore/src';
1+
import { Letter } from '../../../../../internal/datastore/src';
22
import { LetterApiResource, LetterApiStatus } from '../../contracts/letter-api';
33
import { getLetterIdsForSupplier, patchLetterStatus } from '../letter-operations';
4-
import { z } from 'zod';
54

65
function makeLetterApiResource(id: string, status: LetterApiStatus) : LetterApiResource {
76
return {
@@ -16,7 +15,7 @@ function makeLetterApiResource(id: string, status: LetterApiStatus) : LetterApiR
1615
};
1716
}
1817

19-
function makeLetter(id: string, status: z.infer<typeof LetterStatus>) : Letter {
18+
function makeLetter(id: string, status: Letter['status']) : Letter {
2019
return {
2120
id,
2221
status,

0 commit comments

Comments
 (0)