0
0
GCPcloud~30 mins

Signed URLs for temporary access in GCP - Mini Project: Build & Apply

Choose your learning style9 modes available
Signed URLs for temporary access
📖 Scenario: You work for a company that stores private files in Google Cloud Storage. You want to share a file temporarily with a client without making it public. To do this, you will create a signed URL that allows access to the file for a limited time.
🎯 Goal: Create a signed URL for a Google Cloud Storage object that grants temporary access to the file.
📋 What You'll Learn
Create a variable with the bucket name and object name
Set an expiration time for the signed URL
Generate the signed URL using Google Cloud Storage client
Output the signed URL for sharing
💡 Why This Matters
🌍 Real World
Signed URLs let you share private files securely for a limited time without making them public.
💼 Career
Cloud engineers and developers often use signed URLs to control access to storage resources in real projects.
Progress0 / 4 steps
1
Set up bucket and object names
Create two variables called bucket_name and object_name with the exact values "my-private-bucket" and "documents/report.pdf" respectively.
GCP
Need a hint?

Think of bucket_name as the folder and object_name as the file path inside it.

2
Set the expiration time for the signed URL
Create a variable called expiration_time and set it to 3600 seconds (which is 1 hour).
GCP
Need a hint?

The expiration time controls how long the signed URL will work.

3
Generate the signed URL
Import storage from google.cloud and datetime, timedelta from datetime. Create a storage.Client() instance called client. Use client.bucket(bucket_name) to get the bucket and bucket.blob(object_name) to get the blob. Compute expiration = datetime.utcnow() + timedelta(seconds=expiration_time). Then call blob.generate_signed_url(expiration=expiration) and save the result in a variable called signed_url.
GCP
Need a hint?

Use the Google Cloud Storage client library to create the signed URL.

4
Complete the code to output the signed URL
Add a line that assigns the signed_url variable to a variable called temporary_access_link.
GCP
Need a hint?

This variable will hold the URL you can share with others.