Sharing a file stored in Amazon S3 sounds simple until you realize the bucket must stay private. Making an object public solves the sharing problem but creates a security problem: anyone who finds the link can download the file forever, and search engines may index it. That is exactly the situation where aws s3 presigned urls shine. A presigned URL is a normal S3 object URL with a cryptographic signature appended as query parameters. It grants temporary access to one specific object, for one specific action, and it stops working the moment it expires.
In this guide you will learn how aws s3 presigned urls work, how to generate them with the AWS CLI and with Python and boto3, and how to avoid the mistakes that turn a convenient feature into a security hole. You will also learn the hard expiry limits, why clock skew breaks signatures, and when a CloudFront signed URL is the better tool for the job.

How AWS S3 Presigned URLs Work
A presigned URL does not change the permissions of the bucket or the object. The object stays private, and the bucket policy stays restrictive. Instead, the signer uses their own AWS credentials to compute a signature over the request details: the HTTP method, the object key, and an expiry time. Anyone who holds the resulting URL can perform exactly that one operation until the expiry time passes. After expiry, S3 rejects the request even though the URL itself still looks valid.
This design has two important consequences. First, the URL itself becomes a bearer credential, so you must treat it like a password: send it over HTTPS only, and never log it or paste it into a public chat. Second, the permissions of the presigned URL can never exceed the permissions of the credentials that signed it. If the signer cannot read the object, the presigned URL will not work either. That is why least-privilege IAM credentials matter so much here.
Prerequisites for AWS S3 Presigned URLs
Before you start, make sure you have an AWS account with a private S3 bucket and at least one test object in it. Install the AWS CLI version 2 and configure a profile with credentials that have s3:GetObject and s3:PutObject permission on that bucket. For the Python examples you need Python 3.9 or newer and the boto3 library installed. Never use root account credentials for any of this; create an IAM user or role with only the permissions the task requires.
aws --version
aws s3 ls s3://your-bucket-name
pip install boto3
Generate a Presigned Download URL with the AWS CLI
The fastest way to create a download link is the presign command. The --expires-in flag takes a number of seconds, so 3600 gives you one hour. The command prints a URL that anyone can use to download the object with a simple GET request until the expiry time.
aws s3 presign s3://your-bucket-name/reports/q3-summary.pdf --expires-in 3600
Test the URL with curl to confirm it works, and test it again after the expiry time to confirm that it stops working. This two-step check is worth doing once, because it proves that expiry is enforced server-side by S3 and not merely a convention in your application code.
curl -o q3-summary.pdf "https://your-bucket-name.s3.amazonaws.com/reports/q3-summary.pdf?X-Amz-Algorithm=AWS4-HMAC-SHA256&..."
Generate a Presigned Upload URL with the AWS CLI
Presigned URLs also work for uploads. A presigned PUT URL lets a user upload a file directly to your bucket without ever receiving your AWS credentials. This pattern is common for browser and mobile uploads, because the file travels straight to S3 instead of passing through your application server.
aws s3 presign s3://your-bucket-name/uploads/invoice-1042.pdf --expires-in 1800
Note that the AWS CLI presign command generates a GET URL by default. To create a PUT URL from the command line, use the lower-level aws s3api approach or generate it with boto3, as shown in the next section. Whichever method you choose, keep the expiry short for uploads, typically 15 to 30 minutes, because a leaked upload URL lets an attacker write arbitrary content into your bucket until it expires.
Generate AWS S3 Presigned URLs with Python and Boto3
Most production systems generate presigned URLs in application code rather than on the command line. The boto3 generate_presigned_url method takes a client method name and its parameters, plus an expiry in seconds. The following example creates both a download URL and an upload URL.
import boto3
s3 = boto3.client("s3", region_name="us-east-1")
download_url = s3.generate_presigned_url(
ClientMethod="get_object",
Params={"Bucket": "your-bucket-name", "Key": "reports/q3-summary.pdf"},
ExpiresIn=3600,
)
upload_url = s3.generate_presigned_url(
ClientMethod="put_object",
Params={"Bucket": "your-bucket-name", "Key": "uploads/invoice-1042.pdf"},
ExpiresIn=1800,
)
print(download_url)
print(upload_url)
For uploads, remember that the client must send the exact same headers that were signed. If your code signs a request with a specific Content-Type, the uploader must send that same content type, or S3 will reject the signature. A common practice is to sign only the minimal set of parameters and let the uploader set nothing extra, which avoids this class of mismatch entirely.
Keep the Bucket Private and Use Least-Privilege IAM
A presigned URL is not a substitute for a secure bucket configuration. Keep Block Public Access enabled on the bucket, keep the bucket policy restrictive, and grant the signing identity only the actions it needs. The following IAM policy allows presigning for one bucket prefix and nothing else. Attach it to the IAM user or role that generates your URLs, and never sign URLs with long-lived root credentials.
{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Action": ["s3:GetObject", "s3:PutObject"],
"Resource": "arn:aws:s3:::your-bucket-name/uploads/*"
}
]
}
Also consider whether your use case actually needs S3 presigned URLs at all. If you serve content to many users through a CDN, a CloudFront signed URL or signed cookies may fit better, because they integrate with caching and support longer-lived access patterns. Presigned URLs are the right choice when you need a quick, direct, time-limited link to a single object. If you already use versioning and retention controls on the same bucket, read our guide to AWS S3 versioning and Object Lock to understand how object versions interact with signed access. For serving public content instead, see how to host a static website on Amazon S3. The official reference is the Amazon S3 presigned URL documentation.
Expiry Limits for AWS S3 Presigned URLs
Signature Version 4 presigned URLs for GET requests support a maximum expiry of seven days, which is 604800 seconds. If you pass a larger value, the request fails. For uploads and for most application use cases, much shorter expiries are appropriate: an hour for downloads and 15 to 30 minutes for uploads. Short expiries limit the damage if a URL leaks, and they cost nothing because generating a new URL is a local signing operation that does not call S3.
There is one important exception to the seven-day rule. If the signing credentials are temporary session credentials from AWS STS, the presigned URL cannot outlive the session itself. A URL signed with credentials that expire in one hour stops working after one hour, even if you requested a seven-day expiry. When you need longer-lived URLs, sign them with long-lived IAM user credentials that are scoped to the single bucket, and rotate those credentials regularly.
Troubleshooting AWS S3 Presigned URLs
SignatureDoesNotMatch. This is the most common error, and clock skew is the most common cause. The signing machine and the client must agree on the time within a few minutes, so make sure the server clock is synchronized with NTP. Other causes include a mismatched region, a changed object key, or extra headers sent by the client that were not part of the signature.
AccessDenied. The signing identity lacks permission on the object, or a bucket policy or SCP explicitly denies the action. Check the IAM policy first, then the bucket policy, then any organization-level service control policies. Remember that an explicit deny anywhere overrides an allow.
Expired URL. S3 returns an error once the expiry time passes, and there is no way to extend an existing URL. Generate a fresh one instead. If URLs seem to expire immediately, check whether the signing machine clock is ahead of real time, or whether temporary credentials expired before the requested expiry.
Upload fails with a signature error. The uploader probably sent a header, such as Content-Type, that was not included in the signature, or omitted one that was. Align the signed parameters with the actual request, or simplify the signature to the minimum set of parameters.
Conclusion
AWS S3 presigned urls give you the best of both worlds: a bucket that stays fully private and a sharing mechanism that works for anyone, for a limited time, for one object. Generate them with the AWS CLI for quick one-off links and with boto3 in application code, keep expiries short, sign with least-privilege credentials, and never treat a presigned URL as public content. Follow those rules and presigned URLs become one of the safest and simplest sharing tools in your AWS toolkit.