0%
AWS Developer Associate (DVA-C03) Exam Prep: Development, Security, Testing, Deployment and Troubleshooting
How the Exam Works
Domain 2: Security
Domain 3: Testing and Deployment
Domain 4: Troubleshooting and Optimization
New in DVA-C03: Containers and AI
Final Review and Mock Exams
S3 From Code, the AWS SDK and Caching Patterns
Amazon S3 is the storage service every other lesson leans on. The architect exam asks which storage class or replication option fits a requirement. The Developer Associate exam asks what your code does with S3: how a browser uploads without credentials, how a large file gets there reliably, how code reacts when an object arrives and what versioning does to a delete call. Later sections of this lesson cover the SDK itself, which you use for every AWS call, and caching patterns with ElastiCache.
The object model your code sees
An object is identified by a bucket and a key. The key is a full string such as uploads/2026/11/photo.jpg. S3 has no real directories; the console shows folders by splitting keys on the slash, and the ListObjectsV2 API can simulate directories with a Prefix and a Delimiter. A prefix is just the start of a key, and it matters for two reasons a developer meets often: event notification filters and per-prefix request rates. S3 supports at least 3,500 write requests and 5,500 read requests per second per prefix, and there is no limit on the number of prefixes, so spreading hot keys across prefixes raises total throughput.
S3 now gives strong read-after-write consistency for PUT and DELETE of objects, including overwrites, and for list operations. Once a PUT returns success, a GET or a LIST from any client sees the new object. Older material that talks about eventual consistency for overwrites is out of date.
The core calls are PutObject, GetObject, HeadObject (metadata only, cheap, useful for checking that an object exists and reading its size and ETag), DeleteObject, CopyObject and ListObjectsV2. A single PutObject can upload up to 5 GB; anything larger must use multipart upload, covered in the next section. A single object can still be several terabytes in total, which is what multipart upload is for.
User-defined metadata is sent as x-amz-meta- headers, is limited to about 2 KB and cannot be changed without copying the object onto itself. Object tags are separate key and value pairs, up to ten per object, that can be changed in place and used in IAM conditions and lifecycle rules. If a question asks how to label objects so that access policies or lifecycle rules can act on the label, the answer is tags, not metadata.
Why presigned URLs exist
A common requirement is to let a user upload or download a private object from a browser or mobile app without giving that client AWS credentials and without streaming the bytes through your servers. Streaming through an API server wastes its bandwidth and memory, and API Gateway limits payloads to about 10 MB and requests to about 29 seconds by default, so large uploads through the API simply fail.
A presigned URL solves this. Your server, which does have credentials, signs a URL for one specific operation on one specific object, valid for a limited time. Anyone holding the URL can perform that operation until it expires. The server never touches the bytes.
Generating the URL is a local signing operation. It makes no network call and does not check permissions. The check happens when the client uses the URL, and S3 evaluates the signer's permissions at that moment. That has two consequences the exam likes. First, a presigned URL can never grant more than the signer could do: if the signing role lacks s3:PutObject on that bucket, the URL returns 403 Access Denied when used. Second, if the signer's permissions are removed after signing, the URL stops working.
How long a presigned URL lasts
ExpiresIn sets the lifetime. With long-term IAM user credentials and Signature Version 4, the maximum is seven days. With temporary credentials, such as those of a Lambda execution role or an EC2 instance role, the URL also stops working when those credentials expire, even if ExpiresIn was longer. A Lambda function that signs a URL "valid for 24 hours" may produce a URL that dies after a few hours, when the function's session credentials expire. If a stem describes presigned URLs failing earlier than their stated expiry, look for temporary credentials as the cause.
Presigned POST and constraints on uploads
A presigned PUT URL fixes the key and, if you include it when signing, the content type. It does not limit file size. For browser form uploads with conditions, use a presigned POST: the server generates a policy with conditions such as content-length-range, an exact key or key prefix and a content type, and the browser submits a multipart form with those fields. S3 rejects uploads that break the conditions. When a stem says users must not upload files larger than 10 MB directly to S3, presigned POST with a content-length-range condition is the answer.
CORS for browser uploads
A browser enforces the same-origin policy. When JavaScript on app.example.com calls PUT on acme-uploads.s3.amazonaws.com, the browser first sends a preflight OPTIONS request and only proceeds if S3 answers with matching CORS headers. You configure that with a CORS configuration on the bucket, listing allowed origins, methods and headers.
The symptom of a missing CORS rule is distinctive: the same presigned URL works with curl but fails in the browser with a CORS error in the console. The fix is on the bucket being called, not on the website's bucket or the API. ExposeHeaders matters for multipart uploads from the browser, because the client must read the ETag of each part.
Downloads and private content
For downloads, a presigned GET URL works the same way and is the usual answer for "let a logged in user download their invoice for 15 minutes". For content served at scale to many users, such as video, CloudFront signed URLs or signed cookies in front of a private bucket with origin access control are the better fit, because they add caching and can cover many files with one cookie. The exam separates the two by scale and by the presence of CloudFront in the stem.
What the exam is checking here
Typical stems: "users upload large files and the API times out" means presigned URLs for direct upload. "The URL returns Access Denied" means the signer lacks the permission or the credentials expired. "Works from the command line, fails in the browser" means CORS on the bucket. "Limit upload size" means presigned POST with a policy condition. Wrong options in these questions usually suggest making the bucket public, embedding access keys in the client or raising a timeout that cannot be raised far enough.
Encryption headers and presigned URLs
Buckets now encrypt every new object by default with SSE-S3, so most code never sets an encryption header. When a bucket uses SSE-KMS, the encryption lesson explains the details, but one point belongs here: the principal that uploads or downloads needs KMS permissions on the key as well as S3 permissions on the object. A presigned URL for an SSE-KMS object therefore fails with Access Denied if the signer lacks kms:Decrypt for downloads or kms:GenerateDataKey for uploads, even though its S3 permissions are fine. If a presigned PUT was signed with specific headers, such as Content-Type or an encryption header, the client must send exactly those headers, or S3 rejects the request with SignatureDoesNotMatch.
Worked example: a document portal
A portal lets customers upload contracts and download signed copies. The API authenticates the customer and checks that they own the contract. For upload, it returns a presigned POST with a key fixed to the customer's prefix, a content-length-range of up to 20 MB and a content type of application/pdf, valid for ten minutes. The bucket has a CORS rule for the portal's origin. For download, the API returns a presigned GET valid for five minutes, generated only after the ownership check. The bucket blocks all public access. Every exam option that makes the bucket public, hands out credentials or streams files through the API is worse than this design on security, cost or limits.
Generating a presigned URL succeeds even when the signer has no permission on the object. The permission check happens when the URL is used, so test the URL, not just the generation call.