Amazon S3 for developers: DVA-C03 study notes and practice questions
What to know about Amazon S3 for developers for the DVA-C03 exam, from the Development with AWS Services domain (30% of the exam guide), then 1 free question to test it. Part of the DVA-C03 study guide.
S3 developer questions describe an upload or download that fails, costs too much, or behaves oddly. Match the symptom to the feature, then check the rule that causes it.
Presigned URLs
A presigned URL grants temporary access to one object, for GET or PUT, without giving the client credentials.
It stops working at the set expiry (at most 7 days with Signature Version 4), or earlier if the credentials that signed it expire first. A URL signed with a role’s temporary credentials can end sooner than the time you set.
The URL is only as good as its signature. Changing the method, key or signed headers breaks it.
Browser uploads also need a CORS rule on the bucket that allows the page’s origin and the PUT method. Without it, the browser fails before sending any data.
Caching a presigned URL and reusing it after it expires gives “access denied” errors.
Large uploads
A single PUT can upload up to 5 GB; AWS recommends multipart upload for objects over about 100 MB, and it is required above 5 GB, up to the maximum object size. Uploads can resume by part, and a failed part can be retried without restarting.
Add a lifecycle rule that deletes incomplete multipart uploads. Unfinished parts are stored and billed until they are removed or aborted.
Event notifications
An S3 event that invokes Lambda, and a function that writes output into the same bucket, can loop forever. Limit the notification to an input prefix, and write output to a different prefix or bucket that the notification doesn’t match.
Versions and overwrites
With versioning on, a lifecycle rule can expire noncurrent versions after a number of days. A rule that expires current objects is a different action.
To stop anyone replacing an existing key, use a conditional write (If-None-Match: *). The second write then fails instead of overwriting.
Archived objects in S3 Glacier
DVA-C03 adds Amazon S3 Glacier to its in-scope list, so expect a question where your code reads an object that has been archived.
There are three Glacier storage classes. Glacier Instant Retrieval returns objects in milliseconds, like S3 Standard. Glacier Flexible Retrieval and Glacier Deep Archive are archives: you can’t read an object until you restore it.
A GET on an archived object fails with an InvalidObjectState error. Call RestoreObject with the number of days the temporary copy should stay available, then read it once the restore finishes.
Restore tiers trade speed for cost. Flexible Retrieval offers Expedited (usually 1-5 minutes), Standard (3-5 hours) and Bulk (5-12 hours). Deep Archive offers Standard (within 12 hours) and Bulk (within 48 hours).
Don’t poll for a restore. The s3:ObjectRestore:Completed event notification can invoke a function or send a message when the copy is ready.
Lifecycle rules move objects into Glacier classes after a number of days. Each class has a minimum storage charge (90 days for Instant and Flexible Retrieval, 180 days for Deep Archive), so archiving short-lived data costs more, not less.
How to choose
Scenario wording
Answer
Client uploads without AWS credentials
Presigned PUT URL from a backend
Browser upload fails with a CORS error
CORS rule on the bucket
Multi-gigabyte upload fails and restarts
Multipart upload
Charges grow for uploads never finished
Lifecycle rule to abort incomplete multipart uploads
Lambda keeps running for its own output
Prefix filter on the notification, or a separate output bucket
Old versions must be removed after a set time
Lifecycle rule for noncurrent versions
Reading an archived object fails with InvalidObjectState
RestoreObject, then read the restored copy
Run code when an archive restore finishes
s3:ObjectRestore:Completed event notification
Common traps
Reusing an expired presigned URL.
Writing output to the bucket that triggers the function.
Expiring current objects when the goal is cleaning old versions.
Assuming a presigned URL needs a public bucket. It does not.
Thinking a single PUT suits a multi-gigabyte file. Use multipart.
Reading an archived object directly. Flexible Retrieval and Deep Archive objects must be restored first.
A mobile app uploads profile photos straight to an Amazon S3 bucket, so the app holds no AWS credentials.
An AWS Lambda function behind Amazon API Gateway generates a presigned PUT URL, with a 24-hour expiry, for each upload. The app caches each URL and reuses it for later uploads.
Users report that uploads made from cached URLs fail several hours after the URL was issued, even though the URL states a 24-hour expiry. The team still wants no long-lived keys in the app.
What should the developer do?
Choose one answer.
AA. Request a fresh presigned URL from the API for each upload, since it stops working when the signing credentials expire.
BB. Lower the expiry to 60 minutes and cache each URL for a day, because presigned URLs created with the SDKs are capped at one hour.
CC. Embed an IAM user's access key in the app, so that each URL is signed by a long-lived key that never expires and can be cached.
DD. Turn on S3 versioning on the bucket, so that the earlier URLs stay valid for the whole 24 hours of the expiry they were given.
B. Wrong: The SDKs allow an expiry of up to seven days, so the cap is not the problem. The cause is that the signing credentials expire first.
C. Wrong: A key in the app is a long-lived credential that anyone can extract. It breaks the no-credentials rule, and it is not how presigned URLs are meant to be used.
D. Wrong: Versioning keeps earlier versions of objects. It does not change how long a presigned URL works.
Explanation
A presigned URL expires at whichever comes first, its requested expiry or the expiry of the credentials that signed it. The Lambda role session ends first, so cached URLs fail early. Requesting a URL when an upload starts avoids this without putting long-lived keys in the app.
Want more on Amazon S3 for developers? The 5 full-length practice sets have 5 more Amazon S3 for developers questions, 390 in all, none of them in the free exam. One payment of $14.99, no subscription. See the practice sets →