The best way to control Claude Code, Codex and more from any computer or phone

main
mdx 138 lines 5.5 KB
Raw
1 ---
2 title: GCP
3 description: Build Google Cloud applications with Alchemy — a runtime (usually Cloud Run) plus typed resources, wired together by bindings that grant least-privilege IAM.
4 ---
5
6 An Alchemy app on Google Cloud is one **runtime**, usually a Cloud Run
7 service, plus the **resources** it uses: databases, buckets, topics,
8 secrets. You connect them with typed **bindings**. Call
9 `GCP.Firestore.ReadWriteDatabase(db)` in your code and Alchemy gives
10 the service its own service account with exactly that role on that
11 database. The code is the IAM policy.
12
13 ```typescript
14 // src/Api.ts
15 import * as GCP from "@alchemy.run/gcp";
16 import * as Effect from "effect/Effect";
17 import * as HttpServerResponse from "effect/http/HttpServerResponse";
18
19 export default class Api extends GCP.Function<Api>()(
20 "Api",
21 { main: import.meta.url, invokerIamDisabled: true },
22 Effect.gen(function* () {
23 const links = yield* GCP.Firestore.Database("Links", {
24 type: "FIRESTORE_NATIVE",
25 });
26 const db = yield* GCP.Firestore.ReadWriteDatabase(links);
27
28 return {
29 fetch: Effect.gen(function* () {
30 yield* db.set("links/demo", { url: "https://alchemy.run" });
31 const link = yield* db.get("links/demo");
32 return yield* HttpServerResponse.json(link?.fields ?? {});
33 }).pipe(Effect.orDie),
34 };
35 }).pipe(Effect.provide(GCP.Firestore.ReadWriteDatabaseHttp)),
36 ) {}
37 ```
38
39 New here? [Set up credentials](/gcp/setup), then start the
40 [tutorial](/gcp/tutorial/part-1).
41
42 ## Pick your runtime
43
44 - **[Cloud Run](/gcp/compute/cloud-run)** — HTTP services that scale to
45 zero. The default, and what every page here builds on.
46 - **[Cloud Run jobs](/gcp/compute/jobs)** — batch work that runs to
47 completion.
48 - **[Worker pools](/gcp/compute/worker-pools)** — always-on queue
49 consumers with no URL.
50 - **[Cloud Functions](/gcp/compute/cloud-functions)** — the same
51 program, built by Google, no local Docker.
52 - **[GKE](/gcp/compute/gke)** — Kubernetes Deployments and Jobs on
53 Autopilot.
54
55 Not sure? See [Choosing a runtime](/gcp/compute/choosing-a-runtime).
56
57 ## Data
58
59 - **[Firestore](/gcp/data/firestore)** — documents as plain objects,
60 no instance to size.
61 - **[Cloud Storage](/gcp/data/storage)** — buckets with read and write
62 clients and signed URLs.
63 - **[Cloud SQL](/gcp/data/cloud-sql)** — Postgres over the Cloud SQL
64 socket, with Drizzle.
65 - **[BigQuery](/gcp/data/bigquery)** — stream rows in, query with
66 parameters.
67 - **[Memorystore](/gcp/data/memorystore)** — Redis on a private IP.
68
69 ## Messaging & events
70
71 - **[Pub/Sub](/gcp/messaging/pubsub)** — publish, then consume by push
72 or pull, with filters and dead letters.
73 - **[Cloud Scheduler](/gcp/messaging/scheduler)** — cron handlers on
74 your service.
75 - **[Storage events](/gcp/messaging/storage-events)** — run code when
76 an object lands.
77 - **[Eventarc](/gcp/messaging/eventarc)** — react to Firestore changes
78 and other Google events.
79
80 ## Frontend & APIs
81
82 - **[Websites](/gcp/frontend/websites)** — Astro, Next.js, Nuxt,
83 SvelteKit, Vite, and more on Cloud Run.
84 - **[Effect HTTP](/gcp/apis/effect-http-api)** and
85 **[Effect RPC](/gcp/apis/effect-rpc)** — typed APIs with typed
86 clients.
87
88 ## AI, security, and operations
89
90 - **[Vertex AI](/gcp/ai/vertex-ai)** — Gemini with no API key.
91 - **[IAM & bindings](/gcp/security/iam)** — exactly what each binding
92 grants.
93 - **[Secret Manager & KMS](/gcp/security/secrets-kms)** — credentials
94 and encryption.
95 - **[Logging & Monitoring](/gcp/observability/monitoring)** — uptime
96 checks and alerts in the same Stack.
97 - **[VPC](/gcp/networking/vpc)** and
98 **[Private services](/gcp/networking/private-services)** — private
99 IPs and service-to-service calls.
100
101 ## What are you building?
102
103 | You're building | Reach for |
104 | --- | --- |
105 | An HTTP API | [Cloud Run](/gcp/compute/cloud-run) + [Firestore](/gcp/data/firestore) |
106 | A typed API | [Effect HTTP on Cloud Run](/gcp/apis/effect-http-api) |
107 | A Postgres-backed app | [Cloud SQL](/gcp/data/cloud-sql) |
108 | A website | [Websites](/gcp/frontend/websites) |
109 | A static site | [Static sites](/gcp/frontend/static-site) |
110 | Background jobs | [Pub/Sub](/gcp/messaging/pubsub) + a [worker pool](/gcp/compute/worker-pools) |
111 | An analytics pipeline | [Pub/Sub](/gcp/messaging/pubsub) → [BigQuery](/gcp/data/bigquery) |
112 | Scheduled work | [Cloud Scheduler](/gcp/messaging/scheduler) or a [scheduled job](/gcp/compute/jobs#run-it-on-a-schedule) |
113 | Upload processing | [Storage events](/gcp/messaging/storage-events) |
114 | A chat endpoint | [Vertex AI](/gcp/ai/vertex-ai) |
115 | Kubernetes workloads | [GKE](/gcp/compute/gke) |
116
117 ## Out of scope
118
119 Alchemy manages infrastructure, not end-user content. APIs whose
120 objects are a person's data are not modelled as resources: Gmail,
121 Forms, Calendar, Drive, Classroom, Chat, Tasks, Keep, People, Blogger,
122 YouTube, Fitness, Apps Script, Street View, Fact Check, and Business
123 Profile. Neither is `prodtt-sasportal`, a test copy of the SAS Portal
124 API.
125
126 The advertising and marketing APIs (Analytics Admin, Display & Video
127 360, Tag Manager, Workspace Reseller, AdSense, AdSense Platform, Ad
128 Exchange Buyer II, Campaign Manager 360, and DoubleClick Bid Manager)
129 need a user's OAuth consent, which a service account can't hold. The
130 Content API for Shopping and Apigee Registry are retired by Google.
131
132 ## Where next
133
134 - [Setup](/gcp/setup) — connect your project.
135 - [Tutorial](/gcp/tutorial/part-1) — from an empty folder to CI/CD in
136 five parts.
137 - [Providers reference](/providers) — generated docs for every GCP
138 resource, well beyond the services covered here.