Create Google Cloud Functions
✓Works with OpenClaudeYou are a Google Cloud Platform developer. The user wants to create and deploy a Google Cloud Function using the gcloud CLI and Cloud Functions API.
What to check first
- Run
gcloud auth listto verify you're authenticated to GCP - Run
gcloud config listto confirm your project ID is set correctly - Ensure you have the Cloud Functions API enabled:
gcloud services enable cloudfunctions.googleapis.com - Check your local gcloud version with
gcloud --version(requires v300+)
Steps
- Create a new directory for your function and initialize it:
mkdir my-function && cd my-function - Create your function code file (
main.pyfor Python orindex.jsfor Node.js) - Create a
requirements.txt(Python) orpackage.json(Node.js) listing dependencies - Choose your trigger type: HTTP, Pub/Sub, Cloud Storage, Firestore, or Cloud Tasks
- Deploy using
gcloud functions deploy [FUNCTION_NAME]with appropriate flags for runtime, trigger-type, and entry-point - Verify deployment completed:
gcloud functions describe [FUNCTION_NAME] - Test the function using
gcloud functions call [FUNCTION_NAME]or curl the HTTP endpoint - Monitor logs with
gcloud functions logs read [FUNCTION_NAME] --limit 50
Code
# main.py - HTTP Cloud Function example
import functions_framework
import json
from datetime import datetime
@functions_framework.http
def hello_world(request):
"""HTTP Cloud Function to process requests."""
try:
# Parse request JSON
request_json = request.get_json(silent=True)
request_args = request.args
# Extract parameters with defaults
name = request_json.get('name') if request_json else None
name = request_args.get('name') if not name else name
name = name or 'World'
# Build response
response = {
'message': f'Hello, {name}!',
'timestamp': datetime.utcnow().isoformat(),
'function': 'hello_world'
}
return json.dumps(response), 200, {'Content-Type': 'application/json'}
except Exception as e:
error_response = {
'error': str(e),
'timestamp': datetime.utcnow().isoformat()
}
return json.dumps(error_response), 500, {'Content-Type': 'application/json'}
# Deploy with:
# gcloud functions deploy hello_world \
# --runtime python39 \
# --trigger-http \
# --allow-unauthenticated \
# --entry-point hello_world \
# --region us-central1
# Test with:
# curl "https://REGION-PROJECT_ID.cloudfunctions.net
Note: this example was truncated in the source. See the GitHub repo for the latest full version.
Common Pitfalls
- Treating this skill as a one-shot solution — most workflows need iteration and verification
- Skipping the verification steps — you don't know it worked until you measure
- Applying this skill without understanding the underlying problem — read the related docs first
When NOT to Use This Skill
- When a simpler manual approach would take less than 10 minutes
- On critical production systems without testing in staging first
- When you don't have permission or authorization to make these changes
How to Verify It Worked
- Run the verification steps documented above
- Compare the output against your expected baseline
- Check logs for any warnings or errors — silent failures are the worst kind
Production Considerations
- Test in staging before deploying to production
- Have a rollback plan — every change should be reversible
- Monitor the affected systems for at least 24 hours after the change
Related Cloud (AWS/GCP/Azure) Skills
Other Claude Code skills in the same category — free to download.
Lambda Function
Create AWS Lambda function with handler
S3 Operations
Set up S3 bucket operations (upload, download, presigned URLs)
DynamoDB CRUD
Create DynamoDB CRUD operations
SQS Setup
Set up SQS queue producer and consumer
SNS Notifications
Configure SNS for push notifications
CloudFront Setup
Set up CloudFront CDN distribution
Cognito Auth
Implement AWS Cognito authentication
RDS Setup
Configure RDS database connection
Want a Cloud (AWS/GCP/Azure) skill personalized to YOUR project?
This is a generic skill that works for everyone. Our AI can generate one tailored to your exact tech stack, naming conventions, folder structure, and coding patterns — with 3x more detail.