GCP Cloud Functions Cheat Sheet
Reference for deploying event-driven and HTTP-triggered serverless functions on Google Cloud Functions.
2 PagesIntermediateFeb 20, 2026
Python HTTP Function
A minimal HTTP-triggered Cloud Function (2nd gen).
python
import functions_frameworkfrom flask import jsonify@functions_framework.httpdef hello_http(request): name = request.args.get('name', 'World') return jsonify({"message": f"Hello, {name}!"})
Deploy via gcloud
Deploy an HTTP function and a Pub/Sub-triggered function.
bash
# HTTP-triggeredgcloud functions deploy hello_http \ --gen2 --runtime=python312 --region=us-central1 \ --source=. --entry-point=hello_http \ --trigger-http --allow-unauthenticated# Pub/Sub-triggeredgcloud functions deploy process_message \ --gen2 --runtime=python312 --region=us-central1 \ --source=. --entry-point=process_message \ --trigger-topic=my-topic
Pub/Sub-Triggered Function
React to messages published to a topic.
python
import functions_frameworkimport base64@functions_framework.cloud_eventdef process_message(cloud_event): data = base64.b64decode(cloud_event.data["message"]["data"]) print(f"Received: {data.decode('utf-8')}")
Trigger Types
Key trigger types to know.
- HTTP Trigger- Invoked directly via an HTTPS endpoint
- Pub/Sub Trigger- Fires when a message is published to a topic
- Cloud Storage Trigger- Fires on object finalize, delete, or metadata update events
- Firestore Trigger- Fires on document create, update, or delete
- Eventarc- Unified eventing backbone routing Google Cloud/Cloud Audit Log events (2nd gen)
1st Gen vs 2nd Gen
Key 1st gen vs 2nd gen to know.
- 2nd Gen- Built on Cloud Run + Eventarc; supports concurrency, longer timeouts (up to 60 min), larger instances
- 1st Gen- Legacy platform, max 9-minute timeout, simpler event model
- Concurrency- 2nd gen functions can handle multiple requests per instance simultaneously
- Cold Start- Latency incurred spinning up a new instance after scale-to-zero
Pro Tip
Prefer 2nd generation Cloud Functions for new projects — they run on Cloud Run under the hood, giving you longer timeouts, larger max instance sizes, and request concurrency that 1st gen doesn't support.
Was this cheat sheet helpful?
Explore Topics
#GCPCloudFunctions#GCPCloudFunctionsCheatSheet#CloudComputing#Intermediate#PythonHTTPFunction#DeployViaGcloud#Pub#Sub#Functions#Networking#CheatSheet#SkillVeris
Advertisement
Sri Hayavadhana Info-Tech
Professional Web Designing Services
- Responsive Websites
- E-commerce Solutions
- SEO Friendly Design
- Fast & Secure
- Support & Maintenance