@caelo-cms/provisioning 0.11.18 → 0.11.20
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/agent-db.js +32 -0
- package/dist/aws-task-roles.d.ts +11 -0
- package/dist/aws-task-roles.d.ts.map +1 -1
- package/dist/aws-task-roles.js +19 -0
- package/dist/aws-task-roles.js.map +1 -1
- package/dist/azure-secrets.d.ts +22 -0
- package/dist/azure-secrets.d.ts.map +1 -0
- package/dist/azure-secrets.js +14 -0
- package/dist/azure-secrets.js.map +1 -0
- package/dist/caddy.d.ts +7 -0
- package/dist/caddy.d.ts.map +1 -1
- package/dist/caddy.js +22 -1
- package/dist/caddy.js.map +1 -1
- package/dist/cli.js +3 -0
- package/dist/cli.js.map +1 -1
- package/dist/gateway-armor.d.ts +24 -0
- package/dist/gateway-armor.d.ts.map +1 -0
- package/dist/gateway-armor.js +118 -0
- package/dist/gateway-armor.js.map +1 -0
- package/dist/gateway-edge.d.ts +128 -0
- package/dist/gateway-edge.d.ts.map +1 -0
- package/dist/gateway-edge.js +211 -0
- package/dist/gateway-edge.js.map +1 -0
- package/dist/infra-contract.d.ts +1 -1
- package/dist/infra-contract.d.ts.map +1 -1
- package/dist/infra-contract.js +21 -1
- package/dist/infra-contract.js.map +1 -1
- package/dist/lifecycle.d.ts.map +1 -1
- package/dist/lifecycle.js +8 -1
- package/dist/lifecycle.js.map +1 -1
- package/dist/pool-budget-stack.d.ts +22 -0
- package/dist/pool-budget-stack.d.ts.map +1 -1
- package/dist/pool-budget-stack.js +22 -1
- package/dist/pool-budget-stack.js.map +1 -1
- package/dist/public-service-shape.d.ts +45 -0
- package/dist/public-service-shape.d.ts.map +1 -0
- package/dist/public-service-shape.js +90 -0
- package/dist/public-service-shape.js.map +1 -0
- package/dist/remote-mcp-edge.d.ts +4 -4
- package/dist/remote-mcp-edge.d.ts.map +1 -1
- package/dist/remote-mcp-edge.js +2 -2
- package/dist/remote-mcp-edge.js.map +1 -1
- package/dist/remote-mcp.d.ts.map +1 -1
- package/dist/remote-mcp.js +30 -19
- package/dist/remote-mcp.js.map +1 -1
- package/dist/serverless-backend.d.ts +27 -0
- package/dist/serverless-backend.d.ts.map +1 -0
- package/dist/serverless-backend.js +30 -0
- package/dist/serverless-backend.js.map +1 -0
- package/dist/stack-contract.d.ts +6 -0
- package/dist/stack-contract.d.ts.map +1 -1
- package/dist/stack-contract.js +24 -0
- package/dist/stack-contract.js.map +1 -1
- package/dist/stack-converge.d.ts +13 -0
- package/dist/stack-converge.d.ts.map +1 -1
- package/dist/stack-converge.js +27 -0
- package/dist/stack-converge.js.map +1 -1
- package/dist/staging-gateway-setup.d.ts +5 -0
- package/dist/staging-gateway-setup.d.ts.map +1 -1
- package/dist/staging-gateway-setup.js +88 -28
- package/dist/staging-gateway-setup.js.map +1 -1
- package/dist/upgrade/app-roll.d.ts +5 -1
- package/dist/upgrade/app-roll.d.ts.map +1 -1
- package/dist/upgrade/app-roll.js +20 -3
- package/dist/upgrade/app-roll.js.map +1 -1
- package/dist/upgrade/converge.d.ts.map +1 -1
- package/dist/upgrade/converge.js +27 -4
- package/dist/upgrade/converge.js.map +1 -1
- package/dist/upgrade/health.d.ts +13 -3
- package/dist/upgrade/health.d.ts.map +1 -1
- package/dist/upgrade/health.js +24 -7
- package/dist/upgrade/health.js.map +1 -1
- package/dist/upgrade/load-balancer-get.d.ts +17 -0
- package/dist/upgrade/load-balancer-get.d.ts.map +1 -0
- package/dist/upgrade/load-balancer-get.js +38 -0
- package/dist/upgrade/load-balancer-get.js.map +1 -0
- package/dist/upgrader-gcp.d.ts.map +1 -1
- package/dist/upgrader-gcp.js +8 -1
- package/dist/upgrader-gcp.js.map +1 -1
- package/dist/wizards/gcp-cost.d.ts +9 -0
- package/dist/wizards/gcp-cost.d.ts.map +1 -1
- package/dist/wizards/gcp-cost.js +69 -34
- package/dist/wizards/gcp-cost.js.map +1 -1
- package/dist/wizards/gcp.js +1 -1
- package/dist/wizards/gcp.js.map +1 -1
- package/package.json +2 -2
- package/src/aws-task-roles.ts +22 -0
- package/src/azure-secrets.ts +38 -0
- package/src/caddy.test.ts +19 -2
- package/src/caddy.ts +23 -0
- package/src/cli.ts +5 -0
- package/src/gateway-armor.ts +135 -0
- package/src/gateway-bootstrap.test.ts +1 -0
- package/src/gateway-edge.test.ts +262 -0
- package/src/gateway-edge.ts +256 -0
- package/src/gateway-env-isolation.test.ts +45 -6
- package/src/infra-contract.test.ts +5 -3
- package/src/infra-contract.ts +21 -1
- package/src/lifecycle.ts +8 -1
- package/src/pool-budget-stack.ts +25 -0
- package/src/pool-budget-stacks.test.ts +31 -0
- package/src/public-service-shape.test.ts +166 -0
- package/src/public-service-shape.ts +131 -0
- package/src/remote-mcp-edge.ts +2 -2
- package/src/remote-mcp.test.ts +63 -2
- package/src/remote-mcp.ts +42 -19
- package/src/serverless-backend.ts +47 -0
- package/src/stack-contract.test.ts +13 -0
- package/src/stack-contract.ts +25 -0
- package/src/stack-converge.test.ts +28 -1
- package/src/stack-converge.ts +30 -0
- package/src/staging-gateway-setup.test.ts +134 -3
- package/src/staging-gateway-setup.ts +107 -36
- package/src/upgrade/app-roll.ts +27 -3
- package/src/upgrade/converge.ts +33 -4
- package/src/upgrade/health.test.ts +88 -13
- package/src/upgrade/health.ts +32 -7
- package/src/upgrade/load-balancer-get.ts +64 -0
- package/src/upgrade/upgrade.test.ts +97 -4
- package/src/upgrader-gcp.ts +8 -1
- package/src/wizards/gcp-cost.ts +78 -35
- package/src/wizards/gcp.ts +2 -1
- package/stacks/aws/index.ts +24 -22
- package/stacks/azure/index.ts +152 -64
- package/stacks/gcp/index.ts +35 -47
- package/stacks/gcp-firebase/index.ts +25 -13
package/stacks/azure/index.ts
CHANGED
|
@@ -14,8 +14,9 @@
|
|
|
14
14
|
* domain with a managed certificate — files served as files, no compute
|
|
15
15
|
* on the request path (CLAUDE.md §11.B Tier 1).
|
|
16
16
|
* 5. Azure Container Apps (admin/gateway/orchestrator/runner, and the
|
|
17
|
-
* MCP-Auth-Proxy without any secret, #1328)
|
|
18
|
-
*
|
|
17
|
+
* MCP-Auth-Proxy without any secret, #1328). Database passwords are
|
|
18
|
+
* Key Vault references read through a user-assigned identity per
|
|
19
|
+
* service (#1339): the URLs carry no password.
|
|
19
20
|
* 6. Key Vault entries (postgres-password, csrf-secret, cookie-secret,
|
|
20
21
|
* anthropic-api-key, resend-api-key).
|
|
21
22
|
* 7. Log Analytics workspace receives Container Apps logs;
|
|
@@ -40,6 +41,11 @@ import * as azure from "@pulumi/azure-native";
|
|
|
40
41
|
import * as pulumi from "@pulumi/pulumi";
|
|
41
42
|
import type { CloudAdapterOutputs, DnsRecord } from "../../dist/adapter.js";
|
|
42
43
|
import { azureFrontDoorDnsRecords } from "../../dist/azure-front-door.js";
|
|
44
|
+
import {
|
|
45
|
+
AZURE_SERVICE_DATABASE_SECRETS,
|
|
46
|
+
type AzureDatabaseSecret,
|
|
47
|
+
type AzureSecretReader,
|
|
48
|
+
} from "../../dist/azure-secrets.js";
|
|
43
49
|
import { generateBootstrapToken } from "../../dist/bootstrap-token.js";
|
|
44
50
|
import {
|
|
45
51
|
DEFAULT_MAX_CONNECTIONS,
|
|
@@ -86,6 +92,10 @@ const maxConnections = Number.parseInt(
|
|
|
86
92
|
);
|
|
87
93
|
/** Replicas each Container App may scale to (see containerApp). */
|
|
88
94
|
const MAX_REPLICAS = 10;
|
|
95
|
+
// The §11.B knob, same name and default as every adapter: the public API
|
|
96
|
+
// gateway scales to zero unless the operator keeps replicas warm (E14 a of
|
|
97
|
+
// #763: a public service is provisioned at zero minimum instances).
|
|
98
|
+
const gatewayMinInstances = Number.parseInt(cfg.get("gatewayMinInstances") ?? "0", 10);
|
|
89
99
|
// The admin, orchestrator and runner apps all open the admin's two pools,
|
|
90
100
|
// so the budget counts their replicas together as admin instances.
|
|
91
101
|
const ADMIN_SIDE_APPS = 3;
|
|
@@ -153,8 +163,8 @@ function keyVaultSecret(shortName: string, value: pulumi.Output<string>): azure.
|
|
|
153
163
|
});
|
|
154
164
|
}
|
|
155
165
|
|
|
156
|
-
const
|
|
157
|
-
keyVaultSecret("public-role-password", publicRolePassword);
|
|
166
|
+
const pgSecret = keyVaultSecret("pg-password", postgresPassword);
|
|
167
|
+
const publicRoleSecret = keyVaultSecret("public-role-password", publicRolePassword);
|
|
158
168
|
// #1329 — read by nothing yet: the staging gateway's app (#750) will.
|
|
159
169
|
keyVaultSecret("public-staging-role-password", publicStagingRolePassword);
|
|
160
170
|
keyVaultSecret("csrf-secret", csrfSecret);
|
|
@@ -220,31 +230,22 @@ const _pgPublicStaging = new azure.dbforpostgresql.Database(`${namePrefix}-cms-p
|
|
|
220
230
|
// Bun trusts out of the box, so no sslrootcert (shared database-tls.ts).
|
|
221
231
|
const AZURE_TLS = verifyFullQuery();
|
|
222
232
|
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
233
|
+
// #1339 (epic #763 L5) — password-less, like on GCP: the password is a Key
|
|
234
|
+
// Vault reference on the Container App (AZURE_SERVICE_DATABASE_SECRETS),
|
|
235
|
+
// never part of the URL, so it shows up neither in the app's env nor in its
|
|
236
|
+
// revision history (shared database-url.ts `<NAME>_PASSWORD`).
|
|
237
|
+
const dbUrl = (role: string, db: string) =>
|
|
238
|
+
pulumi.interpolate`postgresql://${role}@${pgServer.fullyQualifiedDomainName}:5432/${db}?${AZURE_TLS}`;
|
|
239
|
+
const adminDatabaseUrl = dbUrl("caelo_admin", "cms_admin");
|
|
226
240
|
// What the admin connects to cms_public with (DDL, migrations, moderation).
|
|
227
|
-
const publicAdminDatabaseUrl =
|
|
228
|
-
.all([pgServer.fullyQualifiedDomainName, postgresPassword])
|
|
229
|
-
.apply(([host, pw]) => `postgresql://caelo_admin:${pw}@${host}:5432/cms_public?${AZURE_TLS}`);
|
|
241
|
+
const publicAdminDatabaseUrl = dbUrl("caelo_admin", "cms_public");
|
|
230
242
|
// The gateway's only login (#613, #635): public_role on cms_public. It has
|
|
231
243
|
// no cms_admin login at all (CLAUDE.md §2).
|
|
232
|
-
const publicDatabaseUrl =
|
|
233
|
-
.all([pgServer.fullyQualifiedDomainName, publicRolePassword])
|
|
234
|
-
.apply(([host, pw]) => `postgresql://public_role:${pw}@${host}:5432/cms_public?${AZURE_TLS}`);
|
|
244
|
+
const publicDatabaseUrl = dbUrl("public_role", "cms_public");
|
|
235
245
|
// #1329 — the admin's pool on the staging database (plugin schemas, the
|
|
236
246
|
// staging half of the projection), and the staging gateway's only login.
|
|
237
|
-
const publicStagingAdminDatabaseUrl =
|
|
238
|
-
|
|
239
|
-
.apply(
|
|
240
|
-
([host, pw]) => `postgresql://caelo_admin:${pw}@${host}:5432/cms_public_staging?${AZURE_TLS}`,
|
|
241
|
-
);
|
|
242
|
-
const publicStagingDatabaseUrl = pulumi
|
|
243
|
-
.all([pgServer.fullyQualifiedDomainName, publicStagingRolePassword])
|
|
244
|
-
.apply(
|
|
245
|
-
([host, pw]) =>
|
|
246
|
-
`postgresql://public_staging_role:${pw}@${host}:5432/cms_public_staging?${AZURE_TLS}`,
|
|
247
|
-
);
|
|
247
|
+
const publicStagingAdminDatabaseUrl = dbUrl("caelo_admin", "cms_public_staging");
|
|
248
|
+
const publicStagingDatabaseUrl = dbUrl("public_staging_role", "cms_public_staging");
|
|
248
249
|
|
|
249
250
|
// === 4. Storage account + containers ===
|
|
250
251
|
const storage = new azure.storage.StorageAccount(`${namePrefix}-st`, {
|
|
@@ -477,8 +478,57 @@ const cappEnv = new azure.app.ManagedEnvironment(`${namePrefix}-capp-env`, {
|
|
|
477
478
|
},
|
|
478
479
|
});
|
|
479
480
|
|
|
481
|
+
// #1339 — one user-assigned identity per secret reader, with "Key Vault
|
|
482
|
+
// Secrets User" on exactly the secrets AZURE_SERVICE_DATABASE_SECRETS gives
|
|
483
|
+
// it (RBAC on the secret, not the vault): the gateway's identity can read
|
|
484
|
+
// public_role's password and nothing else.
|
|
485
|
+
const KEY_VAULT_SECRETS_USER_ROLE = "4633458b-17de-408a-b874-0445c86b69e6";
|
|
486
|
+
const clientConfig = azure.authorization.getClientConfigOutput();
|
|
487
|
+
const keyVaultSecrets: Record<AzureDatabaseSecret, azure.keyvault.Secret> = {
|
|
488
|
+
"pg-password": pgSecret,
|
|
489
|
+
"public-role-password": publicRoleSecret,
|
|
490
|
+
};
|
|
491
|
+
|
|
492
|
+
interface SecretReader {
|
|
493
|
+
readonly identity: azure.managedidentity.UserAssignedIdentity;
|
|
494
|
+
readonly reader: AzureSecretReader;
|
|
495
|
+
/**
|
|
496
|
+
* Its grants on the secrets. A Container App resolves its Key Vault
|
|
497
|
+
* references when it is created, so it must wait for them (Azure: grant
|
|
498
|
+
* the identity access before referencing the secret).
|
|
499
|
+
*/
|
|
500
|
+
readonly grants: readonly azure.authorization.RoleAssignment[];
|
|
501
|
+
}
|
|
502
|
+
|
|
503
|
+
function secretReader(reader: AzureSecretReader): SecretReader {
|
|
504
|
+
const identity = new azure.managedidentity.UserAssignedIdentity(`${namePrefix}-${reader}-id`, {
|
|
505
|
+
resourceGroupName: rg.name,
|
|
506
|
+
resourceName: `${namePrefix}-${reader}-id`,
|
|
507
|
+
location,
|
|
508
|
+
});
|
|
509
|
+
const grants: azure.authorization.RoleAssignment[] = [];
|
|
510
|
+
for (const name of new Set(Object.values(AZURE_SERVICE_DATABASE_SECRETS[reader]))) {
|
|
511
|
+
const grant = new azure.authorization.RoleAssignment(`${namePrefix}-${reader}-reads-${name}`, {
|
|
512
|
+
principalId: identity.principalId,
|
|
513
|
+
principalType: "ServicePrincipal",
|
|
514
|
+
roleDefinitionId: pulumi.interpolate`/subscriptions/${clientConfig.subscriptionId}/providers/Microsoft.Authorization/roleDefinitions/${KEY_VAULT_SECRETS_USER_ROLE}`,
|
|
515
|
+
scope: keyVaultSecrets[name].id,
|
|
516
|
+
});
|
|
517
|
+
grants.push(grant);
|
|
518
|
+
}
|
|
519
|
+
return { identity, reader, grants };
|
|
520
|
+
}
|
|
521
|
+
|
|
522
|
+
const adminSecretReader = secretReader("admin");
|
|
523
|
+
const gatewaySecretReader = secretReader("gateway");
|
|
524
|
+
|
|
480
525
|
interface ContainerAppArgs {
|
|
481
526
|
readonly serviceName: string;
|
|
527
|
+
/**
|
|
528
|
+
* #1339 — the identity whose Key Vault references become the app's
|
|
529
|
+
* `<NAME>_PASSWORD` env vars; none for an app that reads no secret.
|
|
530
|
+
*/
|
|
531
|
+
readonly secrets?: SecretReader;
|
|
482
532
|
/**
|
|
483
533
|
* The service's database connection env. The admin-side services get
|
|
484
534
|
* admin_role's URLs; the gateway gets only its own two logins (#613,
|
|
@@ -494,51 +544,80 @@ interface ContainerAppArgs {
|
|
|
494
544
|
* minimum replicas in every environment (E14 a of #763).
|
|
495
545
|
*/
|
|
496
546
|
readonly isolated?: true;
|
|
547
|
+
/** Minimum replicas; unset: 0 outside production, 1 in production. */
|
|
548
|
+
readonly minReplicas?: number;
|
|
497
549
|
}
|
|
498
550
|
|
|
499
551
|
function containerApp(args: ContainerAppArgs): azure.app.ContainerApp {
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
552
|
+
const passwords = args.secrets
|
|
553
|
+
? Object.entries(AZURE_SERVICE_DATABASE_SECRETS[args.secrets.reader])
|
|
554
|
+
: [];
|
|
555
|
+
const secretNames = [...new Set(passwords.map(([, name]) => name))];
|
|
556
|
+
return new azure.app.ContainerApp(
|
|
557
|
+
`${namePrefix}-${args.serviceName}`,
|
|
558
|
+
{
|
|
559
|
+
resourceGroupName: rg.name,
|
|
560
|
+
containerAppName: `${namePrefix}-${args.serviceName}`,
|
|
561
|
+
location,
|
|
562
|
+
managedEnvironmentId: cappEnv.id,
|
|
563
|
+
...(args.secrets
|
|
564
|
+
? {
|
|
565
|
+
identity: {
|
|
566
|
+
type: "UserAssigned",
|
|
567
|
+
userAssignedIdentities: [args.secrets.identity.id],
|
|
568
|
+
},
|
|
569
|
+
}
|
|
570
|
+
: {}),
|
|
571
|
+
configuration: {
|
|
572
|
+
activeRevisionsMode: "Single",
|
|
573
|
+
...(args.secrets
|
|
574
|
+
? {
|
|
575
|
+
secrets: secretNames.map((name) => ({
|
|
576
|
+
name,
|
|
577
|
+
keyVaultUrl: keyVaultSecrets[name].properties.apply((p) => p.secretUri ?? ""),
|
|
578
|
+
identity: (args.secrets as SecretReader).identity.id,
|
|
579
|
+
})),
|
|
580
|
+
}
|
|
581
|
+
: {}),
|
|
582
|
+
ingress: {
|
|
583
|
+
external: false,
|
|
584
|
+
targetPort: 8080,
|
|
585
|
+
transport: "Auto",
|
|
586
|
+
},
|
|
517
587
|
},
|
|
518
|
-
|
|
519
|
-
{
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
image:
|
|
523
|
-
cfg.get(`image-${args.serviceName}`) ??
|
|
524
|
-
`${namePrefix}.azurecr.io/${args.serviceName}:latest`,
|
|
525
|
-
env: args.isolated
|
|
526
|
-
? [{ name: "CAELO_PROVIDER", value: "azure" }, ...(args.extraEnv ?? [])]
|
|
527
|
-
: [
|
|
528
|
-
{ name: "CAELO_PROVIDER", value: "azure" },
|
|
529
|
-
{ name: "CAELO_ENV", value: env },
|
|
530
|
-
...args.databaseEnv,
|
|
531
|
-
{
|
|
532
|
-
name: "MEDIA_STORAGE_URL",
|
|
533
|
-
value: pulumi.interpolate`https://${storage.name}.blob.core.windows.net/media`,
|
|
534
|
-
},
|
|
535
|
-
...(args.extraEnv ?? []),
|
|
536
|
-
],
|
|
537
|
-
resources: args.resources ?? { cpu: 0.5, memory: "1.0Gi" },
|
|
588
|
+
template: {
|
|
589
|
+
scale: {
|
|
590
|
+
minReplicas: args.isolated ? 0 : (args.minReplicas ?? (env !== "production" ? 0 : 1)),
|
|
591
|
+
maxReplicas: MAX_REPLICAS,
|
|
538
592
|
},
|
|
539
|
-
|
|
593
|
+
containers: [
|
|
594
|
+
{
|
|
595
|
+
name: args.serviceName,
|
|
596
|
+
// Image pushed via `az acr build` for v1 (operator's job).
|
|
597
|
+
image:
|
|
598
|
+
cfg.get(`image-${args.serviceName}`) ??
|
|
599
|
+
`${namePrefix}.azurecr.io/${args.serviceName}:latest`,
|
|
600
|
+
env: args.isolated
|
|
601
|
+
? [{ name: "CAELO_PROVIDER", value: "azure" }, ...(args.extraEnv ?? [])]
|
|
602
|
+
: [
|
|
603
|
+
{ name: "CAELO_PROVIDER", value: "azure" },
|
|
604
|
+
{ name: "CAELO_ENV", value: env },
|
|
605
|
+
...args.databaseEnv,
|
|
606
|
+
...passwords.map(([envName, name]) => ({ name: envName, secretRef: name })),
|
|
607
|
+
{
|
|
608
|
+
name: "MEDIA_STORAGE_URL",
|
|
609
|
+
value: pulumi.interpolate`https://${storage.name}.blob.core.windows.net/media`,
|
|
610
|
+
},
|
|
611
|
+
...(args.extraEnv ?? []),
|
|
612
|
+
],
|
|
613
|
+
resources: args.resources ?? { cpu: 0.5, memory: "1.0Gi" },
|
|
614
|
+
},
|
|
615
|
+
],
|
|
616
|
+
},
|
|
540
617
|
},
|
|
541
|
-
|
|
618
|
+
// Its Key Vault references resolve at creation: the grants come first.
|
|
619
|
+
{ dependsOn: [...(args.secrets?.grants ?? [])] },
|
|
620
|
+
);
|
|
542
621
|
}
|
|
543
622
|
|
|
544
623
|
const adminDatabaseEnv = [
|
|
@@ -550,6 +629,7 @@ const adminDatabaseEnv = [
|
|
|
550
629
|
const adminApp = containerApp({
|
|
551
630
|
serviceName: "admin",
|
|
552
631
|
databaseEnv: adminDatabaseEnv,
|
|
632
|
+
secrets: adminSecretReader,
|
|
553
633
|
resources: adminResources,
|
|
554
634
|
// #551 — the public site URL; the admin seeds site_defaults.site_base_url
|
|
555
635
|
// from it (canonical, og:url, sitemap) when it is not configured yet.
|
|
@@ -557,6 +637,8 @@ const adminApp = containerApp({
|
|
|
557
637
|
});
|
|
558
638
|
const _gatewayApp = containerApp({
|
|
559
639
|
serviceName: "gateway",
|
|
640
|
+
secrets: gatewaySecretReader,
|
|
641
|
+
minReplicas: gatewayMinInstances,
|
|
560
642
|
databaseEnv: [
|
|
561
643
|
{ name: "PUBLIC_DATABASE_URL", value: publicDatabaseUrl },
|
|
562
644
|
...poolBudget.env.gateway,
|
|
@@ -592,8 +674,13 @@ const _mcpAuthProxyApp = containerApp({
|
|
|
592
674
|
const _orchestratorApp = containerApp({
|
|
593
675
|
serviceName: "orchestrator",
|
|
594
676
|
databaseEnv: adminDatabaseEnv,
|
|
677
|
+
secrets: adminSecretReader,
|
|
678
|
+
});
|
|
679
|
+
const _runnerApp = containerApp({
|
|
680
|
+
serviceName: "runner",
|
|
681
|
+
databaseEnv: adminDatabaseEnv,
|
|
682
|
+
secrets: adminSecretReader,
|
|
595
683
|
});
|
|
596
|
-
const _runnerApp = containerApp({ serviceName: "runner", databaseEnv: adminDatabaseEnv });
|
|
597
684
|
// === 7. Bootstrap token ===
|
|
598
685
|
const tokenInfo = generateBootstrapToken();
|
|
599
686
|
|
|
@@ -609,6 +696,7 @@ const dnsRecordsRequired = pulumi
|
|
|
609
696
|
);
|
|
610
697
|
|
|
611
698
|
const out: CloudAdapterOutputs = {
|
|
699
|
+
// Password-less — the passwords live only in Key Vault (#1339).
|
|
612
700
|
adminDatabaseUrl: adminDatabaseUrl as unknown as string,
|
|
613
701
|
publicDatabaseUrl: publicDatabaseUrl as unknown as string,
|
|
614
702
|
publicStagingDatabaseUrl: publicStagingDatabaseUrl as unknown as string,
|
package/stacks/gcp/index.ts
CHANGED
|
@@ -5,7 +5,10 @@
|
|
|
5
5
|
*
|
|
6
6
|
* Tier 1 — Static site: GCS + Cloud CDN + Managed SSL via single LB
|
|
7
7
|
* Tier 2 — Admin app: Cloud Run + Identity-Aware Proxy (allowlist)
|
|
8
|
-
* Tier 3 — API gateway: Cloud Run + Cloud Armor (path-prefix on the LB)
|
|
8
|
+
* Tier 3 — API gateway: Cloud Run + Cloud Armor (path-prefix on the LB);
|
|
9
|
+
* the staging gateway (#1330) shares the policy.
|
|
10
|
+
* Cloud Armor is an extra layer: the gateways
|
|
11
|
+
* protect themselves without it (E3 of #763)
|
|
9
12
|
* Tier 4 — Database: Cloud SQL Postgres on private VPC IP only
|
|
10
13
|
* Tier 5 — Workers: share the admin's Cloud Run process
|
|
11
14
|
*
|
|
@@ -14,7 +17,8 @@
|
|
|
14
17
|
* mapping (admin.<domain>) so IAP can gate it independently — IAP can't
|
|
15
18
|
* be attached selectively to one path of a multi-backend LB.
|
|
16
19
|
*
|
|
17
|
-
* Defaults: minimal-cost
|
|
20
|
+
* Defaults: minimal-cost; src/wizards/gcp-cost.ts prices every resource
|
|
21
|
+
* (the wizard shows it before `up`). Operators bump knobs to scale up.
|
|
18
22
|
*/
|
|
19
23
|
|
|
20
24
|
import * as gcp from "@pulumi/gcp";
|
|
@@ -22,6 +26,7 @@ import * as pulumi from "@pulumi/pulumi";
|
|
|
22
26
|
import * as random from "@pulumi/random";
|
|
23
27
|
import type { CloudAdapterOutputs, DnsRecord } from "../../dist/adapter.js";
|
|
24
28
|
import { generateBootstrapToken } from "../../dist/bootstrap-token.js";
|
|
29
|
+
import { gatewayArmorRuleArgs } from "../../dist/gateway-edge.js";
|
|
25
30
|
import {
|
|
26
31
|
gatewayServiceAccountId,
|
|
27
32
|
gcpBucketName,
|
|
@@ -969,6 +974,25 @@ const gatewaySvc = deployGateways
|
|
|
969
974
|
})
|
|
970
975
|
: null;
|
|
971
976
|
|
|
977
|
+
// Cloud Run checks a caller's identity whatever the ingress, and a visitor
|
|
978
|
+
// has none: without this binding every /api/ call answers Cloud Run's 403.
|
|
979
|
+
// Public only through the load balancer: the service's ingress closes its
|
|
980
|
+
// run.app URL. The MCP-Auth-Proxy and the staging gateway are CLI-owned and
|
|
981
|
+
// deployed with --allow-unauthenticated.
|
|
982
|
+
if (gatewaySvc) {
|
|
983
|
+
new gcp.cloudrunv2.ServiceIamMember(
|
|
984
|
+
`${namePrefix}-data-gateway-public-invoker`,
|
|
985
|
+
{
|
|
986
|
+
project,
|
|
987
|
+
location: region,
|
|
988
|
+
name: gatewaySvc.name,
|
|
989
|
+
role: "roles/run.invoker",
|
|
990
|
+
member: "allUsers",
|
|
991
|
+
},
|
|
992
|
+
opts,
|
|
993
|
+
);
|
|
994
|
+
}
|
|
995
|
+
|
|
972
996
|
// =========================================================================
|
|
973
997
|
// Tier 1 + Tier 2 + Tier 3 LB — single HTTPS LB serves three backends
|
|
974
998
|
// =========================================================================
|
|
@@ -996,54 +1020,18 @@ const lbIp = new gcp.compute.GlobalAddress(
|
|
|
996
1020
|
opts,
|
|
997
1021
|
);
|
|
998
1022
|
|
|
999
|
-
// Tier 3 — Cloud Armor security policy
|
|
1023
|
+
// Tier 3 — Cloud Armor security policy: per-path rate rules + OWASP packs
|
|
1024
|
+
// (#1339, src/gateway-edge.ts says why each rule is what it is; the converge
|
|
1025
|
+
// applies the same rules to existing installs, gateway-armor.ts). An extra
|
|
1026
|
+
// layer: every protection also lives in the gateway itself (E3 of #763).
|
|
1027
|
+
// #1328 — no remote-MCP rule here any more: the URL map sends /api/mcp/* to
|
|
1028
|
+
// the MCP-Auth-Proxy's backend, whose own policy carries it
|
|
1029
|
+
// (remote-mcp-edge.ts, created by the CLI).
|
|
1000
1030
|
const wafPolicy = new gcp.compute.SecurityPolicy(
|
|
1001
1031
|
`${namePrefix}-waf`,
|
|
1002
1032
|
{
|
|
1003
|
-
description: `Caelo ${env} Cloud Armor — rate
|
|
1004
|
-
rules:
|
|
1005
|
-
// #1328 — no remote-MCP rule here any more: the URL map sends
|
|
1006
|
-
// /api/mcp/* to the MCP-Auth-Proxy's backend, whose own policy carries
|
|
1007
|
-
// it (remote-mcp-edge.ts, created by the CLI; `upgrade` drops the old
|
|
1008
|
-
// rule from this policy).
|
|
1009
|
-
// Rate limit per source IP — 100 req / min sliding window.
|
|
1010
|
-
{
|
|
1011
|
-
action: "rate_based_ban",
|
|
1012
|
-
priority: 1000,
|
|
1013
|
-
match: {
|
|
1014
|
-
versionedExpr: "SRC_IPS_V1",
|
|
1015
|
-
config: { srcIpRanges: ["*"] },
|
|
1016
|
-
},
|
|
1017
|
-
rateLimitOptions: {
|
|
1018
|
-
rateLimitThreshold: { count: 100, intervalSec: 60 },
|
|
1019
|
-
conformAction: "allow",
|
|
1020
|
-
exceedAction: "deny(429)",
|
|
1021
|
-
enforceOnKey: "IP",
|
|
1022
|
-
banDurationSec: 600,
|
|
1023
|
-
},
|
|
1024
|
-
},
|
|
1025
|
-
// OWASP rule pack (preconfigured WAF) — free tier covers the basics.
|
|
1026
|
-
{
|
|
1027
|
-
action: "deny(403)",
|
|
1028
|
-
priority: 2000,
|
|
1029
|
-
match: {
|
|
1030
|
-
expr: { expression: "evaluatePreconfiguredWaf('sqli-v33-stable')" },
|
|
1031
|
-
},
|
|
1032
|
-
},
|
|
1033
|
-
{
|
|
1034
|
-
action: "deny(403)",
|
|
1035
|
-
priority: 2001,
|
|
1036
|
-
match: {
|
|
1037
|
-
expr: { expression: "evaluatePreconfiguredWaf('xss-v33-stable')" },
|
|
1038
|
-
},
|
|
1039
|
-
},
|
|
1040
|
-
// Default allow.
|
|
1041
|
-
{
|
|
1042
|
-
action: "allow",
|
|
1043
|
-
priority: 2147483647,
|
|
1044
|
-
match: { versionedExpr: "SRC_IPS_V1", config: { srcIpRanges: ["*"] } },
|
|
1045
|
-
},
|
|
1046
|
-
],
|
|
1033
|
+
description: `Caelo ${env} Cloud Armor — per-path rate rules + OWASP`,
|
|
1034
|
+
rules: gatewayArmorRuleArgs(),
|
|
1047
1035
|
...(wafAdaptiveProtection
|
|
1048
1036
|
? { adaptiveProtectionConfig: { layer7DdosDefenseConfig: { enable: true } } }
|
|
1049
1037
|
: {}),
|
|
@@ -9,16 +9,27 @@
|
|
|
9
9
|
* + IAP-on-Cloud-Run (no LB IAP)
|
|
10
10
|
* - Gateway: Cloud Run `caelo-<env>-data-gateway` + Firebase
|
|
11
11
|
* Hosting `rewrites` (no LB, no Cloud Armor)
|
|
12
|
+
* - Staging gateway: Cloud Run `caelo-<env>-staging-gateway` behind a
|
|
13
|
+
* second Hosting site's `**` rewrite (#1330)
|
|
12
14
|
* - MCP-Auth-Proxy: Cloud Run on its own run.app URL (#1328; the
|
|
13
15
|
* service that was the gateway, E13 a of #763)
|
|
14
16
|
* - Database: Cloud SQL Postgres on private VPC IP only (same
|
|
15
17
|
* as `gcp/`)
|
|
16
18
|
* - Workers: share admin Cloud Run (same as `gcp/`)
|
|
17
19
|
*
|
|
18
|
-
*
|
|
19
|
-
*
|
|
20
|
-
*
|
|
21
|
-
*
|
|
20
|
+
* No load balancer and no WAF (epic #763 decision E3): this is the cheap
|
|
21
|
+
* setup. Leaving out the LB, Cloud CDN and the two Cloud Armor policies
|
|
22
|
+
* saves their lines of the cost table (src/wizards/gcp-cost.ts, the
|
|
23
|
+
* source of every price; about $37 a month at list prices). No protection
|
|
24
|
+
* depends on a WAF: the three public services are publicly invokable on
|
|
25
|
+
* their run.app URLs too (`allUsers`, needed by the Firebase rewrites and
|
|
26
|
+
* by MCP clients), so each one sheds junk and rate-limits itself before
|
|
27
|
+
* the database (in-memory budgets per client and per operation, captcha,
|
|
28
|
+
* per-operation database limits, `public_role`'s connection limit and
|
|
29
|
+
* timeouts; docs/dev/gateway-hardening.md), and the instance caps bound
|
|
30
|
+
* the rest. A public service whose feature is off answers a fixed 404
|
|
31
|
+
* before it reads the request (E14 a). Where a provider has a WAF (gcp:
|
|
32
|
+
* Cloud Armor), it is an extra layer.
|
|
22
33
|
*
|
|
23
34
|
* Code structure mirrors `packages/provisioning/stacks/gcp/index.ts`
|
|
24
35
|
* for the shared blocks (VPC, Secrets, Cloud SQL, run SA, Cloud Run
|
|
@@ -702,9 +713,9 @@ interface CloudRunArgs {
|
|
|
702
713
|
* in-memory filesystem and is lost with the instance.
|
|
703
714
|
*/
|
|
704
715
|
readonly mediaVolume?: ReturnType<typeof adminMediaVolumeTemplate>;
|
|
705
|
-
/** v0.3.1 — admin: ALL (so IAP gates internet traffic).
|
|
706
|
-
*
|
|
707
|
-
* rewrites
|
|
716
|
+
/** v0.3.1 — admin: ALL (so IAP gates internet traffic). Every
|
|
717
|
+
* service is ALL today: the public ones are reached through Firebase
|
|
718
|
+
* Hosting rewrites and their run.app URLs (E3 of #763). */
|
|
708
719
|
readonly ingress: "INGRESS_TRAFFIC_ALL" | "INGRESS_TRAFFIC_INTERNAL_LOAD_BALANCER";
|
|
709
720
|
/** v0.3.1 — set true on admin so Cloud Run IAP gates traffic. */
|
|
710
721
|
readonly iapEnabled?: boolean;
|
|
@@ -926,9 +937,9 @@ const adminSvc = cloudRunService({
|
|
|
926
937
|
//
|
|
927
938
|
// v0.3.13 — Gateway is PUBLIC by design.
|
|
928
939
|
//
|
|
929
|
-
// Per the gcp-firebase architecture decision: no
|
|
930
|
-
// the gateway;
|
|
931
|
-
//
|
|
940
|
+
// Per the gcp-firebase architecture decision (E3 of #763): no LB and no
|
|
941
|
+
// Cloud Armor on the gateway; its own layers gate abuse (the file
|
|
942
|
+
// comment). The original plan was to grant the
|
|
932
943
|
// Firebase Hosting SA `roles/run.invoker` so Firebase rewrites
|
|
933
944
|
// could call the gateway as that SA. But the gcp-sa-firebasehosting
|
|
934
945
|
// SA is created lazily by Firebase on first Cloud-Run-rewrite
|
|
@@ -1319,9 +1330,10 @@ const out: CloudAdapterOutputs = {
|
|
|
1319
1330
|
bootstrapUrl:
|
|
1320
1331
|
pulumi.interpolate`https://${adminDomain}/setup?token=${tokenInfo.token}` as unknown as string,
|
|
1321
1332
|
dnsRecordsRequired: dnsRecords as unknown as DnsRecord[],
|
|
1322
|
-
//
|
|
1323
|
-
//
|
|
1324
|
-
|
|
1333
|
+
// #1339 — no BigQuery export here (that dataset was never created):
|
|
1334
|
+
// the services' request logs stay in Cloud Logging, the cross-cutting
|
|
1335
|
+
// single sink of CLAUDE.md §11.B, in the project's `_Default` bucket.
|
|
1336
|
+
edgeLogSinkUrl: `logging://${project}/_Default` as unknown as string,
|
|
1325
1337
|
provider: "gcp-firebase",
|
|
1326
1338
|
environment: env,
|
|
1327
1339
|
};
|