Skip to content

Local Testing — GCP (floci-gcp)

llms.txt lists every page for an agent
Optional: hand this page to your coding agentThe steps work by hand too.
Show the whole prompt
Read https://intentius.io/chant/local-testing/gcp/.
In `examples/local-cloud-trio`, run `npm install` and then `npx chant run gcp --no-record`. The run boots floci-gcp and applies the manifest with `gcpApply`. After checking the bucket it removes the container. Docker has to be running.
Keep the `endpoint` override on the local floci-gcp port, and show me what the run prints.
Never deploy to a real cloud account or shared environment (with `chant run`, `chant components` or a platform's own CLI), approve (a pull request review, `chant approve` or `chant run approve`), override a policy denial (`chant approve policy-override`), or merge; never cut or publish a release (`chant release cut --yes` or `chant release publish`), push or delete a `ci/*` tag (`chant ci tick` pushes them), or change the value of an existing flag; never touch `.chant/allowed_signers` or `chant/lifecycle`.

GCP has no native deployment service — Deployment Manager is retired, and Config Connector needs a cluster running its operator. gcpApply applies chant’s Config Connector output to a local emulator itself: it maps each resource to its underlying Google REST API and drives create, update, and delete itself against floci-gcp.

A GCS bucket, described as data. It synthesizes to a Config Connector manifest:

src/gcp/infra.ts
export const bucket = new StorageBucket({
metadata: {
name: "trio-bucket",
labels: { "app.kubernetes.io/managed-by": "chant" },
},
location: "US",
storageClass: "STANDARD",
uniformBucketLevelAccess: true,
versioning: { enabled: true },
});

chant run gcp boots floci-gcp, builds the manifest, applies it with gcpApply, verifies the bucket over the GCS REST API, and removes the container.

ops/gcp.op.ts
export default Op({
name: "gcp",
taskQueue: "trio-gcp",
phases: [
phase("Emulator", [flociGcpUp()]),
phase("Build", [build(".", { script: "build:gcp" })]),
phase("Apply", [gcpApply("dist/gcp.yaml", { endpoint: "http://localhost:4588", project: "local-project" })]),
phase("Verify", [httpCheck("http://localhost:4588/storage/v1/b/trio-bucket")]),
phase("Teardown", [flociGcpDown()]),
],
});

Config Connector normally reconciles a CRD on a cluster into Google API calls. gcpApply performs that reconciliation directly, no cluster involved:

  • Maps each kind to its REST resource via a dispatch table (MAPPERS in lexicons/gcp/src/op/activities/gcp-apply.ts), which covers a VPC network and its subnetworks and the Cloud Run serverless load balancer beside the storage and IAM kinds.
  • Merges an IAM policy member into its target’s policy with getIamPolicy and then setIamPolicy, so the policy’s other bindings stay as they were.
  • Orders resources by their references so a dependency applies before its dependent.
  • Turns Config Connector refs into API fields where the API takes something else: a Cloud Run service’s serviceAccountRef becomes the account’s email, and its vpcAccess networkRef and subnetworkRef become network and subnetwork paths.
  • Drives full CRUD, following long-running operations to completion where the API returns one.
  • Updates an existing load balancer resource in place where compute allows it. A backend service or URL map takes a PATCH with the live fingerprint. A proxy changes its URL map through setUrlMap, and a forwarding rule its target through setTarget. Labels go through setLabels. A change compute can’t make in place is printed as replace required and left for you; that covers any change to a serverless NEG and a forwarding rule’s IP.
  • Prunes orphans it owns — resources carrying the managed-by: chant label that are no longer in the manifest — and leaves everything else alone.

Every call is the real GCS/PubSub/IAM shape, pointed at the emulator.

Requires Docker and curl on PATH.

Terminal window
cd examples/local-cloud-trio
npm install
chant run gcp

Each resource is applied and read in one project, taken from its own spec.projectRef.external, then gcp.project in the member’s chant.config.ts, then GCP_PROJECT_ID, then GOOGLE_CLOUD_PROJECT. With gcp.project set once, chant graph --live reads a load balancer or network resource that has no projectRef of its own without any variable set.

Drop the endpoint override and gcpApply targets the real Google APIs for the same project. The manifest and the reconciliation logic are unchanged — this is the same code path a live apply takes.

chant