@caelo-cms/provisioning 0.11.13 → 0.11.15
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/__tests__/stack-under-mocks.d.ts +2 -0
- package/dist/__tests__/stack-under-mocks.d.ts.map +1 -0
- package/dist/__tests__/stack-under-mocks.js +59 -0
- package/dist/__tests__/stack-under-mocks.js.map +1 -0
- package/dist/admin-domain.d.ts +4 -46
- package/dist/admin-domain.d.ts.map +1 -1
- package/dist/admin-domain.js +4 -101
- package/dist/admin-domain.js.map +1 -1
- package/dist/agent-db.js +29 -5
- package/dist/audit-job-setup.d.ts.map +1 -1
- package/dist/audit-job-setup.js +14 -19
- package/dist/audit-job-setup.js.map +1 -1
- package/dist/caddy.d.ts +2 -1
- package/dist/caddy.d.ts.map +1 -1
- package/dist/caddy.js +21 -3
- package/dist/caddy.js.map +1 -1
- package/dist/cli.js +111 -62
- package/dist/cli.js.map +1 -1
- package/dist/compose.d.ts +22 -2
- package/dist/compose.d.ts.map +1 -1
- package/dist/compose.js +53 -3
- package/dist/compose.js.map +1 -1
- package/dist/converge-checkpoint.d.ts +1 -0
- package/dist/converge-checkpoint.d.ts.map +1 -1
- package/dist/converge-checkpoint.js +1 -0
- package/dist/converge-checkpoint.js.map +1 -1
- package/dist/deployed-release.d.ts.map +1 -1
- package/dist/deployed-release.js +42 -8
- package/dist/deployed-release.js.map +1 -1
- package/dist/gateway-bootstrap.d.ts +68 -0
- package/dist/gateway-bootstrap.d.ts.map +1 -0
- package/dist/gateway-bootstrap.js +145 -0
- package/dist/gateway-bootstrap.js.map +1 -0
- package/dist/gcp-names.d.ts +33 -14
- package/dist/gcp-names.d.ts.map +1 -1
- package/dist/gcp-names.js +43 -0
- package/dist/gcp-names.js.map +1 -1
- package/dist/gcp-url-map.d.ts +19 -4
- package/dist/gcp-url-map.d.ts.map +1 -1
- package/dist/gcp-url-map.js +33 -5
- package/dist/gcp-url-map.js.map +1 -1
- package/dist/infra-contract.d.ts +1 -1
- package/dist/infra-contract.d.ts.map +1 -1
- package/dist/infra-contract.js +18 -1
- package/dist/infra-contract.js.map +1 -1
- package/dist/lifecycle.d.ts.map +1 -1
- package/dist/lifecycle.js +5 -39
- package/dist/lifecycle.js.map +1 -1
- package/dist/mcp-auth-proxy-setup.d.ts +8 -2
- package/dist/mcp-auth-proxy-setup.d.ts.map +1 -1
- package/dist/mcp-auth-proxy-setup.js +4 -0
- package/dist/mcp-auth-proxy-setup.js.map +1 -1
- package/dist/release-manifest.d.ts +1 -1
- package/dist/release-manifest.d.ts.map +1 -1
- package/dist/release-manifest.js +2 -0
- package/dist/release-manifest.js.map +1 -1
- package/dist/remote-mcp.d.ts.map +1 -1
- package/dist/remote-mcp.js +11 -1
- package/dist/remote-mcp.js.map +1 -1
- package/dist/runtime-secrets.d.ts +10 -0
- package/dist/runtime-secrets.d.ts.map +1 -1
- package/dist/runtime-secrets.js +10 -1
- package/dist/runtime-secrets.js.map +1 -1
- package/dist/stack-contract.d.ts +61 -20
- package/dist/stack-contract.d.ts.map +1 -1
- package/dist/stack-contract.js +173 -35
- package/dist/stack-contract.js.map +1 -1
- package/dist/stack-converge.d.ts.map +1 -1
- package/dist/stack-converge.js +4 -2
- package/dist/stack-converge.js.map +1 -1
- package/dist/stack-gateways.d.ts +31 -0
- package/dist/stack-gateways.d.ts.map +1 -0
- package/dist/stack-gateways.js +40 -0
- package/dist/stack-gateways.js.map +1 -0
- package/dist/staging-admin.d.ts +2 -2
- package/dist/staging-admin.d.ts.map +1 -1
- package/dist/staging-gateway-setup.d.ts +140 -0
- package/dist/staging-gateway-setup.d.ts.map +1 -0
- package/dist/staging-gateway-setup.js +848 -0
- package/dist/staging-gateway-setup.js.map +1 -0
- package/dist/state-command.d.ts.map +1 -1
- package/dist/state-command.js +3 -0
- package/dist/state-command.js.map +1 -1
- package/dist/upgrade/app-roll.d.ts +4 -4
- package/dist/upgrade/app-roll.d.ts.map +1 -1
- package/dist/upgrade/app-roll.js +7 -5
- package/dist/upgrade/app-roll.js.map +1 -1
- package/dist/upgrade/converge.d.ts.map +1 -1
- package/dist/upgrade/converge.js +36 -27
- package/dist/upgrade/converge.js.map +1 -1
- package/dist/upgrade/image-forms.d.ts +3 -3
- package/dist/upgrade/image-forms.d.ts.map +1 -1
- package/dist/upgrade/image-forms.js +2 -2
- package/dist/upgrade/image-forms.js.map +1 -1
- package/dist/upgrade/release-images.d.ts +20 -0
- package/dist/upgrade/release-images.d.ts.map +1 -1
- package/dist/upgrade/release-images.js +28 -0
- package/dist/upgrade/release-images.js.map +1 -1
- package/dist/upgrade/upgrade.d.ts +3 -1
- package/dist/upgrade/upgrade.d.ts.map +1 -1
- package/dist/upgrade/upgrade.js +22 -1
- package/dist/upgrade/upgrade.js.map +1 -1
- package/dist/upgrader-job.d.ts.map +1 -1
- package/dist/upgrader-job.js +30 -5
- package/dist/upgrader-job.js.map +1 -1
- package/dist/upgrader-records.d.ts +2 -2
- package/dist/upgrader-records.d.ts.map +1 -1
- package/dist/upgrader-records.js +2 -2
- package/dist/upgrader-records.js.map +1 -1
- package/dist/wizard.d.ts.map +1 -1
- package/dist/wizard.js +3 -3
- package/dist/wizard.js.map +1 -1
- package/dist/wizards/gcp-pulumi.d.ts +7 -1
- package/dist/wizards/gcp-pulumi.d.ts.map +1 -1
- package/dist/wizards/gcp-pulumi.js +2 -0
- package/dist/wizards/gcp-pulumi.js.map +1 -1
- package/dist/wizards/gcp.d.ts.map +1 -1
- package/dist/wizards/gcp.js +168 -22
- package/dist/wizards/gcp.js.map +1 -1
- package/package.json +2 -2
- package/src/__tests__/stack-under-mocks.ts +69 -0
- package/src/admin-domain.test.ts +0 -156
- package/src/admin-domain.ts +4 -117
- package/src/admin-memory.test.ts +2 -0
- package/src/audit-job-setup.test.ts +11 -11
- package/src/audit-job-setup.ts +14 -19
- package/src/caddy-redirects.docker.test.ts +10 -5
- package/src/caddy-redirects.test.ts +7 -5
- package/src/caddy-validate.test.ts +1 -1
- package/src/caddy.test.ts +12 -6
- package/src/caddy.ts +23 -4
- package/src/cli.ts +138 -77
- package/src/compose.ts +67 -2
- package/src/converge-checkpoint.ts +1 -0
- package/src/database-tls-builders.test.ts +3 -1
- package/src/deployed-release.test.ts +37 -0
- package/src/deployed-release.ts +44 -7
- package/src/gateway-bootstrap.test.ts +381 -0
- package/src/gateway-bootstrap.ts +195 -0
- package/src/gateway-env-isolation.test.ts +2 -0
- package/src/gcp-names.ts +53 -0
- package/src/gcp-url-map.test.ts +27 -3
- package/src/gcp-url-map.ts +36 -5
- package/src/index.test.ts +9 -3
- package/src/infra-contract.test.ts +4 -3
- package/src/infra-contract.ts +18 -1
- package/src/lifecycle.ts +8 -52
- package/src/mcp-auth-proxy-setup.test.ts +15 -6
- package/src/mcp-auth-proxy-setup.ts +14 -2
- package/src/release-manifest.ts +3 -1
- package/src/remote-mcp-stack-config.test.ts +3 -1
- package/src/remote-mcp.test.ts +5 -1
- package/src/remote-mcp.ts +10 -1
- package/src/runtime-secrets.test.ts +10 -1
- package/src/runtime-secrets.ts +21 -0
- package/src/self-hosted-backup.test.ts +6 -4
- package/src/self-hosted-compose.test.ts +2 -0
- package/src/stack-cloud-run-names.test.ts +49 -0
- package/src/stack-contract-parity.test.ts +7 -3
- package/src/stack-contract.test.ts +73 -13
- package/src/stack-contract.ts +195 -42
- package/src/stack-converge-secrets.test.ts +7 -2
- package/src/stack-converge.test.ts +37 -9
- package/src/stack-converge.ts +4 -1
- package/src/stack-gateways.ts +39 -0
- package/src/staging-admin.ts +2 -2
- package/src/staging-gateway-setup.test.ts +361 -0
- package/src/staging-gateway-setup.ts +1083 -0
- package/src/state-command.ts +3 -0
- package/src/upgrade/app-roll.ts +7 -4
- package/src/upgrade/converge.ts +40 -26
- package/src/upgrade/image-forms.ts +7 -7
- package/src/upgrade/release-images.test.ts +28 -0
- package/src/upgrade/release-images.ts +44 -0
- package/src/upgrade/upgrade.test.ts +63 -11
- package/src/upgrade/upgrade.ts +29 -2
- package/src/upgrader-job.test.ts +23 -0
- package/src/upgrader-job.ts +45 -11
- package/src/upgrader-records.ts +7 -7
- package/src/wizard.ts +2 -3
- package/src/wizards/gcp-pulumi.ts +9 -0
- package/src/wizards/gcp.ts +219 -23
- package/stacks/gcp/Pulumi.yaml +4 -0
- package/stacks/gcp/index.ts +128 -66
- package/stacks/gcp-firebase/index.ts +101 -50
- package/stacks/self-hosted/index.ts +9 -2
package/stacks/gcp/index.ts
CHANGED
|
@@ -29,6 +29,7 @@ import {
|
|
|
29
29
|
MCP_IAP_SERVICE_ACCOUNT_ID,
|
|
30
30
|
mcpAuthProxyServiceAccountId,
|
|
31
31
|
runServiceAccountId,
|
|
32
|
+
stagingGatewayServiceAccountId,
|
|
32
33
|
staticPublisherServiceAccountId,
|
|
33
34
|
} from "../../dist/gcp-names.js";
|
|
34
35
|
import { createSiteUrlMap } from "../../dist/gcp-url-map.js";
|
|
@@ -63,6 +64,7 @@ import {
|
|
|
63
64
|
STATIC_CDN_POLICY,
|
|
64
65
|
secretFileVolumesTemplate,
|
|
65
66
|
} from "../../dist/stack-contract.js";
|
|
67
|
+
import { DEPLOY_GATEWAYS_CONFIG, parseDeployGateways } from "../../dist/stack-gateways.js";
|
|
66
68
|
import { GCP_STATIC_RESPONSE_HEADERS } from "../../dist/static-security-headers.js";
|
|
67
69
|
|
|
68
70
|
const cfg = new pulumi.Config();
|
|
@@ -513,9 +515,10 @@ new gcp.storage.BucketIAMMember(
|
|
|
513
515
|
|
|
514
516
|
// v0.2.78 — private staging bucket. Stage uploads here; Confirm-publish
|
|
515
517
|
// server-side copies to the public static bucket. Never has allUsers
|
|
516
|
-
// binding
|
|
517
|
-
//
|
|
518
|
-
//
|
|
518
|
+
// binding: since #1330 the staged build is reachable ONLY through the
|
|
519
|
+
// staging gateway (the staging host, behind the staging gate), whose
|
|
520
|
+
// account may read this bucket and nothing else. The public CDN never
|
|
521
|
+
// serves from it.
|
|
519
522
|
const stagingBucket = new gcp.storage.Bucket(
|
|
520
523
|
`${namePrefix}-staging`,
|
|
521
524
|
{
|
|
@@ -570,9 +573,24 @@ const mcpAuthProxySa = new gcp.serviceaccount.Account(
|
|
|
570
573
|
},
|
|
571
574
|
opts,
|
|
572
575
|
);
|
|
576
|
+
// #1330 — the staging gateway's own SA and (below) its secretAccessor on
|
|
577
|
+
// its one login password, plus the telemetry roles. Its service, its read
|
|
578
|
+
// access to the staging bucket and its edge (gcp: NEG, backend, host rule,
|
|
579
|
+
// certificate; gcp-firebase: the second Hosting site) are the CLI's
|
|
580
|
+
// (staging-gateway-setup.ts, after the first `up` and in every converge).
|
|
581
|
+
const stagingGatewaySa = new gcp.serviceaccount.Account(
|
|
582
|
+
`${namePrefix}-staging-gateway-sa`,
|
|
583
|
+
{
|
|
584
|
+
accountId: stagingGatewayServiceAccountId(env),
|
|
585
|
+
displayName: `Caelo ${env} staging gateway`,
|
|
586
|
+
createIgnoreAlreadyExists: true,
|
|
587
|
+
},
|
|
588
|
+
opts,
|
|
589
|
+
);
|
|
573
590
|
const serviceSa: Record<CloudRunSlug, gcp.serviceaccount.Account> = {
|
|
574
591
|
admin: runSa,
|
|
575
592
|
gateway: gatewaySa,
|
|
593
|
+
"staging-gateway": stagingGatewaySa,
|
|
576
594
|
"mcp-auth-proxy": mcpAuthProxySa,
|
|
577
595
|
};
|
|
578
596
|
|
|
@@ -582,6 +600,7 @@ const serviceSa: Record<CloudRunSlug, gcp.serviceaccount.Account> = {
|
|
|
582
600
|
const secretBindings: Record<CloudRunSlug, gcp.secretmanager.SecretIamMember[]> = {
|
|
583
601
|
admin: [],
|
|
584
602
|
gateway: [],
|
|
603
|
+
"staging-gateway": [],
|
|
585
604
|
"mcp-auth-proxy": [],
|
|
586
605
|
};
|
|
587
606
|
for (const binding of runtimeSecretBindings()) {
|
|
@@ -696,6 +715,24 @@ new gcp.projects.IAMMember(
|
|
|
696
715
|
},
|
|
697
716
|
opts,
|
|
698
717
|
);
|
|
718
|
+
new gcp.projects.IAMMember(
|
|
719
|
+
`${namePrefix}-staging-gateway-log-writer`,
|
|
720
|
+
{
|
|
721
|
+
project,
|
|
722
|
+
role: "roles/logging.logWriter",
|
|
723
|
+
member: pulumi.interpolate`serviceAccount:${stagingGatewaySa.email}`,
|
|
724
|
+
},
|
|
725
|
+
opts,
|
|
726
|
+
);
|
|
727
|
+
new gcp.projects.IAMMember(
|
|
728
|
+
`${namePrefix}-staging-gateway-metric-writer`,
|
|
729
|
+
{
|
|
730
|
+
project,
|
|
731
|
+
role: "roles/monitoring.metricWriter",
|
|
732
|
+
member: pulumi.interpolate`serviceAccount:${stagingGatewaySa.email}`,
|
|
733
|
+
},
|
|
734
|
+
opts,
|
|
735
|
+
);
|
|
699
736
|
|
|
700
737
|
// `static-publisher` SA used by `bunx @caelo-cms/provisioning deploy` to
|
|
701
738
|
// upload the static-generator output to the bucket. Pre-v0.2.78 this
|
|
@@ -759,8 +796,8 @@ function imageTag(service: string): pulumi.Output<string> {
|
|
|
759
796
|
}
|
|
760
797
|
|
|
761
798
|
interface CloudRunArgs {
|
|
762
|
-
/** The MCP-Auth-Proxy
|
|
763
|
-
readonly serviceName: Exclude<CloudRunSlug, "mcp-auth-proxy">;
|
|
799
|
+
/** The MCP-Auth-Proxy and the staging gateway are CLI-owned on this stack (see their SAs). */
|
|
800
|
+
readonly serviceName: Exclude<CloudRunSlug, "mcp-auth-proxy" | "staging-gateway">;
|
|
764
801
|
readonly minInstances: number;
|
|
765
802
|
readonly maxInstances: number;
|
|
766
803
|
readonly memory: string;
|
|
@@ -911,18 +948,26 @@ const adminSvc = cloudRunService({
|
|
|
911
948
|
],
|
|
912
949
|
mediaVolume: adminMediaVolumeTemplate(adminMediaVolume(project, env)),
|
|
913
950
|
});
|
|
914
|
-
|
|
915
|
-
|
|
916
|
-
|
|
917
|
-
|
|
918
|
-
|
|
919
|
-
|
|
920
|
-
|
|
921
|
-
|
|
922
|
-
|
|
923
|
-
|
|
924
|
-
|
|
925
|
-
|
|
951
|
+
// The first `up` of a fresh install withholds the gateway and everything
|
|
952
|
+
// that routes to it (stack-gateways.ts): it refuses to start until the
|
|
953
|
+
// migrations, which run after that `up`, have isolated its database login.
|
|
954
|
+
// The URL map goes with it because its `/api/*` rule must exist at creation
|
|
955
|
+
// (the stack ignores `pathRules` after that, gcp-url-map.ts).
|
|
956
|
+
const deployGateways = parseDeployGateways(cfg.get(DEPLOY_GATEWAYS_CONFIG));
|
|
957
|
+
const gatewaySvc = deployGateways
|
|
958
|
+
? cloudRunService({
|
|
959
|
+
serviceName: "gateway",
|
|
960
|
+
minInstances: gatewayMinInstances,
|
|
961
|
+
maxInstances: gatewayMaxInstances,
|
|
962
|
+
memory: "512Mi",
|
|
963
|
+
// Visitor requests only (#1328 moved remote MCP's long streams to the
|
|
964
|
+
// MCP-Auth-Proxy): Cloud Run's default.
|
|
965
|
+
timeout: "300s",
|
|
966
|
+
// public_role on cms_public only: no cms_admin login of any role
|
|
967
|
+
// (#613, #635, CLAUDE.md §2).
|
|
968
|
+
contractEnv: [...gatewayEnvContract(envContractInputs), ...poolBudget.env.gateway],
|
|
969
|
+
})
|
|
970
|
+
: null;
|
|
926
971
|
|
|
927
972
|
// =========================================================================
|
|
928
973
|
// Tier 1 + Tier 2 + Tier 3 LB — single HTTPS LB serves three backends
|
|
@@ -1023,26 +1068,28 @@ const staticBackendBucket = new gcp.compute.BackendBucket(
|
|
|
1023
1068
|
);
|
|
1024
1069
|
|
|
1025
1070
|
// Tier 3 backend — gateway Cloud Run via serverless NEG
|
|
1026
|
-
|
|
1027
|
-
|
|
1028
|
-
|
|
1029
|
-
|
|
1030
|
-
|
|
1031
|
-
|
|
1032
|
-
|
|
1033
|
-
|
|
1034
|
-
|
|
1035
|
-
|
|
1036
|
-
|
|
1037
|
-
|
|
1038
|
-
|
|
1039
|
-
|
|
1040
|
-
|
|
1041
|
-
|
|
1042
|
-
|
|
1043
|
-
|
|
1044
|
-
|
|
1045
|
-
);
|
|
1071
|
+
function gatewayBackend(service: gcp.cloudrunv2.Service): gcp.compute.BackendService {
|
|
1072
|
+
const gatewayNeg = new gcp.compute.RegionNetworkEndpointGroup(
|
|
1073
|
+
`${namePrefix}-gateway-neg`,
|
|
1074
|
+
{
|
|
1075
|
+
region,
|
|
1076
|
+
networkEndpointType: "SERVERLESS",
|
|
1077
|
+
cloudRun: { service: service.name },
|
|
1078
|
+
},
|
|
1079
|
+
opts,
|
|
1080
|
+
);
|
|
1081
|
+
return new gcp.compute.BackendService(
|
|
1082
|
+
`${namePrefix}-gateway-backend`,
|
|
1083
|
+
{
|
|
1084
|
+
protocol: "HTTPS",
|
|
1085
|
+
backends: [{ group: gatewayNeg.id }],
|
|
1086
|
+
loadBalancingScheme: "EXTERNAL_MANAGED",
|
|
1087
|
+
securityPolicy: wafPolicy.id,
|
|
1088
|
+
},
|
|
1089
|
+
opts,
|
|
1090
|
+
);
|
|
1091
|
+
}
|
|
1092
|
+
const gatewayBackendService = gatewaySvc ? gatewayBackend(gatewaySvc) : null;
|
|
1046
1093
|
|
|
1047
1094
|
// Tier 2 backend — admin Cloud Run via serverless NEG, IAP-gated.
|
|
1048
1095
|
const adminNeg = new gcp.compute.RegionNetworkEndpointGroup(
|
|
@@ -1222,17 +1269,22 @@ new gcp.iap.WebBackendServiceIamMember(
|
|
|
1222
1269
|
// #587 — the public path matcher also carries the redirects table as
|
|
1223
1270
|
// `urlRedirect` rules, written by the admin on every Confirm-publish; the
|
|
1224
1271
|
// stack ignores that field after creation (src/gcp-url-map.ts).
|
|
1225
|
-
|
|
1226
|
-
|
|
1227
|
-
|
|
1228
|
-
|
|
1229
|
-
|
|
1230
|
-
|
|
1231
|
-
|
|
1232
|
-
|
|
1233
|
-
|
|
1234
|
-
|
|
1235
|
-
|
|
1272
|
+
// Withheld with the gateway (see `deployGateways`), and the HTTPS proxy and
|
|
1273
|
+
// forwarding rule below with it.
|
|
1274
|
+
function siteUrlMap(gatewayBackendId: pulumi.Input<string>): gcp.compute.URLMap {
|
|
1275
|
+
return createSiteUrlMap(
|
|
1276
|
+
`${namePrefix}-url-map`,
|
|
1277
|
+
{
|
|
1278
|
+
domain,
|
|
1279
|
+
adminDomain,
|
|
1280
|
+
stagingHost,
|
|
1281
|
+
staticBackend: staticBackendBucket.id,
|
|
1282
|
+
gatewayBackend: gatewayBackendId,
|
|
1283
|
+
adminBackend: adminBackendService.id,
|
|
1284
|
+
},
|
|
1285
|
+
opts,
|
|
1286
|
+
);
|
|
1287
|
+
}
|
|
1236
1288
|
|
|
1237
1289
|
// #587 — the admin's run SA may rewrite the URL map's redirect rules through
|
|
1238
1290
|
// a project custom role. The CLI owns that role, not this stack: the
|
|
@@ -1261,22 +1313,29 @@ const adminCert = new gcp.compute.ManagedSslCertificate(
|
|
|
1261
1313
|
opts,
|
|
1262
1314
|
);
|
|
1263
1315
|
|
|
1264
|
-
|
|
1265
|
-
|
|
1266
|
-
|
|
1267
|
-
|
|
1268
|
-
)
|
|
1316
|
+
// #1330 — the staging host's own certificate is the CLI's
|
|
1317
|
+
// (staging-gateway-setup.ts, `caelo-<env>-staging-cert`), attached next to
|
|
1318
|
+
// these two after the first `up` and by every converge, so the proxy's
|
|
1319
|
+
// certificate list is left to it after creation.
|
|
1320
|
+
if (gatewayBackendService) {
|
|
1321
|
+
const urlMap = siteUrlMap(gatewayBackendService.id);
|
|
1322
|
+
const httpsProxy = new gcp.compute.TargetHttpsProxy(
|
|
1323
|
+
`${namePrefix}-https-proxy`,
|
|
1324
|
+
{ urlMap: urlMap.id, sslCertificates: [adminCert.id, managedCert.id] },
|
|
1325
|
+
{ ...opts, ignoreChanges: ["sslCertificates"] },
|
|
1326
|
+
);
|
|
1269
1327
|
|
|
1270
|
-
new gcp.compute.GlobalForwardingRule(
|
|
1271
|
-
|
|
1272
|
-
|
|
1273
|
-
|
|
1274
|
-
|
|
1275
|
-
|
|
1276
|
-
|
|
1277
|
-
|
|
1278
|
-
|
|
1279
|
-
);
|
|
1328
|
+
new gcp.compute.GlobalForwardingRule(
|
|
1329
|
+
`${namePrefix}-https-fwd`,
|
|
1330
|
+
{
|
|
1331
|
+
target: httpsProxy.id,
|
|
1332
|
+
portRange: "443",
|
|
1333
|
+
ipAddress: lbIp.address,
|
|
1334
|
+
loadBalancingScheme: "EXTERNAL_MANAGED",
|
|
1335
|
+
},
|
|
1336
|
+
opts,
|
|
1337
|
+
);
|
|
1338
|
+
}
|
|
1280
1339
|
|
|
1281
1340
|
// HTTP → HTTPS redirect: a tiny URLMap with no backend, just a 301
|
|
1282
1341
|
// redirect rule. Same LB IP, port 80, returns to the request's host
|
|
@@ -1330,8 +1389,11 @@ const loggingSink = new gcp.logging.ProjectSink(
|
|
|
1330
1389
|
{
|
|
1331
1390
|
name: `${namePrefix}-edge-log-sink`,
|
|
1332
1391
|
destination: pulumi.interpolate`bigquery.googleapis.com/projects/${project}/datasets/${edgeLogDataset.datasetId}`,
|
|
1333
|
-
// Capture all gateway request logs + admin warnings/errors
|
|
1334
|
-
|
|
1392
|
+
// Capture all gateway request logs + admin warnings/errors (the
|
|
1393
|
+
// gateway's once it is declared).
|
|
1394
|
+
filter: gatewaySvc
|
|
1395
|
+
? pulumi.interpolate`(resource.type="cloud_run_revision" AND resource.labels.service_name="${gatewaySvc.name}") OR (resource.type="cloud_run_revision" AND resource.labels.service_name="${adminSvc.name}" AND severity>=WARNING)`
|
|
1396
|
+
: pulumi.interpolate`resource.type="cloud_run_revision" AND resource.labels.service_name="${adminSvc.name}" AND severity>=WARNING`,
|
|
1335
1397
|
uniqueWriterIdentity: true,
|
|
1336
1398
|
},
|
|
1337
1399
|
opts,
|
|
@@ -1397,7 +1459,7 @@ export const environmentOut = out.environment;
|
|
|
1397
1459
|
export const cloudSqlConnectionNameOut = sqlInstance.connectionName;
|
|
1398
1460
|
export const cloudSqlPrivateIpOut = sqlInstance.privateIpAddress;
|
|
1399
1461
|
export const adminCloudRunUrlOut = adminSvc.uri;
|
|
1400
|
-
export const gatewayCloudRunUrlOut = gatewaySvc
|
|
1462
|
+
export const gatewayCloudRunUrlOut = gatewaySvc?.uri;
|
|
1401
1463
|
export const lbIpOut = lbIp.address;
|
|
1402
1464
|
export const adminDomainOut = adminDomain;
|
|
1403
1465
|
export const bootstrapTokenExpiresAtOut = tokenInfo.expiresAt;
|
|
@@ -33,12 +33,14 @@ import * as random from "@pulumi/random";
|
|
|
33
33
|
import type { CloudAdapterOutputs, DnsRecord } from "../../dist/adapter.js";
|
|
34
34
|
import { generateBootstrapToken } from "../../dist/bootstrap-token.js";
|
|
35
35
|
import {
|
|
36
|
+
firebaseStagingSiteId,
|
|
36
37
|
gatewayServiceAccountId,
|
|
37
38
|
gcpBucketName,
|
|
38
39
|
gcpSecretId,
|
|
39
40
|
MCP_IAP_SERVICE_ACCOUNT_ID,
|
|
40
41
|
mcpAuthProxyServiceAccountId,
|
|
41
42
|
runServiceAccountId,
|
|
43
|
+
stagingGatewayServiceAccountId,
|
|
42
44
|
} from "../../dist/gcp-names.js";
|
|
43
45
|
import {
|
|
44
46
|
DEFAULT_ADMIN_MAX_INSTANCES,
|
|
@@ -65,7 +67,6 @@ import {
|
|
|
65
67
|
defaultStagingHost,
|
|
66
68
|
fixedCloudRunServiceName,
|
|
67
69
|
gatewayEnvContract,
|
|
68
|
-
INTERIM_FORWARD_ORIGIN_ENV,
|
|
69
70
|
MCP_AUTH_PROXY_TIMEOUT_SECONDS,
|
|
70
71
|
mcpAuthProxyEnvContract,
|
|
71
72
|
REMOTE_MCP_IDENTITY_CONFIG,
|
|
@@ -76,6 +77,7 @@ import {
|
|
|
76
77
|
SERVICE_VPC_EGRESS,
|
|
77
78
|
secretFileVolumesTemplate,
|
|
78
79
|
} from "../../dist/stack-contract.js";
|
|
80
|
+
import { DEPLOY_GATEWAYS_CONFIG, parseDeployGateways } from "../../dist/stack-gateways.js";
|
|
79
81
|
|
|
80
82
|
const cfg = new pulumi.Config();
|
|
81
83
|
const domain = cfg.require("domain");
|
|
@@ -482,9 +484,24 @@ const mcpAuthProxySa = new gcp.serviceaccount.Account(
|
|
|
482
484
|
},
|
|
483
485
|
opts,
|
|
484
486
|
);
|
|
487
|
+
// #1330 — the staging gateway's own SA and (below) its secretAccessor on
|
|
488
|
+
// its one login password, plus the telemetry roles. Its service, its read
|
|
489
|
+
// access to the staging bucket and its edge (gcp: NEG, backend, host rule,
|
|
490
|
+
// certificate; gcp-firebase: the second Hosting site) are the CLI's
|
|
491
|
+
// (staging-gateway-setup.ts, after the first `up` and in every converge).
|
|
492
|
+
const stagingGatewaySa = new gcp.serviceaccount.Account(
|
|
493
|
+
`${namePrefix}-staging-gateway-sa`,
|
|
494
|
+
{
|
|
495
|
+
accountId: stagingGatewayServiceAccountId(env),
|
|
496
|
+
displayName: `Caelo ${env} staging gateway`,
|
|
497
|
+
createIgnoreAlreadyExists: true,
|
|
498
|
+
},
|
|
499
|
+
opts,
|
|
500
|
+
);
|
|
485
501
|
const serviceSa: Record<CloudRunSlug, gcp.serviceaccount.Account> = {
|
|
486
502
|
admin: runSa,
|
|
487
503
|
gateway: gatewaySa,
|
|
504
|
+
"staging-gateway": stagingGatewaySa,
|
|
488
505
|
"mcp-auth-proxy": mcpAuthProxySa,
|
|
489
506
|
};
|
|
490
507
|
|
|
@@ -494,6 +511,7 @@ const serviceSa: Record<CloudRunSlug, gcp.serviceaccount.Account> = {
|
|
|
494
511
|
const secretBindings: Record<CloudRunSlug, gcp.secretmanager.SecretIamMember[]> = {
|
|
495
512
|
admin: [],
|
|
496
513
|
gateway: [],
|
|
514
|
+
"staging-gateway": [],
|
|
497
515
|
"mcp-auth-proxy": [],
|
|
498
516
|
};
|
|
499
517
|
for (const binding of runtimeSecretBindings()) {
|
|
@@ -593,6 +611,24 @@ new gcp.projects.IAMMember(
|
|
|
593
611
|
},
|
|
594
612
|
opts,
|
|
595
613
|
);
|
|
614
|
+
new gcp.projects.IAMMember(
|
|
615
|
+
`${namePrefix}-staging-gateway-log-writer`,
|
|
616
|
+
{
|
|
617
|
+
project,
|
|
618
|
+
role: "roles/logging.logWriter",
|
|
619
|
+
member: pulumi.interpolate`serviceAccount:${stagingGatewaySa.email}`,
|
|
620
|
+
},
|
|
621
|
+
opts,
|
|
622
|
+
);
|
|
623
|
+
new gcp.projects.IAMMember(
|
|
624
|
+
`${namePrefix}-staging-gateway-metric-writer`,
|
|
625
|
+
{
|
|
626
|
+
project,
|
|
627
|
+
role: "roles/monitoring.metricWriter",
|
|
628
|
+
member: pulumi.interpolate`serviceAccount:${stagingGatewaySa.email}`,
|
|
629
|
+
},
|
|
630
|
+
opts,
|
|
631
|
+
);
|
|
596
632
|
|
|
597
633
|
// =========================================================================
|
|
598
634
|
// Tier 1 — Firebase Hosting site
|
|
@@ -794,26 +830,38 @@ const envContractInputs = {
|
|
|
794
830
|
},
|
|
795
831
|
} as const;
|
|
796
832
|
|
|
797
|
-
//
|
|
798
|
-
//
|
|
799
|
-
//
|
|
800
|
-
//
|
|
801
|
-
|
|
802
|
-
|
|
803
|
-
|
|
804
|
-
|
|
805
|
-
|
|
806
|
-
|
|
807
|
-
|
|
808
|
-
|
|
809
|
-
|
|
810
|
-
|
|
811
|
-
|
|
812
|
-
|
|
813
|
-
|
|
814
|
-
|
|
815
|
-
|
|
816
|
-
|
|
833
|
+
// #1328 — the data gateway, a service of its own (`caelo-<env>-data-gateway`);
|
|
834
|
+
// before, the gateway was also the remote-MCP broker. Its fixed name goes into
|
|
835
|
+
// the admin's env (the Firebase publisher wires the /api/** rewrite to it).
|
|
836
|
+
//
|
|
837
|
+
// The first `up` of a fresh install withholds it (stack-gateways.ts): it
|
|
838
|
+
// refuses to start until the migrations, which run after that `up`, have
|
|
839
|
+
// isolated its database login. The admin names it by its fixed name, not by
|
|
840
|
+
// this resource, so the admin does not wait for it and keeps its env when it
|
|
841
|
+
// is declared.
|
|
842
|
+
const deployGateways = parseDeployGateways(cfg.get(DEPLOY_GATEWAYS_CONFIG));
|
|
843
|
+
const dataGatewayName = fixedCloudRunServiceName("gcp-firebase", env, "gateway");
|
|
844
|
+
if (!dataGatewayName) throw new Error("the gcp-firebase data gateway has no fixed service name");
|
|
845
|
+
const gatewaySvc = deployGateways
|
|
846
|
+
? cloudRunService({
|
|
847
|
+
serviceName: "gateway",
|
|
848
|
+
// Its own logical name: `${namePrefix}-gateway` belongs to the
|
|
849
|
+
// MCP-Auth-Proxy (E13 a, below), and two resources with one URN fail
|
|
850
|
+
// every `pulumi up` (a fresh install could not converge, 2026-11-04).
|
|
851
|
+
resourceName: `${namePrefix}-data-gateway`,
|
|
852
|
+
minInstances: gatewayMinInstances,
|
|
853
|
+
maxInstances: gatewayMaxInstances,
|
|
854
|
+
memory: "512Mi",
|
|
855
|
+
// Firebase Hosting cuts a rewritten request at 60 s anyway.
|
|
856
|
+
timeout: "300s",
|
|
857
|
+
// All traffic: the Firebase rewrite arrives from Google's edge, and it is
|
|
858
|
+
// invokable by allUsers anyway (data-gateway-public-invoker below): every
|
|
859
|
+
// /api request passes its rate limits, captcha and honeypot. Staging has a
|
|
860
|
+
// gateway of its own since #1330 (staging-gateway-setup.ts).
|
|
861
|
+
ingress: "INGRESS_TRAFFIC_ALL",
|
|
862
|
+
contractEnv: [...gatewayEnvContract(envContractInputs), ...poolBudget.env.gateway],
|
|
863
|
+
})
|
|
864
|
+
: null;
|
|
817
865
|
|
|
818
866
|
// #1328 — the MCP-Auth-Proxy: remote MCP's sign-in broker and its stream to
|
|
819
867
|
// the IAP-protected admin, with no database, no VPC route and an account
|
|
@@ -832,15 +880,11 @@ const mcpAuthProxySvc = cloudRunService({
|
|
|
832
880
|
// MCP clients call its run.app URL, never the Firebase rewrite (which
|
|
833
881
|
// buffers streams and cuts at 60 s).
|
|
834
882
|
timeout: `${MCP_AUTH_PROXY_TIMEOUT_SECONDS}s`,
|
|
835
|
-
// Public: MCP clients reach it directly
|
|
836
|
-
// domain mapping (#650) still points at this service too, and the proxy
|
|
837
|
-
// forwards that traffic to the data gateway (INTERIM_FORWARD_ORIGIN_ENV).
|
|
883
|
+
// Public: MCP clients reach it directly.
|
|
838
884
|
ingress: "INGRESS_TRAFFIC_ALL",
|
|
839
885
|
contractEnv: [
|
|
840
886
|
...mcpAuthProxyEnvContract({ provider: "gcp-firebase", env }),
|
|
841
887
|
...remoteMcpEnv["mcp-auth-proxy"],
|
|
842
|
-
// FIXME(issue #1331): goes with the staging cutover.
|
|
843
|
-
{ name: INTERIM_FORWARD_ORIGIN_ENV, value: gatewaySvc.uri },
|
|
844
888
|
],
|
|
845
889
|
});
|
|
846
890
|
|
|
@@ -861,7 +905,10 @@ const adminSvc = cloudRunService({
|
|
|
861
905
|
...adminEnvContract({
|
|
862
906
|
...envContractInputs,
|
|
863
907
|
firebaseSiteId,
|
|
864
|
-
|
|
908
|
+
firebaseStagingSiteId: pulumi
|
|
909
|
+
.output(firebaseSiteId)
|
|
910
|
+
.apply((id) => firebaseStagingSiteId(env, id)),
|
|
911
|
+
gatewayService: dataGatewayName,
|
|
865
912
|
}),
|
|
866
913
|
...remoteMcpEnv.admin,
|
|
867
914
|
...poolBudget.env.admin,
|
|
@@ -898,17 +945,19 @@ const adminSvc = cloudRunService({
|
|
|
898
945
|
// in-app rate-limit middleware + form CAPTCHA + per-endpoint
|
|
899
946
|
// authentication remain the real security boundary, exactly as
|
|
900
947
|
// designed.
|
|
901
|
-
|
|
902
|
-
|
|
903
|
-
|
|
904
|
-
|
|
905
|
-
|
|
906
|
-
|
|
907
|
-
|
|
908
|
-
|
|
909
|
-
|
|
910
|
-
|
|
911
|
-
|
|
948
|
+
if (gatewaySvc) {
|
|
949
|
+
new gcp.cloudrunv2.ServiceIamMember(
|
|
950
|
+
`${namePrefix}-data-gateway-public-invoker`,
|
|
951
|
+
{
|
|
952
|
+
project,
|
|
953
|
+
location: region,
|
|
954
|
+
name: gatewaySvc.name,
|
|
955
|
+
role: "roles/run.invoker",
|
|
956
|
+
member: "allUsers",
|
|
957
|
+
},
|
|
958
|
+
opts,
|
|
959
|
+
);
|
|
960
|
+
}
|
|
912
961
|
|
|
913
962
|
// #1328 — the MCP-Auth-Proxy: MCP clients sign in and call it without a
|
|
914
963
|
// Google identity of their own. The binding the service had as the gateway,
|
|
@@ -943,17 +992,19 @@ new gcp.cloudrunv2.ServiceIamMember(
|
|
|
943
992
|
// service for the runSa to act as itself. The gateway needs the
|
|
944
993
|
// explicit cross-service grant because the admin's runSa is a
|
|
945
994
|
// DIFFERENT-resource caller from the gateway's perspective.
|
|
946
|
-
|
|
947
|
-
|
|
948
|
-
|
|
949
|
-
|
|
950
|
-
|
|
951
|
-
|
|
952
|
-
|
|
953
|
-
|
|
954
|
-
|
|
955
|
-
|
|
956
|
-
|
|
995
|
+
if (gatewaySvc) {
|
|
996
|
+
new gcp.cloudrunv2.ServiceIamMember(
|
|
997
|
+
`${namePrefix}-data-gateway-viewer-for-admin-sa`,
|
|
998
|
+
{
|
|
999
|
+
project,
|
|
1000
|
+
location: region,
|
|
1001
|
+
name: gatewaySvc.name,
|
|
1002
|
+
role: "roles/run.viewer",
|
|
1003
|
+
member: pulumi.interpolate`serviceAccount:${runSa.email}`,
|
|
1004
|
+
},
|
|
1005
|
+
opts,
|
|
1006
|
+
);
|
|
1007
|
+
}
|
|
957
1008
|
|
|
958
1009
|
// =========================================================================
|
|
959
1010
|
// Admin custom domain — Cloud Run domain mapping
|
|
@@ -1286,7 +1337,7 @@ export const edgeLogSinkUrlOut = out.edgeLogSinkUrl;
|
|
|
1286
1337
|
export const providerOut = out.provider;
|
|
1287
1338
|
export const environmentOut = out.environment;
|
|
1288
1339
|
export const adminCloudRunUrlOut = adminSvc.uri;
|
|
1289
|
-
export const gatewayCloudRunUrlOut = gatewaySvc
|
|
1340
|
+
export const gatewayCloudRunUrlOut = gatewaySvc?.uri;
|
|
1290
1341
|
export const mcpAuthProxyCloudRunUrlOut = mcpAuthProxySvc.uri;
|
|
1291
1342
|
export const adminDomainOut = adminDomain;
|
|
1292
1343
|
export const firebaseSiteIdOut = firebaseSiteId;
|
|
@@ -30,6 +30,7 @@ import {
|
|
|
30
30
|
COMPOSE_ADMIN_UPSTREAM,
|
|
31
31
|
COMPOSE_GATEWAY_UPSTREAM,
|
|
32
32
|
COMPOSE_MCP_AUTH_PROXY_UPSTREAM,
|
|
33
|
+
COMPOSE_STAGING_GATEWAY_UPSTREAM,
|
|
33
34
|
composeProjectName,
|
|
34
35
|
generateDockerCompose,
|
|
35
36
|
SITE_OUTPUT_ROOT,
|
|
@@ -89,6 +90,9 @@ const publicRolePassword = pulumi.secret(randomHex(32));
|
|
|
89
90
|
const publicStagingRolePassword = pulumi.secret(randomHex(32));
|
|
90
91
|
// P18 — the KEK that encrypts stored provider keys.
|
|
91
92
|
const caeloSecretKek = pulumi.secret(randomHex(32));
|
|
93
|
+
// #650 / #1330 — the staging gate's key (admin only; the admin publishes it
|
|
94
|
+
// to the staging gateway through the staging projection).
|
|
95
|
+
const stagingGateSecret = pulumi.secret(randomHex(32));
|
|
92
96
|
|
|
93
97
|
const composeYaml = pulumi
|
|
94
98
|
.all([
|
|
@@ -97,10 +101,13 @@ const composeYaml = pulumi
|
|
|
97
101
|
publicRolePassword,
|
|
98
102
|
publicStagingRolePassword,
|
|
99
103
|
caeloSecretKek,
|
|
104
|
+
stagingGateSecret,
|
|
100
105
|
])
|
|
101
|
-
.apply(([pgPw, adminPw, publicPw, publicStagingPw, kek]) =>
|
|
106
|
+
.apply(([pgPw, adminPw, publicPw, publicStagingPw, kek, gateSecret]) =>
|
|
102
107
|
generateDockerCompose({
|
|
103
108
|
domain,
|
|
109
|
+
stagingHost,
|
|
110
|
+
stagingGateSecret: gateSecret,
|
|
104
111
|
postgresPassword: pgPw,
|
|
105
112
|
rolePasswords: { admin: adminPw, public: publicPw, publicStaging: publicStagingPw },
|
|
106
113
|
caeloSecretKek: kek,
|
|
@@ -126,7 +133,7 @@ const caddyConf = generateCaddyfile({
|
|
|
126
133
|
ownerEmail,
|
|
127
134
|
tls: "acme",
|
|
128
135
|
publicSiteRoot: `${SITE_OUTPUT_ROOT}/output/production/current`,
|
|
129
|
-
|
|
136
|
+
stagingGatewayUpstream: COMPOSE_STAGING_GATEWAY_UPSTREAM,
|
|
130
137
|
adminUpstream: COMPOSE_ADMIN_UPSTREAM,
|
|
131
138
|
gatewayUpstream: COMPOSE_GATEWAY_UPSTREAM,
|
|
132
139
|
mcpAuthProxyUpstream: COMPOSE_MCP_AUTH_PROXY_UPSTREAM,
|