agentleFS
Ghost7802Ghost7802/awesome-api-skills/skills/google-cloud-run/SKILL.md

google-cloud-run

Skill13 starsChanged 26 days agoMITView on GitHub

Verification Tier: code_example_tested | Last Verified: 2026-11-18 Official Docs: https://cloud.google.com/run/docs/authenticating/service-to-service

  • Reads credentials
  • Installs packages

The file

We split this skill into the rules it gives an agent

1 rule. About 0 are common, 0 are distinctive, and 1 is very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈0

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 1

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Very specific:

    Use gcloud run services proxy for authenticated local testing against private services instead of opening them to allUsers.

    line 27

≈ “Common” is an estimate: at least 1 in 5 of the 408,460 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

Google Cloud Run Skill

Verification Tier: code_example_tested | Last Verified: 2026-11-18
Official Docs: https://cloud.google.com/run/docs/authenticating/service-to-service

Overview

Google Cloud Run executes stateless HTTP containers with automatic scale-to-zero and IAM-enforced service-to-service authentication via Google-signed OIDC Identity Tokens.

Installation

npm install google-auth-library

Authentication (Service-to-Service OIDC)

For private Cloud Run services (--no-allow-unauthenticated):

  1. Grant the caller's service account the roles/run.invoker IAM role on the target service.
  2. Fetch a Google-signed OIDC Identity Token whose audience is set to the exact target Cloud Run service root URL (e.g., https://billing-service-xyz.a.run.app) using google-auth-library (auth.getIdTokenClient(targetAudience)) or the GCP metadata server.
  3. Pass Authorization: Bearer <ID_TOKEN>.

Core Concepts

  • Container Contract: Listen on 0.0.0.0 and Number(process.env.PORT) || 8080. Never hardcode port 3000 ignoring PORT.
  • Graceful Shutdown (SIGTERM): Cloud Run sends SIGTERM and allows up to 10 seconds to drain in-flight requests and flush logs/DB connections before SIGKILL.
  • CPU Allocation: Background async work after returning an HTTP response is throttled unless CPU is configured as always-allocated (--no-cpu-throttling).

Error Handling & Rate Limits

  • Retry transient 503 cold-start / scaling responses with jittered backoff.
  • Use gcloud run services proxy for authenticated local testing against private services instead of opening them to allUsers.

Security Best Practices

  • Assign a dedicated least-privilege runtime service account per Cloud Run service (never use the overly broad Compute Engine default service account).
  • Mount secrets via Google Secret Manager integration instead of committing secrets in container images.

AI Pitfalls

  • Sending an OAuth2 Access Token instead of an OIDC Identity Token with audience = targetServiceUrl (results in HTTP 401/403).
  • Binding HTTP servers to localhost/127.0.0.1 instead of 0.0.0.0, causing Cloud Run startup health checks to fail.
  • Spawning fire-and-forget promises after sending the HTTP response with default request-based CPU throttling.

Production Checklist

  • Server binds to 0.0.0.0 on process.env.PORT || 8080
  • SIGTERM handler closes HTTP server and flushes connections cleanly
  • Private service callers hold roles/run.invoker and send OIDC ID tokens with exact target URL audience
  • Dedicated least-privilege runtime service account attached

References

Related skills

  • docker — depends on
  • google-cloud-storage — works well with
  • google-maps-platform — works well with

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.