Question

Difficulty: EasyResolving IAM and Authorization Failures

An AWS Lambda function is configured to upload generated reports to an Amazon S3 bucket. During execution, the Lambda function fails to write to the bucket and returns an 'Access Denied' error. How should the developer resolve this authorization failure?

  1. Attach an IAM policy to the Lambda execution role that grants the s3:PutObject action on the target S3 bucket ARN.Answer
  2. B
    Modify the Lambda execution role's trust policy to include s3:PutObject in the Action block.
  3. C
    Initialize the S3 SDK client inside the Lambda function using hardcoded Administrator access keys.
  4. D
    Create an Amazon Cognito User Pool and configure it to generate temporary AWS credentials for the Lambda function.

Answer

Attach an IAM policy to the Lambda execution role that grants the s3:PutObject action on the target S3 bucket ARN.
The correct option addresses the authorization failure by adding a policy to the Lambda execution role. In AWS, Lambda functions use an execution role to acquire temporary security credentials. Granting the 's3:PutObject' permission on the specific bucket ARN in this execution role permits the Lambda function to upload reports successfully.

Step-by-Step Solution

1
Identify the IAM role assigned as the Lambda function's execution role.
The execution role is located, which determines the identity and permissions of the executing function.
Permissions in Lambda are governed by the execution role.
2
Define an IAM policy document containing an 'Allow' statement for the 's3:PutObject' action on the S3 bucket's ARN.
A valid permission policy JSON or visual definition is created.
This policy specifies the exact resource and action that are currently failing due to authorization issues.
3
Attach the defined IAM policy to the identified Lambda execution role.
The Lambda execution role now possesses permissions to write to the S3 bucket.
Attaching the policy applies the permissions to the Lambda function's identity context, resolving the Access Denied error.

Key Concept

Resolving AWS permission failures by attaching identity-based IAM policies to execution roles.
Estimated Time:1m 0s
Rate this question