A developer has configured an AWS Lambda function in Account A (123456789012) to access resources in Account B (987654321098) by assuming an IAM role named CrossAccountAccessRole in Account B. The developer attached an IAM policy to the Lambda execution role in Account A that permits the sts:AssumeRole action. However, when the Lambda function runs and attempts to assume the role, the API call fails with an AccessDenied error.
The trust policy for CrossAccountAccessRole in Account B is configured as follows:
{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Principal": {
"Service": "lambda.amazonaws.com"
},
"Action": "sts:AssumeRole"
}
]
}
Which modification must the developer make to resolve this error?
- Modify the trust policy of CrossAccountAccessRole in Account B to specify the ARN of the Lambda function's execution role from Account A as the principal.Cevap
- BModify the trust policy of the Lambda function's execution role in Account A to allow the sts:AssumeRole action from the lambda.amazonaws.com service principal.
- CInitialize the AWS SDK client inside the Lambda function code by passing the AWS access key and secret access key of an IAM user created directly in Account B.
- DModify the trust policy of CrossAccountAccessRole in Account B to specify its own role ARN as the principal.