📡 You're offline — showing cached content
New version available!
Quick Access
Tutorials AWS Solutions Architect S3 Pre-signed URLs and Access Control

S3 Pre-signed URLs and Access Control

4 min read
Use pre-signed URLs for secure temporary S3 access without exposing AWS credentials. Understand all S3 access control mechanisms.

S3 Pre-signed URLs — Secure Temporary Access

A pre-signed URL grants temporary access to a PRIVATE S3 object without requiring AWS credentials. The URL contains the access parameters and expires after a set time — perfect for secure file downloads and uploads in web applications.

Teacher Note: Imagine a museum (S3 bucket) with private exhibits (private objects). Normally nobody can enter without an employee badge (AWS credentials). A pre-signed URL is like a temporary guest pass that lets a visitor (user) enter for exactly 1 hour — then the pass expires and is useless.

Pre-signed URL Use Cases

ScenarioHow Pre-signed URLs Help
Profile photo downloadServer generates a 1-hour pre-signed URL. User's browser downloads photo directly from S3 without credentials
Direct file uploadServer generates a pre-signed PUT URL. User uploads file directly to S3 without going through your server — reduces server load
Invoice downloadPre-signed URL valid for 24 hours — user can only download their own invoice
Partner data sharingShare specific private files with partners for a limited time without making bucket public

Generating Pre-signed URLs

import boto3
from datetime import timedelta

s3 = boto3.client('s3')

# Generate download URL (valid 1 hour)
url = s3.generate_presigned_url(
    ClientMethod='get_object',
    Params={'Bucket': 'my-bucket', 'Key': 'private-file.pdf'},
    ExpiresIn=3600  # seconds
)
print(url)  # Share this URL with the user
# Anyone with this URL can download the file for 1 hour
# After 1 hour: 403 Forbidden

# Generate upload URL (direct upload from browser)
url = s3.generate_presigned_url(
    ClientMethod='put_object',
    Params={
        'Bucket': 'upload-bucket',
        'Key': f'uploads/{user_id}/profile.jpg',
        'ContentType': 'image/jpeg'
    },
    ExpiresIn=300  # 5 minutes to complete upload
)

S3 Access Control Summary

MethodUse CaseComplexity
Block Public AccessKeep bucket private (default)Zero — enable and forget
Bucket PolicyGrant specific accounts/services accessMedium — JSON policy
Pre-signed URLTemporary access for specific objectsLow — generate with SDK
S3 Access PointsNamed endpoints per application/teamMedium — one policy per access point
VPC Endpoint PolicyOnly allow S3 access from within VPCMedium — endpoint + bucket policy
Exam Tip: Pre-signed URLs inherit the permissions of the IAM user or role that GENERATED them. If the role loses access to S3 after the URL is generated, the pre-signed URL still works until it expires. Keep URL expiry times short (minutes for uploads, hours for downloads) to limit exposure.