A developer is configuring an AWS Lambda function that needs to retrieve objects from an Amazon S3 bucket. Which of the following configurations represents the most secure method to grant the Lambda function the necessary permissions to access the S3 bucket?
- ACreate an IAM role with a permissions policy allowing s3:GetObject, and configure the trust policy of the role to allow the s3.amazonaws.com service principal to assume it.
- Create an IAM execution role with a permissions policy that allows s3:GetObject on the specific bucket, configure the trust policy of the role to allow the lambda.amazonaws.com service principal to assume it, and associate this role with the Lambda function.Cevap
- CInitialize the AWS SDK client inside the Lambda function code using hardcoded AWS access keys of an IAM user that has read access to the S3 bucket.
- DAssign an ECS Task Execution Role containing the necessary S3 permissions to the Lambda function configuration.
Cevap
Create an IAM execution role with a permissions policy that allows s3:GetObject on the specific bucket, configure the trust policy of the role to allow the lambda.amazonaws.com service principal to assume it, and associate this role with the Lambda function.
The correct answer correctly specifies creating an IAM execution role, defining its permissions policy to allow s3:GetObject, configuring its trust policy to allow lambda.amazonaws.com to assume it, and associating the role with the Lambda function. This follows the principle of least privilege and uses secure, temporary credentials.
Adım Adım Çözüm
Anahtar Kavram
IAM Execution Roles for AWS Lambda