A developer is configuring an AWS Lambda function in Account A () to write data to an Amazon DynamoDB table in Account B (). The function executes using the IAM execution role `AccountALambdaRole`. The developer creates an IAM role named `CrossAccountAccessRole` in Account B with a policy that allows write operations on the DynamoDB table. The trust policy for `CrossAccountAccessRole` is currently configured as follows:
{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Principal": {
"Service": "lambda.amazonaws.com"
},
"Action": "sts:AssumeRole"
}
]
}
When the Lambda function in Account A attempts to assume the role `CrossAccountAccessRole` using the AWS SDK to write to the DynamoDB table, it fails with an `AccessDenied` error. Which two of the following modifications are required to resolve this error and allow the Lambda function to write to the DynamoDB table?
- Update the trust policy of CrossAccountAccessRole in Account B to specify the Principal as "AWS": "arn:aws:iam::111122223333:role/AccountALambdaRole" instead of the lambda.amazonaws.com service principal.Answer
- Attach an IAM permission policy to AccountALambdaRole in Account A that grants the sts:AssumeRole action on the resource arn:aws:iam::444455556666:role/CrossAccountAccessRole.Answer
- CAdd a statement to the identity-based permission policy of AccountALambdaRole in Account A that includes a Principal element set to lambda.amazonaws.com with the sts:AssumeRole action.
- DModify the trust policy of the Lambda execution role AccountALambdaRole in Account A to trust the role arn:aws:iam::444455556666:role/CrossAccountAccessRole.
- EConfigure the Lambda function code to use hardcoded AWS access keys of an IAM user from Account B in the AWS SDK client constructor to write to the DynamoDB table directly.