@caelo-cms/provisioning 0.11.14 → 0.11.16
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/adopt-existing.d.ts +0 -56
- package/dist/adopt-existing.d.ts.map +1 -1
- package/dist/adopt-existing.js +58 -2
- package/dist/adopt-existing.js.map +1 -1
- package/dist/cloudsql-tls.d.ts.map +1 -1
- package/dist/cloudsql-tls.js +3 -3
- package/dist/cloudsql-tls.js.map +1 -1
- package/dist/deployed-release.d.ts.map +1 -1
- package/dist/deployed-release.js +4 -2
- 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/gcloud.d.ts +2 -0
- package/dist/gcloud.d.ts.map +1 -1
- package/dist/gcloud.js +14 -0
- package/dist/gcloud.js.map +1 -1
- package/dist/mcp-auth-proxy-setup.d.ts.map +1 -1
- package/dist/mcp-auth-proxy-setup.js +3 -6
- package/dist/mcp-auth-proxy-setup.js.map +1 -1
- package/dist/ops-backend.d.ts.map +1 -1
- package/dist/ops-backend.js +4 -6
- package/dist/ops-backend.js.map +1 -1
- package/dist/remote-mcp.d.ts.map +1 -1
- package/dist/remote-mcp.js +4 -5
- package/dist/remote-mcp.js.map +1 -1
- package/dist/runtime-secrets.d.ts.map +1 -1
- package/dist/runtime-secrets.js +4 -5
- package/dist/runtime-secrets.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-gateway-setup.d.ts.map +1 -1
- package/dist/staging-gateway-setup.js +7 -8
- package/dist/staging-gateway-setup.js.map +1 -1
- 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/state-lock-lease.d.ts +1 -1
- package/dist/state-lock-lease.d.ts.map +1 -1
- package/dist/state-lock-lease.js +2 -2
- package/dist/state-lock-lease.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 +120 -13
- package/dist/wizards/gcp.js.map +1 -1
- package/package.json +2 -2
- package/src/__tests__/stack-under-mocks.ts +69 -0
- package/src/adopt-existing.test.ts +36 -9
- package/src/adopt-existing.ts +2 -3
- package/src/cloudsql-tls.ts +3 -3
- package/src/deployed-release.test.ts +16 -0
- package/src/deployed-release.ts +4 -2
- package/src/gateway-bootstrap.test.ts +381 -0
- package/src/gateway-bootstrap.ts +195 -0
- package/src/gcloud.test.ts +24 -0
- package/src/gcloud.ts +17 -0
- package/src/gcp-url-map.test.ts +1 -1
- package/src/mcp-auth-proxy-setup.ts +3 -7
- package/src/ops-backend.ts +4 -7
- package/src/remote-mcp-stack-config.test.ts +2 -1
- package/src/remote-mcp.ts +4 -6
- package/src/runtime-secrets.ts +4 -5
- package/src/stack-cloud-run-names.test.ts +49 -0
- package/src/stack-gateways.ts +39 -0
- package/src/staging-gateway-setup.ts +7 -8
- package/src/state-command.ts +3 -0
- package/src/state-lock-lease.ts +2 -4
- package/src/wizards/gcp-pulumi.ts +9 -0
- package/src/wizards/gcp.ts +146 -14
- package/stacks/gcp/Pulumi.yaml +4 -0
- package/stacks/gcp/index.ts +83 -62
- package/stacks/gcp-firebase/index.ts +61 -42
package/stacks/gcp/index.ts
CHANGED
|
@@ -64,6 +64,7 @@ import {
|
|
|
64
64
|
STATIC_CDN_POLICY,
|
|
65
65
|
secretFileVolumesTemplate,
|
|
66
66
|
} from "../../dist/stack-contract.js";
|
|
67
|
+
import { DEPLOY_GATEWAYS_CONFIG, parseDeployGateways } from "../../dist/stack-gateways.js";
|
|
67
68
|
import { GCP_STATIC_RESPONSE_HEADERS } from "../../dist/static-security-headers.js";
|
|
68
69
|
|
|
69
70
|
const cfg = new pulumi.Config();
|
|
@@ -947,18 +948,26 @@ const adminSvc = cloudRunService({
|
|
|
947
948
|
],
|
|
948
949
|
mediaVolume: adminMediaVolumeTemplate(adminMediaVolume(project, env)),
|
|
949
950
|
});
|
|
950
|
-
|
|
951
|
-
|
|
952
|
-
|
|
953
|
-
|
|
954
|
-
|
|
955
|
-
|
|
956
|
-
|
|
957
|
-
|
|
958
|
-
|
|
959
|
-
|
|
960
|
-
|
|
961
|
-
|
|
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;
|
|
962
971
|
|
|
963
972
|
// =========================================================================
|
|
964
973
|
// Tier 1 + Tier 2 + Tier 3 LB — single HTTPS LB serves three backends
|
|
@@ -1059,26 +1068,28 @@ const staticBackendBucket = new gcp.compute.BackendBucket(
|
|
|
1059
1068
|
);
|
|
1060
1069
|
|
|
1061
1070
|
// Tier 3 backend — gateway Cloud Run via serverless NEG
|
|
1062
|
-
|
|
1063
|
-
|
|
1064
|
-
|
|
1065
|
-
|
|
1066
|
-
|
|
1067
|
-
|
|
1068
|
-
|
|
1069
|
-
|
|
1070
|
-
|
|
1071
|
-
|
|
1072
|
-
|
|
1073
|
-
|
|
1074
|
-
|
|
1075
|
-
|
|
1076
|
-
|
|
1077
|
-
|
|
1078
|
-
|
|
1079
|
-
|
|
1080
|
-
|
|
1081
|
-
);
|
|
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;
|
|
1082
1093
|
|
|
1083
1094
|
// Tier 2 backend — admin Cloud Run via serverless NEG, IAP-gated.
|
|
1084
1095
|
const adminNeg = new gcp.compute.RegionNetworkEndpointGroup(
|
|
@@ -1258,18 +1269,22 @@ new gcp.iap.WebBackendServiceIamMember(
|
|
|
1258
1269
|
// #587 — the public path matcher also carries the redirects table as
|
|
1259
1270
|
// `urlRedirect` rules, written by the admin on every Confirm-publish; the
|
|
1260
1271
|
// stack ignores that field after creation (src/gcp-url-map.ts).
|
|
1261
|
-
|
|
1262
|
-
|
|
1263
|
-
|
|
1264
|
-
|
|
1265
|
-
|
|
1266
|
-
|
|
1267
|
-
|
|
1268
|
-
|
|
1269
|
-
|
|
1270
|
-
|
|
1271
|
-
|
|
1272
|
-
|
|
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
|
+
}
|
|
1273
1288
|
|
|
1274
1289
|
// #587 — the admin's run SA may rewrite the URL map's redirect rules through
|
|
1275
1290
|
// a project custom role. The CLI owns that role, not this stack: the
|
|
@@ -1302,22 +1317,25 @@ const adminCert = new gcp.compute.ManagedSslCertificate(
|
|
|
1302
1317
|
// (staging-gateway-setup.ts, `caelo-<env>-staging-cert`), attached next to
|
|
1303
1318
|
// these two after the first `up` and by every converge, so the proxy's
|
|
1304
1319
|
// certificate list is left to it after creation.
|
|
1305
|
-
|
|
1306
|
-
|
|
1307
|
-
|
|
1308
|
-
|
|
1309
|
-
|
|
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
|
+
);
|
|
1310
1327
|
|
|
1311
|
-
new gcp.compute.GlobalForwardingRule(
|
|
1312
|
-
|
|
1313
|
-
|
|
1314
|
-
|
|
1315
|
-
|
|
1316
|
-
|
|
1317
|
-
|
|
1318
|
-
|
|
1319
|
-
|
|
1320
|
-
);
|
|
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
|
+
}
|
|
1321
1339
|
|
|
1322
1340
|
// HTTP → HTTPS redirect: a tiny URLMap with no backend, just a 301
|
|
1323
1341
|
// redirect rule. Same LB IP, port 80, returns to the request's host
|
|
@@ -1371,8 +1389,11 @@ const loggingSink = new gcp.logging.ProjectSink(
|
|
|
1371
1389
|
{
|
|
1372
1390
|
name: `${namePrefix}-edge-log-sink`,
|
|
1373
1391
|
destination: pulumi.interpolate`bigquery.googleapis.com/projects/${project}/datasets/${edgeLogDataset.datasetId}`,
|
|
1374
|
-
// Capture all gateway request logs + admin warnings/errors
|
|
1375
|
-
|
|
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`,
|
|
1376
1397
|
uniqueWriterIdentity: true,
|
|
1377
1398
|
},
|
|
1378
1399
|
opts,
|
|
@@ -1438,7 +1459,7 @@ export const environmentOut = out.environment;
|
|
|
1438
1459
|
export const cloudSqlConnectionNameOut = sqlInstance.connectionName;
|
|
1439
1460
|
export const cloudSqlPrivateIpOut = sqlInstance.privateIpAddress;
|
|
1440
1461
|
export const adminCloudRunUrlOut = adminSvc.uri;
|
|
1441
|
-
export const gatewayCloudRunUrlOut = gatewaySvc
|
|
1462
|
+
export const gatewayCloudRunUrlOut = gatewaySvc?.uri;
|
|
1442
1463
|
export const lbIpOut = lbIp.address;
|
|
1443
1464
|
export const adminDomainOut = adminDomain;
|
|
1444
1465
|
export const bootstrapTokenExpiresAtOut = tokenInfo.expiresAt;
|
|
@@ -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
|
-
//
|
|
833
|
-
//
|
|
834
|
-
//
|
|
835
|
-
//
|
|
836
|
-
|
|
837
|
-
|
|
838
|
-
|
|
839
|
-
|
|
840
|
-
|
|
841
|
-
|
|
842
|
-
|
|
843
|
-
|
|
844
|
-
|
|
845
|
-
|
|
846
|
-
|
|
847
|
-
|
|
848
|
-
|
|
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:
|
|
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
|
-
|
|
934
|
-
|
|
935
|
-
|
|
936
|
-
|
|
937
|
-
|
|
938
|
-
|
|
939
|
-
|
|
940
|
-
|
|
941
|
-
|
|
942
|
-
|
|
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
|
-
|
|
979
|
-
|
|
980
|
-
|
|
981
|
-
|
|
982
|
-
|
|
983
|
-
|
|
984
|
-
|
|
985
|
-
|
|
986
|
-
|
|
987
|
-
|
|
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
|
|
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;
|