Skip to content

Commit e0f2e5e

Browse files
committed
dynamodb policy attachment II
1 parent dc113e3 commit e0f2e5e

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

terraform/id_sync_lambda.tf

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -255,14 +255,18 @@ data "aws_iam_policy_document" "id_sync_policy_document" {
255255
]
256256
}
257257

258+
resource "aws_iam_policy" "id_sync_lambda_dynamodb_access_policy" {
259+
name = "${local.short_prefix}-id-sync-lambda-dynamodb-access-policy"
260+
description = "Allow Lambda to access DynamoDB"
261+
policy = data.aws_iam_policy_document.id_sync_policy_document.json
262+
}
263+
258264
# Attach the dynamodb policy to the Lambda role
259-
# TODO: attach a policy rather than a policy_arn?
260265
resource "aws_iam_role_policy_attachment" "id_sync_lambda_dynamodb_policy_attachment" {
261266
role = aws_iam_role.id_sync_lambda_exec_role.name
262-
policy = data.aws_iam_policy_document.id_sync_policy_document.json
267+
policy_arn = aws_iam_policy.id_sync_lambda_dynamodb_access_policy.arn
263268
}
264269

265-
266270
# Lambda Function with Security Group and VPC.
267271
resource "aws_lambda_function" "id_sync_lambda" {
268272
function_name = "${local.short_prefix}-id_sync_lambda"

0 commit comments

Comments
 (0)