A Lambda function needs to write logs to CloudWatch and read from DynamoDB. What is the BEST way to grant these permissions?
-
A
Hardcode IAM user credentials in the Lambda environment variables
-
B
Create an IAM role with the required policies and attach it as the Lambda execution role
-
C
Add the Lambda function ARN to the CloudWatch and DynamoDB resource-based policies
-
D
Use an IAM group to manage Lambda function permissions