A developer is writing an AWS Lambda function in AWS Account A () that needs to retrieve files from an Amazon S3 bucket located in AWS Account B (). The developer has attached an IAM policy to the Lambda function's execution role in Account A that grants `s3:GetObject` permissions on the S3 bucket in Account B. However, when the Lambda function runs, it receives an Access Denied error (HTTP ) from Amazon S3. Which of the following actions will resolve this authorization failure?
- Add a bucket policy to the S3 bucket in Account B that explicitly grants the Lambda execution role ARN in Account A permission to perform the s3:GetObject action.Cevap
- BUpdate the trust policy of the Lambda execution role in Account A to allow the S3 service in Account B to assume the role.
- CInitialize the Amazon S3 client in the Lambda function using hardcoded AWS access keys from an IAM user in Account B who has access to the bucket.
- DCreate an Amazon Cognito Identity Pool in Account B, configure it to authenticate the Lambda function, and use the retrieved temporary credentials to access the bucket.
Cevap
Add a bucket policy to the S3 bucket in Account B that explicitly grants the Lambda execution role ARN in Account A permission to perform the s3:GetObject action.
For cross-account access to Amazon S3, both the identity-based policy in the source account (Account A) and the resource-based policy (bucket policy) in the destination account (Account B) must explicitly grant permission. Adding a bucket policy in the destination account that allows the source account's Lambda execution role to perform the object retrieval action satisfies the second requirement.
Adım Adım Çözüm
Anahtar Kavram
Cross-Account IAM Delegation and Resource-Based Policies