/serverless-compute-skills:google-cloud-functions-configurationfrom serverless-compute-skills
Configures Google Cloud Functions Gen1 vs Gen2 runtime differences, HTTP/event/CloudEvent triggers, and min/max instance scaling settings to manage cold-start and concurrency tradeoffs.
Ships in serverless-compute-skills. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
None: SKILL.md is the whole skill.
Google Cloud Functions ships as two distinct generations with materially
different execution models: Gen1 runs on a purpose-built, single-
concurrency-per-instance execution environment, while Gen2 runs on
top of Cloud Run and Eventarc, giving it concurrent requests per
instance, longer timeouts, and larger max instance counts — but also a
different (and in some cases slower) cold-start profile and a different
trigger/IAM plumbing underneath. Picking the wrong generation, or
carrying over Gen1 scaling assumptions (maxInstances as a hard
concurrency limit, one request per instance) into a Gen2 function, is a
common source of unexpected throttling, cost, or latency. This skill
covers choosing between generations, wiring triggers correctly for each,
and setting min/max instance scaling deliberately rather than by default.
min-instances/max-instances to control cold starts and
cap cost/blast radius.max-instances
looking generous, or one that cold-starts on every invocation despite
steady traffic.gcloud/Deployment Manager) change that
touches a Cloud Function's generation, trigger, or scaling block.gcloud CLI authenticated against the target project, with the
cloudfunctions.functions.* and (for Gen2) run.services.* and
eventarc.triggers.* IAM permissions — Gen2 functions are Cloud Run
services underneath, and Eventarc-routed triggers need their own
service account permissions.gcloud components update recent enough to support --gen2 and
Gen2-specific flags (gcloud functions deploy gained --gen2 in the
gcloud CLI well before Gen2 became the default for new deploys in
the console; always pass the flag explicitly in scripts/CI rather
than relying on the CLI's current default).gcloud functions runtimes list --region=<REGION> since supported
runtimes and their generation availability change over time — don't
assume a runtime available in Gen1 is available in Gen2 or vice
versa).Choose the generation deliberately, not by inertia. Gen2 is the better default for new functions needing larger max instance counts, concurrent requests per instance (reducing instance count needed under load), longer timeouts, or larger resource allocations — it runs on Cloud Run. Gen1 remains simpler and can have a faster per-request cold start for very small, single-purpose functions since there's no Cloud Run revision layer underneath. Decide once per function and be explicit in every deploy path (CLI, Terraform, CI):
# Gen2 explicit
gcloud functions deploy order-validator \
--gen2 \
--runtime=nodejs20 \
--region=us-central1 \
--source=. \
--entry-point=validateOrder \
--trigger-http \
--no-allow-unauthenticated
# Gen1 explicit
gcloud functions deploy legacy-thumbnail \
--no-gen2 \
--runtime=nodejs18 \
--region=us-central1 \
--source=. \
--entry-point=makeThumbnail \
--trigger-bucket=<GCS_BUCKET_NAME>
Wire triggers according to generation. Gen1 event triggers
(--trigger-bucket, --trigger-topic) call the underlying service
directly; Gen2 event triggers route through Eventarc even for
the same-looking source, which means the function's runtime service
account needs roles/eventarc.eventReceiver and the Eventarc trigger
needs its own service account with permission to invoke the
underlying Cloud Run service:
gcloud functions deploy image-processor \
--gen2 \
--runtime=python312 \
--region=us-central1 \
--source=. \
--entry-point=process_image \
--trigger-event-filters="type=google.cloud.storage.object.v1.finalized" \
--trigger-event-filters="bucket=<GCS_BUCKET_NAME>" \
--trigger-service-account=eventarc-trigger-sa@<PROJECT_ID>.iam.gserviceaccount.com
A Gen2 CloudEvent function receives a standardized CloudEvent
envelope (type, source, data), not the Gen1-specific event
payload shape — code written for Gen1's event, context signature
needs a compatibility shim or a rewrite to the CloudEvent
functions-framework signature when migrating.
Set min-instances deliberately to trade cost for cold-start
latency, not left at the default of zero for latency-sensitive
paths:
gcloud functions deploy checkout-api \
--gen2 \
--region=us-central1 \
--min-instances=1 \
--max-instances=50 \
--concurrency=40 \
--cpu=1 \
--memory=512Mi
--min-instances keeps that many instances warm continuously — this
is a direct, ongoing cost, so size it to the smallest number that
keeps p99 cold-start-affected latency acceptable, not to "always
warm" by default.
Set max-instances against real downstream capacity, and remember
Gen2's --concurrency changes what max-instances actually caps.
In Gen1, each instance serves exactly one request, so max-instances
directly bounds concurrent requests. In Gen2, each instance can serve
up to --concurrency concurrent requests, so the effective request
ceiling is max-instances × concurrency — a Gen2 function with
max-instances=50, concurrency=40 can have up to 2,000 concurrent
requests hitting a downstream database that may only tolerate a
fraction of that:
gcloud functions describe checkout-api --gen2 --region=us-central1 \
--format="value(serviceConfig.maxInstanceCount,serviceConfig.maxInstanceRequestConcurrency)"
Size max-instances against the actual capacity of whatever the
function calls (a database connection pool, a rate-limited
third-party API), not against an arbitrary round number.
Validate the runtime service account is scoped per function, not the shared default compute service account. Both generations default to the project's default compute service account if none is specified — assign a dedicated, least-privilege service account per function instead:
gcloud functions deploy order-validator \
--gen2 \
--service-account=order-validator-sa@<PROJECT_ID>.iam.gserviceaccount.com
Confirm timeout and resource limits match the generation's ceiling. Gen1 caps HTTP function timeout at 9 minutes (event-driven functions at 9 minutes as well) and has lower max memory/CPU ceilings than Gen2, which allows longer timeouts and larger CPU/memory allocations because it runs on Cloud Run. A function migrated from Gen1 assuming Gen1's ceilings may be needlessly under-provisioned on Gen2 — but don't over-provision reflexively either; size to measured need.
min-instances > 0 as a cost decision requiring sign-off, not a
reflexive fix for cold-start complaints — measure actual cold-start
impact on the SLO before paying to keep instances warm.max-instances against the weakest downstream dependency's
actual capacity (DB connections, third-party rate limits), factoring
in Gen2's concurrency multiplier, not against Cloud Functions' own
account-level ceiling.nodejs20, not an
unspecified "latest") in CI/IaC so a Google-side default runtime bump
doesn't silently change behavior.Symptom: A Gen2 function's downstream database starts refusing
connections under moderate traffic even though max-instances looks
conservative.
Fix: The effective concurrent-request ceiling is
max-instances × concurrency, not max-instances alone; lower
--concurrency (down to 1 reproduces Gen1's one-request-per-instance
model) or size the downstream connection pool/pooler (e.g. a proxy in
front of the database) to the true worst-case concurrency.
Symptom: A Cloud Storage-triggered function migrated from Gen1 to
Gen2 stops firing, or fires with a payload the code can't parse.
Fix: Gen2 event triggers route through Eventarc and deliver a
CloudEvent envelope, not Gen1's native event/context payload; update
the trigger to --trigger-event-filters with the Eventarc event type,
grant the trigger's service account roles/eventarc.eventReceiver and
invoke permission on the underlying Cloud Run service, and update the
function code to the CloudEvent function signature.
Symptom: A latency-sensitive HTTP function shows an occasional
multi-second spike in p99 latency despite steady traffic volume.
Fix: min-instances is likely 0, so instances scale down during
low-traffic windows and cold-start on the next request; set
min-instances to at least 1 (or higher, sized to expected
concurrent baseline traffic) for latency-sensitive paths, accepting
the added standing cost.
Symptom: A function's service account shows broad project-level
roles when reviewed, inherited from the project's default compute
service account.
Fix: Deploy did not specify --service-account; create and assign
a dedicated per-function service account scoped only to the specific
APIs/resources that function calls, then redeploy and rotate out the
default-service-account binding.
Symptom: A team assumes Gen1 timeout/memory ceilings still apply
after migrating to Gen2 and under-provisions a long-running batch-style
function, causing it to time out.
Fix: Gen2 (Cloud Run-backed) supports longer timeouts and larger
memory/CPU allocations than Gen1; check current ceilings with
gcloud functions describe --gen2 against the deployed
serviceConfig.timeoutSeconds/availableMemoryMb and raise them
explicitly rather than assuming Gen1's lower ceiling still applies.
Scenario: An order-validation HTTP function currently on Gen1 suffers cold starts during a morning traffic ramp, and a separate Cloud Storage-triggered thumbnail function needs to move to Gen2 as part of a platform-wide migration.
Gen2 deploy for the latency-sensitive HTTP function, with a warm pool sized to the observed baseline concurrent request count:
gcloud functions deploy order-validator \
--gen2 \
--runtime=nodejs20 \
--region=us-central1 \
--source=. \
--entry-point=validateOrder \
--trigger-http \
--no-allow-unauthenticated \
--service-account=order-validator-sa@<PROJECT_ID>.iam.gserviceaccount.com \
--min-instances=2 \
--max-instances=30 \
--concurrency=20 \
--cpu=1 \
--memory=512Mi \
--timeout=30s
With min-instances=2, at least two instances stay warm through
traffic lulls, eliminating cold starts on the morning ramp; max- instances=30 × concurrency=20 caps effective concurrent requests at
600, checked against the order-validation database's connection pooler
capacity before deploy.
Gen2 migration for the Cloud Storage-triggered function, moving off Gen1's native bucket trigger to an Eventarc-routed one:
gcloud functions deploy image-processor \
--gen2 \
--runtime=python312 \
--region=us-central1 \
--source=. \
--entry-point=process_image \
--trigger-event-filters="type=google.cloud.storage.object.v1.finalized" \
--trigger-event-filters="bucket=<GCS_BUCKET_NAME>" \
--trigger-service-account=eventarc-trigger-sa@<PROJECT_ID>.iam.gserviceaccount.com \
--max-instances=10 \
--memory=1Gi
The function code is updated from Gen1's def make_thumbnail(event, context): signature to the CloudEvent-based
functions-framework signature (@functions_framework.cloud_event /
def process_image(cloud_event):), and eventarc-trigger-sa is
granted roles/eventarc.eventReceiver plus invoke permission on the
resulting Cloud Run service before cutting the Gen1 trigger over.
What SKILL.md sets; muted values are Claude Code's defaults
Three short reads, in order
npx claudepluginhub selvarajmurugesan90/ops-engineering-skills --plugin serverless-compute-skills10 skills in this plugin
/aws-lambda-configuration-validationValidates an AWS Lambda function's configuration — reserved/provisioned concurrency budget, VPC networking config, environment variables, IAM execution role scope, and failure handling — before it deploys, catching problems that only otherwise surface as production throttling or an incident. Use when the user asks to "validate a Lambda function before deploy," "check Lambda reserved concurrency," "review a Lambda IAM role," "why is my Lambda throttling," or "add a pre-deploy check for Lambda config."
/aws-lambda-packaging-and-configurationPackages an AWS Lambda function as a zip deployment package or container image, tunes memory/timeout/ephemeral storage, mitigates cold starts, and scopes the function's IAM execution role to least privilege. Use when the user asks to "package a Lambda function," "build a container image for Lambda," "reduce Lambda cold start latency," "tune Lambda memory or timeout," "add a Lambda layer," or "scope down a Lambda execution role."
/azure-functions-configurationConfigures Azure Functions hosting plans (Consumption, Premium, Dedicated/App Service), triggers and bindings, and host.json/ application settings, with explicit cold-start tradeoffs between plans. Use when the user asks to "choose an Azure Functions hosting plan," "set up a Function App trigger or binding," "reduce Azure Functions cold start," "configure Premium plan pre-warmed instances," or "write host.json for a Function App."
/dapr-configuration-validationValidates Dapr component configurations — state store, pub/sub, and binding components — before deploy, catching missing scopes, inline secrets, unbounded retries, and resiliency gaps that `kubectl apply` won't reject. Use when the user asks to "validate a Dapr component before deploy," "check Dapr component scoping," "review a Dapr pub/sub config for secrets," "add a pre-deploy gate for Dapr components," or "why did my Dapr component apply but not work as expected."
/dapr-distributed-runtime-configurationConfigures Dapr's sidecar building blocks — state management, pub/sub, and service invocation — for polyglot microservices, including component YAML, sidecar annotations, and resiliency policies. Use when the user asks to "add a Dapr state store component," "set up Dapr pub/sub between services," "call another service via Dapr service invocation," "configure a Dapr sidecar for a Kubernetes deployment," or "add retry/circuit-breaker resiliency to a Dapr building block."
/hashicorp-nomad-scheduling-and-configurationConfigures HashiCorp Nomad job specifications, scheduler types, and cluster topology as a lighter-weight alternative to Kubernetes for scheduling containers, binaries, and batch/system workloads. Use when the user asks to "write a Nomad job spec," "choose service vs. batch vs. system scheduler in Nomad," "compare Nomad to Kubernetes for our use case," "set up Nomad server/client topology," "add a Nomad update/canary deployment strategy," or "run non-containerized workloads under a scheduler."
Other plugins' skills for the same job