Signed URLs & Static Sites

Signed URLs

Keep a bucket private and give users temporary access to one object with a signed URL, e.g. a 15-minute download link for a paid course video:

from datetime import timedelta
from google.cloud import storage

blob = storage.Client().bucket("course-media-1234").blob("videos/lecture1.mp4")
url = blob.generate_signed_url(version="v4", expiration=timedelta(minutes=15), method="GET")
print(url)

Hosting a Static Website

gcloud storage buckets update gs://www.example.com --web-main-page-suffix=index.html --web-error-page=404.html
gcloud storage buckets add-iam-policy-binding gs://www.example.com --member=allUsers --role=roles/storage.objectViewer

Tip: For HTTPS on your own domain and global caching, put the bucket behind an external HTTPS load balancer with Cloud CDN.