An AWS Lambda function in Account A () uses its execution role, `LambdaExecutionRole`, to retrieve parameters from AWS Systems Manager Parameter Store in Account B (). To perform this task, the function's code executes an AWS STS `AssumeRole` API call targeting an IAM role in Account B named `ParameterReaderRole`. Although `LambdaExecutionRole` is granted permissions to perform `sts:AssumeRole` on the target resource, the invocation fails with an `AccessDenied` error. The trust policy for `ParameterReaderRole` is configured as follows:
{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Principal": {
"Service": "lambda.amazonaws.com"
},
"Action": "sts:AssumeRole"
}
]
}
How should the developer modify the trust policy of `ParameterReaderRole` to resolve this issue?
- AAttach a resource-based policy directly to the Systems Manager Parameter Store parameters in Account B to allow access from the Lambda execution role in Account A.
- BModify the Lambda function code to use the AWS SDK to authenticate using a hardcoded AWS access key and secret access key associated with an IAM user in Account B.
- Change the Principal block in the trust policy of ParameterReaderRole to reference the Lambda function's execution role ARN: "AWS": "arn:aws:iam::111111111111:role/LambdaExecutionRole".Cevap
- DModify the trust policy of ParameterReaderRole to specify the Systems Manager service principal "Service": "ssm.amazonaws.com" as the allowed principal.