A developer is deploying a backend worker microservice as an AWS Lambda function. The function is designed to poll an Amazon SQS queue, process incoming JSON messages, and write results to an Amazon DynamoDB table. The developer creates an IAM role named BackendWorkerRole and attaches the managed policies AWSLambdaSQSQueueExecutionRole and AmazonDynamoDBFullAccess to it. However, when trying to associate BackendWorkerRole as the execution role in the Lambda function's configuration using the AWS CLI, the command fails with the following error:
An error occurred (InvalidParameterValueException) when calling the CreateFunction operation: The role defined for the function cannot be assumed by Lambda.
Which of the following configuration adjustments is required to resolve this error?
- AAdd an inline permission policy to the role that explicitly grants the sts:AssumeRole action on the AWS Lambda service principal.
- Modify the trust policy of the role to specify 'lambda.amazonaws.com' as the trusted service principal allowed to assume the role.Answer
- CUpdate the Lambda function's initialization code to explicitly call the AWS STS AssumeRole API using hardcoded temporary access keys.
- DIncrease the Lambda function's execution timeout limit to 15 minutes to ensure that the STS session credentials do not expire during function creation.