Skip to content

Commit 9feb2f2

Browse files
author
Adetokunbo Ige
committed
chore: update policy
Signed-off-by: Adetokunbo Ige <[email protected]>
1 parent 202f477 commit 9feb2f2

File tree

1 file changed

+9
-7
lines changed

1 file changed

+9
-7
lines changed

todo-app/__main__.py

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -57,9 +57,10 @@
5757
}
5858
)
5959

60-
# Define IAM policy for DynamoDB access
61-
dynamodb_scan_policy = aws.iam.Policy(
60+
# 3. Create DynamoDB policy
61+
dynamodb_policy = aws.iam.Policy(
6262
"dynamodb-policy",
63+
name=f"dynamodb-policy-{environment}",
6364
description="Policy for DynamoDB access",
6465
policy=pulumi.Output.json_dumps({
6566
"Version": "2012-10-17",
@@ -75,18 +76,19 @@
7576
"dynamodb:Query"
7677
],
7778
"Resource": [
78-
pulumi.Output.format("{}",dynamodb_table.arn),
79-
pulumi.Output.format("{}/*",dynamodb_table.arn) # Include index access
79+
dynamodb_table.arn,
80+
pulumi.Output.concat(dynamodb_table.arn, "/*")
8081
]
8182
}
8283
]
8384
})
8485
)
8586

86-
# Attach the policy to the Lambda execution role
87-
role_policy_attachment = aws.iam.RolePolicyAttachment("lambda-role-policy-attachment",
87+
# 4. IMPORTANT: Attach the policy to the role
88+
lambda_dynamodb_policy_attachment = aws.iam.RolePolicyAttachment(
89+
"lambda-dynamodb-policy-attachment",
8890
role=lambda_role.name,
89-
policy_arn=dynamodb_scan_policy.arn
91+
policy_arn=dynamodb_policy.arn
9092
)
9193

9294
# Create a Lambda function using the Docker image

0 commit comments

Comments
 (0)