Presigned URLs
Giving temporary access to one private S3 object with a presigned URL, how long it lasts, and common uses.
What it is
A presigned URL is a link to one object in a private bucket, signed with someone's AWS credentials, that works for a limited time. Anyone holding the link can download (GET) or upload (PUT) that object, without an AWS account and without making the bucket public.
How it works
- Someone who has access to the object (the owner, or an application) generates a presigned URL with the S3 console, AWS CLI or an SDK. Signing happens locally: no call to S3 is needed.
- They give the URL to a user.
- The user uses it to
GET(orPUT) the object directly from S3, until the URL expires.
Users given a presigned URL inherit the permissions of the identity that generated it, for that one object and operation. If the signer loses access, the URL stops working.
How long it lasts
- S3 console: from 1 minute up to 12 hours (720 minutes).
- AWS CLI: set with
--expires-inin seconds. Default 3,600 seconds (1 hour), maximum 604,800 seconds (7 days). - SDKs: up to 7 days with an IAM user's credentials.
- If the URL is signed with temporary credentials (an IAM role), it expires when those credentials expire, even if a longer expiry was requested.
Examples
- Let only logged-in users download a premium video: the app checks the user, then hands out a short-lived URL.
- Let an ever-changing list of users download files, by generating URLs on the fly instead of managing permissions for each user.
- Let a user temporarily upload a file to a precise location in a bucket, such as a profile picture, straight from their browser.
Real-world examples
- A training company sells video courses. After payment, its site gives each student 15-minute URLs to the videos in a private bucket.
- A mobile app asks its backend for a presigned
PUTURL, then uploads photos directly to S3, so large uploads never pass through the backend servers.
Exam tips
- "Give temporary access to a private object without making it public", "users without AWS credentials download one file" → presigned URL.
- "Let users upload directly to S3 from the browser" → presigned
PUTURL. - "URL stopped working before its expiry time" → it was signed with temporary credentials that expired, or the signer lost permission.
Common traps
- "A presigned URL gives the user their own permissions." It carries the signer's permissions.
- "Presigned URLs can last a month." The maximum is 7 days.
- "Make the bucket public for a few days instead." A presigned URL gives access to one object without exposing the bucket.
Hands-on lab: share a private object
Goal: share a private object for five minutes with a presigned URL.
Costs money
A couple of requests cost less than a cent. Any Region works.
Check the object is private
Open an object in your private lab bucket and copy its Object URL. Open it in a private browser window: AccessDenied.
Create a presigned URL
In CloudShell:
aws s3 presign s3://<your-bucket>/<your-object> --expires-in 300Open the printed URL in the private window: the object downloads. (In the console, Object actions → Share with a presigned URL does the same.)
Wait for it to expire
After five minutes, open the URL again: Request has expired.
Expected result: a private object reachable through the signed URL only until it expires.
Clean up: nothing to delete.