@caelo-cms/provisioning 0.11.14 → 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.
Files changed (41) hide show
  1. package/dist/__tests__/stack-under-mocks.d.ts +2 -0
  2. package/dist/__tests__/stack-under-mocks.d.ts.map +1 -0
  3. package/dist/__tests__/stack-under-mocks.js +59 -0
  4. package/dist/__tests__/stack-under-mocks.js.map +1 -0
  5. package/dist/deployed-release.d.ts.map +1 -1
  6. package/dist/deployed-release.js +4 -2
  7. package/dist/deployed-release.js.map +1 -1
  8. package/dist/gateway-bootstrap.d.ts +68 -0
  9. package/dist/gateway-bootstrap.d.ts.map +1 -0
  10. package/dist/gateway-bootstrap.js +145 -0
  11. package/dist/gateway-bootstrap.js.map +1 -0
  12. package/dist/stack-gateways.d.ts +31 -0
  13. package/dist/stack-gateways.d.ts.map +1 -0
  14. package/dist/stack-gateways.js +40 -0
  15. package/dist/stack-gateways.js.map +1 -0
  16. package/dist/state-command.d.ts.map +1 -1
  17. package/dist/state-command.js +3 -0
  18. package/dist/state-command.js.map +1 -1
  19. package/dist/wizards/gcp-pulumi.d.ts +7 -1
  20. package/dist/wizards/gcp-pulumi.d.ts.map +1 -1
  21. package/dist/wizards/gcp-pulumi.js +2 -0
  22. package/dist/wizards/gcp-pulumi.js.map +1 -1
  23. package/dist/wizards/gcp.d.ts.map +1 -1
  24. package/dist/wizards/gcp.js +120 -13
  25. package/dist/wizards/gcp.js.map +1 -1
  26. package/package.json +2 -2
  27. package/src/__tests__/stack-under-mocks.ts +69 -0
  28. package/src/deployed-release.test.ts +16 -0
  29. package/src/deployed-release.ts +4 -2
  30. package/src/gateway-bootstrap.test.ts +381 -0
  31. package/src/gateway-bootstrap.ts +195 -0
  32. package/src/gcp-url-map.test.ts +1 -1
  33. package/src/remote-mcp-stack-config.test.ts +2 -1
  34. package/src/stack-cloud-run-names.test.ts +49 -0
  35. package/src/stack-gateways.ts +39 -0
  36. package/src/state-command.ts +3 -0
  37. package/src/wizards/gcp-pulumi.ts +9 -0
  38. package/src/wizards/gcp.ts +146 -14
  39. package/stacks/gcp/Pulumi.yaml +4 -0
  40. package/stacks/gcp/index.ts +83 -62
  41. package/stacks/gcp-firebase/index.ts +61 -42
@@ -77,6 +77,7 @@ import {
77
77
  SERVICE_VPC_EGRESS,
78
78
  secretFileVolumesTemplate,
79
79
  } from "../../dist/stack-contract.js";
80
+ import { DEPLOY_GATEWAYS_CONFIG, parseDeployGateways } from "../../dist/stack-gateways.js";
80
81
 
81
82
  const cfg = new pulumi.Config();
82
83
  const domain = cfg.require("domain");
@@ -829,24 +830,38 @@ const envContractInputs = {
829
830
  },
830
831
  } as const;
831
832
 
832
- // The data gateway is provisioned first so its name/region can go into the
833
- // admin's env (the Firebase publisher wires the /api/** rewrite to it).
834
- // #1328 — a service of its own (`caelo-<env>-data-gateway`); before, the
835
- // gateway was also the remote-MCP broker.
836
- const gatewaySvc = cloudRunService({
837
- serviceName: "gateway",
838
- minInstances: gatewayMinInstances,
839
- maxInstances: gatewayMaxInstances,
840
- memory: "512Mi",
841
- // Firebase Hosting cuts a rewritten request at 60 s anyway.
842
- timeout: "300s",
843
- // All traffic: the Firebase rewrite arrives from Google's edge, and it is
844
- // invokable by allUsers anyway (data-gateway-public-invoker below): every
845
- // /api request passes its rate limits, captcha and honeypot. Staging has a
846
- // gateway of its own since #1330 (staging-gateway-setup.ts).
847
- ingress: "INGRESS_TRAFFIC_ALL",
848
- contractEnv: [...gatewayEnvContract(envContractInputs), ...poolBudget.env.gateway],
849
- });
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;
850
865
 
851
866
  // #1328 — the MCP-Auth-Proxy: remote MCP's sign-in broker and its stream to
852
867
  // the IAP-protected admin, with no database, no VPC route and an account
@@ -893,7 +908,7 @@ const adminSvc = cloudRunService({
893
908
  firebaseStagingSiteId: pulumi
894
909
  .output(firebaseSiteId)
895
910
  .apply((id) => firebaseStagingSiteId(env, id)),
896
- gatewayService: gatewaySvc.name,
911
+ gatewayService: dataGatewayName,
897
912
  }),
898
913
  ...remoteMcpEnv.admin,
899
914
  ...poolBudget.env.admin,
@@ -930,17 +945,19 @@ const adminSvc = cloudRunService({
930
945
  // in-app rate-limit middleware + form CAPTCHA + per-endpoint
931
946
  // authentication remain the real security boundary, exactly as
932
947
  // designed.
933
- new gcp.cloudrunv2.ServiceIamMember(
934
- `${namePrefix}-data-gateway-public-invoker`,
935
- {
936
- project,
937
- location: region,
938
- name: gatewaySvc.name,
939
- role: "roles/run.invoker",
940
- member: "allUsers",
941
- },
942
- opts,
943
- );
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
+ }
944
961
 
945
962
  // #1328 — the MCP-Auth-Proxy: MCP clients sign in and call it without a
946
963
  // Google identity of their own. The binding the service had as the gateway,
@@ -975,17 +992,19 @@ new gcp.cloudrunv2.ServiceIamMember(
975
992
  // service for the runSa to act as itself. The gateway needs the
976
993
  // explicit cross-service grant because the admin's runSa is a
977
994
  // DIFFERENT-resource caller from the gateway's perspective.
978
- new gcp.cloudrunv2.ServiceIamMember(
979
- `${namePrefix}-data-gateway-viewer-for-admin-sa`,
980
- {
981
- project,
982
- location: region,
983
- name: gatewaySvc.name,
984
- role: "roles/run.viewer",
985
- member: pulumi.interpolate`serviceAccount:${runSa.email}`,
986
- },
987
- opts,
988
- );
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
+ }
989
1008
 
990
1009
  // =========================================================================
991
1010
  // Admin custom domain — Cloud Run domain mapping
@@ -1318,7 +1337,7 @@ export const edgeLogSinkUrlOut = out.edgeLogSinkUrl;
1318
1337
  export const providerOut = out.provider;
1319
1338
  export const environmentOut = out.environment;
1320
1339
  export const adminCloudRunUrlOut = adminSvc.uri;
1321
- export const gatewayCloudRunUrlOut = gatewaySvc.uri;
1340
+ export const gatewayCloudRunUrlOut = gatewaySvc?.uri;
1322
1341
  export const mcpAuthProxyCloudRunUrlOut = mcpAuthProxySvc.uri;
1323
1342
  export const adminDomainOut = adminDomain;
1324
1343
  export const firebaseSiteIdOut = firebaseSiteId;