A Lambda function running in AWS needs to put events to an EventBridge event bus using the SDK and no explicit credentials in code. After deployment, the function logs AccessDeniedException errors when calling PutEvents. How should the developer fix this?
Choose an answer
Tap an option to check your answer.
Correct answer: Add permissions for the PutEvents action to the Lambda function's execution role..
Why this is the answer
The Lambda function is experiencing AccessDeniedException because it lacks the necessary permissions to call the PutEvents action on EventBridge. When a Lambda function interacts with other AWS services, it assumes an execution role. This role defines the permissions the function has. Therefore, adding the PutEvents action to the Lambda function's execution role will grant it the required authorization. VPC peering is irrelevant as EventBridge is a public service and does not reside within a private VPC that requires peering. Updating the developer's credentials is incorrect because the Lambda function operates under its own execution role, not the developer's credentials. A resource-based policy is used to grant permissions to a resource, not from a resource to another service. The Lambda function needs permissions to perform an action, which is controlled by its execution role.
Pass your exam — without the endless answer hunt
Get every verified question and explanation for this exam in one place, and save hours of prep. 1,000+ certifications · 20+ languages · free to start.
Pass your exam faster → No card needed