Question 1,230 of 724
DVA-C02 Development with AWS Services Practice Question
A developer is creating an AWS Lambda function that processes events from an Amazon S3 bucket. The function writes logs to Amazon CloudWatch Logs. The developer wants to ensure that the Lambda function has the minimum required permissions. Which IAM policy should be attached to the Lambda execution role?
⚠ Common exam trap
The trap here is that candidates often forget that 'logs:CreateLogGroup' is required for the first invocation of a Lambda function, and they mistakenly choose a policy with only 'logs:PutLogEvents' or overly broad S3 permissions like 's3:*'.
Answer choices
Why each option matters
Answer the question above first, then reveal the full breakdown to understand why each option is right or wrong.
Correct answer & explanation
✓
A policy that includes 'logs:CreateLogGroup', 'logs:CreateLogStream', 'logs:PutLogEvents', and 's3:GetObject' on the specific bucket.
It grants the minimum required permissions for the Lambda function to read objects from the specific S3 bucket (s3:GetObject) and to write logs to CloudWatch Logs (logs:CreateLogGroup, logs:CreateLogStream, logs:PutLogEvents). The s3:GetObject action is necessary to process events from S3, and the three logs actions are the minimum needed for the Lambda runtime to create a log group, create a log stream, and write log events. This policy follows the principle of least privilege by scoping permissions to the specific bucket and avoiding wildcards.
Answer analysis
Option-by-option breakdown
For each option: why learners choose it and why it is or isn't the right answer here.
- ✗
A policy that includes 'logs:CreateLogStream', 'logs:PutLogEvents', and 's3:*' on the bucket.
Why it's wrong here
This policy is insufficient because it omits the 'logs:CreateLogGroup' permission, which is necessary for the Lambda service to establish a dedicated log group for the function if one does not already exist. Furthermore, granting 's3:*' on the bucket provides overly broad permissions, including actions like 'PutObject' or 'DeleteObject', which are not required for a function that merely processes an existing object. This violates the principle of least privilege, as only 's3:GetObject' is functionally needed.
- ✗
A policy that includes 'logs:*' and 's3:*' on the bucket.
Why it's wrong here
This policy uses wildcards for both logging and S3 permissions, granting excessive privileges that violate the principle of least privilege. 'logs:*' allows actions like deleting log groups or cancelling export tasks, far beyond what's needed for basic logging. Similarly, 's3:*' grants full administrative control over the S3 bucket, including write and delete operations, when the function only requires read access to an object. Such broad permissions increase the security risk and potential attack surface for the Lambda function.
- ✗
A policy that includes 'logs:PutLogEvents' and 's3:ListBucket' on the bucket.
Why it's wrong here
This policy is critically flawed because it lacks essential permissions for both logging and S3 object processing. It omits 'logs:CreateLogGroup' and 'logs:CreateLogStream', which are fundamental for Lambda to initialize its logging infrastructure in CloudWatch. Additionally, 's3:ListBucket' only permits listing the contents of a bucket; the function requires 's3:GetObject' to actually retrieve and read the data of the specific S3 object it is intended to process.
- ✓
A policy that includes 'logs:CreateLogGroup', 'logs:CreateLogStream', 'logs:PutLogEvents', and 's3:GetObject' on the specific bucket.
Why this is correct
This policy correctly adheres to the principle of least privilege by granting only the necessary permissions for a Lambda function to process an S3 object and log its execution. 'logs:CreateLogGroup' allows the function to create its dedicated log group, 'logs:CreateLogStream' enables the creation of log streams within that group, and 'logs:PutLogEvents' permits writing runtime logs to CloudWatch. 's3:GetObject' is the precise permission required to retrieve the S3 object's content, ensuring the function can perform its core task securely.
Quick reference
AWS S3 Storage Class Comparison
| Storage Class | Min Duration | Retrieval | Use Case |
|---|---|---|---|
| S3 Standard | None | Immediate | Frequently accessed data |
| S3 Standard-IA | 30 days | Immediate | Infrequent access, rapid retrieval |
| S3 One Zone-IA | 30 days | Immediate | Non-critical infrequent data |
| S3 Intelligent-Tiering | None | Immediate–hours | Unknown or changing access patterns |
| S3 Glacier Instant | 90 days | Milliseconds | Archive with instant retrieval |
| S3 Glacier Flexible | 90 days | Minutes–hours | Archive, flexible retrieval |
| S3 Glacier Deep Archive | 180 days | Hours | Long-term compliance archive |
About these practice questions
Courseiva creates original exam-style practice questions with explanations and wrong-answer analysis. It does not publish real exam questions, exam dumps, or protected exam content. Learn why practice questions differ from exam dumps →
Last reviewed: Jul 4, 2026
This DVA-C02 practice question is part of Courseiva's free Amazon Web Services certification practice question bank. Courseiva provides original exam-style practice questions with explanations, topic-based practice, mock exams, readiness tracking, and study analytics to help learners prepare for the DVA-C02 exam.
Question Discussion
Share a tip, memory trick, or ask about the reasoning behind this question. Do not post real exam questions, leaked content, braindumps, or copyrighted exam material. Comments are moderated and may be removed without notice.
Sign in to join the discussion.