Win Big with Google Cloud NEXT '26: $1,000 in Prizes for the Best Cloud Stories
Source: Dev.to
๐ฏ Step 1 โ Pick a Real Problem You Solved with Google Cloud
The best stories start with pain. Think: โBefore GCP, we had X problem. After GCP, we achieved Y.โ
Examples
- Reduced API latency from 2โฏs to 200โฏms using Cloud Runโฏ+โฏCloud SQL
- Automated monthly reports with Cloud Functions and BigQuery
- Scaled image processing with Cloud Storageโฏ+โฏPub/Subโฏ+โฏCloud Functions
Your Turn โ Choose one real project. For this guide weโll use:
โI built a serverless URL shortener using Cloud Run, Firestore, and Firebase Hosting โ cutting costs by 70โฏ% vs. EC2.โ
๐ป Step 2 โ Build & Document Your Project (With Code)
1. Set Up Your Environment
# Install Google Cloud CLI
curl https://sdk.cloud.google.com | bash
gcloud init
# Enable required APIs
gcloud services enable run.googleapis.com
gcloud services enable firestore.googleapis.com
gcloud services enable cloudbuild.googleapis.com
2. Create the Flask App (main.py)
from flask import Flask, request, jsonify, redirect
from google.cloud import firestore
import string, random, os
import logging
import google.cloud.logging
app = Flask(__name__)
db = firestore.Client()
# Enable Cloud Logging
logging_client = google.cloud.logging.Client()
logging_client.setup_logging()
def generate_short_id(length=6):
return ''.join(random.choices(string.ascii_letters + string.digits, k=length))
@app.route('/shorten', methods=['POST'])
def shorten():
logging.info("Shorten request received")
data = request.get_json()
long_url = data.get('url')
if not long_url:
return jsonify({'error': 'URL is required'}), 400
short_id = generate_short_id()
doc_ref = db.collection('urls').document(short_id)
doc_ref.set({'long_url': long_url})
logging.info(f"Generated short ID: {short_id}")
return jsonify({'short_url': f"https://your-domain.com/{short_id}"}), 201
@app.route('/')
def redirect_url(short_id):
doc_ref = db.collection('urls').document(short_id)
doc = doc_ref.get()
if doc.exists:
return redirect(doc.to_dict()['long_url'])
else:
return "Not found", 404
if __name__ == '__main__':
app.run(debug=True, host='0.0.0.0', port=int(os.getenv('PORT', 8080)))
3. Add requirements.txt
Flask==2.3.3
google-cloud-firestore==2.13.0
google-cloud-logging==3.5.0
4. Create Dockerfile
FROM python:3.11-slim
WORKDIR /app
COPY requirements.txt .
RUN pip install --no-cache-dir -r requirements.txt
COPY . .
CMD ["python", "main.py"]
๐ Step 3 โ Deploy to Google Cloud Run
1. Build and Deploy
# Set your project ID
gcloud config set project YOUR_PROJECT_ID
# Build and deploy
gcloud run deploy url-shortener \
--source . \
--platform managed \
--region us-central1 \
--allow-unauthenticated
Output: Youโll receive a public URL such as https://url-shortener-abcd-uc.a.run.app.
2. Test the API
curl -X POST https://url-shortener-abcd-uc.a.run.app/shorten \
-H "Content-Type: application/json" \
-d '{"url": "https://dev.to"}'
Expected response
{
"short_url": "https://your-domain.com/aB3x9k"
}
Visiting the returned short_url redirects to the original site.
๐ Step 4 โ Add Monitoring (Bonus Points!)
Observability strengthens a submission. The example above already integrates Cloud Logging. After deploying, view logs in the Cloud Console Logs Viewer.
๐ Step 5 โ Write Your Story (Template)
Title
How I Built a Serverless URL Shortener on GCP โ For $5/Month
Problem
Describe the pain point you faced (e.g., high cost and low scalability of an EC2โbased solution).
Solution
Explain the architecture (Cloud Run, Firestore, Firebase Hosting) and why it solved the problem.
Implementation
Include code snippets, deployment steps, and any CI/CD pipelines you used.
Results
Quantify improvements (cost reduction, latency, scalability).
Lessons Learned & Best Practices
Share challenges, optimizations, and advice for others.