@venturekit/infra 0.0.53 → 0.0.55
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/cdk/app-stack.d.ts +29 -0
- package/dist/cdk/app-stack.d.ts.map +1 -1
- package/dist/cdk/app-stack.js +104 -31
- package/dist/cdk/app-stack.js.map +1 -1
- package/dist/cdk/data-stack.d.ts.map +1 -1
- package/dist/cdk/data-stack.js +47 -31
- package/dist/cdk/data-stack.js.map +1 -1
- package/dist/cdk/edge-stack.d.ts +15 -0
- package/dist/cdk/edge-stack.d.ts.map +1 -1
- package/dist/cdk/edge-stack.js +59 -15
- package/dist/cdk/edge-stack.js.map +1 -1
- package/dist/cdk/index.d.ts +5 -0
- package/dist/cdk/index.d.ts.map +1 -1
- package/dist/cdk/index.js +4 -0
- package/dist/cdk/index.js.map +1 -1
- package/dist/cdk/migration-runner.js +3 -3
- package/dist/cdk/shared/api-shards.d.ts +38 -0
- package/dist/cdk/shared/api-shards.d.ts.map +1 -0
- package/dist/cdk/shared/api-shards.js +69 -0
- package/dist/cdk/shared/api-shards.js.map +1 -0
- package/dist/cdk/shared/lambda-helpers.js +2 -2
- package/dist/cdk/shared/retained-exports.d.ts +24 -0
- package/dist/cdk/shared/retained-exports.d.ts.map +1 -0
- package/dist/cdk/shared/retained-exports.js +38 -0
- package/dist/cdk/shared/retained-exports.js.map +1 -0
- package/package.json +2 -2
package/dist/cdk/app-stack.d.ts
CHANGED
|
@@ -99,6 +99,8 @@ export interface AppStackImports {
|
|
|
99
99
|
* The app stack registers routes on this API.
|
|
100
100
|
*/
|
|
101
101
|
api?: apigatewayv2.IHttpApi;
|
|
102
|
+
/** The edge tier's extra HTTP APIs by shard (1+), past 300 routes — see `planApiShards`. */
|
|
103
|
+
apiShards?: Map<number, apigatewayv2.IHttpApi>;
|
|
102
104
|
/**
|
|
103
105
|
* Cognito User Pool ARN per declared `auth` intent — for
|
|
104
106
|
* `cognito-idp:Admin*` grant scoping. Resolved by the generator
|
|
@@ -272,6 +274,11 @@ export interface AppStackImports {
|
|
|
272
274
|
*/
|
|
273
275
|
serviceHostsById?: Map<string, string>;
|
|
274
276
|
}
|
|
277
|
+
/** The deployed routes and integrations of each HTTP API shard (`'0'`, `'1'`, …); routes as `METHOD /full/path`. */
|
|
278
|
+
export interface ExistingRoutes {
|
|
279
|
+
integrationsByShard: Record<string, number>;
|
|
280
|
+
routesByShard: Record<string, string[]>;
|
|
281
|
+
}
|
|
275
282
|
export interface VentureAppStackProps extends cdk.StackProps {
|
|
276
283
|
projectName: string;
|
|
277
284
|
stage: string;
|
|
@@ -280,6 +287,17 @@ export interface VentureAppStackProps extends cdk.StackProps {
|
|
|
280
287
|
infrastructure: VentureIntent;
|
|
281
288
|
/** Cross-stack imports (network/data/identity/config/messaging/edge). */
|
|
282
289
|
imports: AppStackImports;
|
|
290
|
+
/**
|
|
291
|
+
* What the deployed HTTP APIs hold (`vk deploy` reads it), so a
|
|
292
|
+
* brand-new route on an API that would pass 300 integrations mid-deploy
|
|
293
|
+
* waits for the next pass — CloudFormation deletes the routes that
|
|
294
|
+
* moved away only at the end. The deferred route keys are written to
|
|
295
|
+
* `reportFile`.
|
|
296
|
+
*/
|
|
297
|
+
routeDeferral?: {
|
|
298
|
+
existing?: ExistingRoutes;
|
|
299
|
+
reportFile?: string;
|
|
300
|
+
};
|
|
283
301
|
/**
|
|
284
302
|
* Project root directory — the dir containing `package.json` +
|
|
285
303
|
* `node_modules`. Used as the bundling asset root so esbuild
|
|
@@ -415,6 +433,10 @@ export declare class VentureAppStack extends cdk.Stack {
|
|
|
415
433
|
* when needed.
|
|
416
434
|
*/
|
|
417
435
|
readonly routeLambdas: Map<string, lambda.Function>;
|
|
436
|
+
/** The edge tier's extra HTTP APIs by shard (1+). */
|
|
437
|
+
private readonly apiShards;
|
|
438
|
+
/** Which HTTP API serves each public route (`planApiShards`), once routes are discovered. */
|
|
439
|
+
private shardPlan?;
|
|
418
440
|
/** Queue consumer Lambdas keyed by handler name. */
|
|
419
441
|
readonly queueLambdas: Map<string, lambda.Function>;
|
|
420
442
|
/** Scheduled / cron Lambdas keyed by handler name. */
|
|
@@ -509,6 +531,13 @@ export declare class VentureAppStack extends cdk.Stack {
|
|
|
509
531
|
* esbuild.
|
|
510
532
|
*/
|
|
511
533
|
private bundleHandlerCode;
|
|
534
|
+
/**
|
|
535
|
+
* The new routes to hold back this deploy: on each HTTP API, the peak
|
|
536
|
+
* during the deploy is what it holds now plus what this deploy creates
|
|
537
|
+
* there (routes moving away are deleted only at the end). Over the
|
|
538
|
+
* limit, brand-new routes wait; routes moving between APIs never do.
|
|
539
|
+
*/
|
|
540
|
+
private deferredRoutes;
|
|
512
541
|
/**
|
|
513
542
|
* Materialise one route handler: a Lambda function + an
|
|
514
543
|
* `HttpRoute` on the imported API + an `HttpLambdaIntegration`
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"app-stack.d.ts","sourceRoot":"","sources":["../../src/cdk/app-stack.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiEG;AAKH,OAAO,KAAK,GAAG,MAAM,aAAa,CAAC;AACnC,OAAO,KAAK,GAAG,MAAM,qBAAqB,CAAC;AAC3C,OAAO,KAAK,GAAG,MAAM,qBAAqB,CAAC;AAC3C,OAAO,KAAK,MAAM,MAAM,wBAAwB,CAAC;AAQjD,OAAO,KAAK,YAAY,MAAM,8BAA8B,CAAC;AAM7D,OAAO,KAAK,cAAc,MAAM,gCAAgC,CAAC;AAEjE,OAAO,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AACvC,OAAO,EAGL,KAAK,SAAS,EACd,KAAK,aAAa,EACnB,MAAM,kBAAkB,CAAC;
|
|
1
|
+
{"version":3,"file":"app-stack.d.ts","sourceRoot":"","sources":["../../src/cdk/app-stack.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;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;;;OAQG;IACH,OAAO,CAAC,mBAAmB;IAkD3B;;;;;;;;;;;;OAYG;IACH,OAAO,CAAC,qBAAqB;IAuD7B;;;;;;;;;;;OAWG;IACH,OAAO,CAAC,wBAAwB;IA0BhC;;;;;;;;;;;;;;OAcG;IACH,OAAO,CAAC,wBAAwB;IAqChC;;;;;;;;;OASG;IACH,OAAO,CAAC,eAAe;IA8DvB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OAgCG;IACH,OAAO,CAAC,gBAAgB;IA2DxB;;;;OAIG;IACH,OAAO,CAAC,sBAAsB;IAiC9B;;;;;OAKG;IACH,OAAO,CAAC,uBAAuB;IAW/B;;;;;;;;;;;;;;;;;;;;;;OAsBG;IACH,OAAO,CAAC,mBAAmB;IA0Q3B;;;;;;;;;;;;;;;;;;OAkBG;IACH,OAAO,CAAC,uBAAuB;CAsKhC"}
|
package/dist/cdk/app-stack.js
CHANGED
|
@@ -92,6 +92,7 @@ import { isInternalRoute, matchesFunctionPattern } from '@venturekit/core';
|
|
|
92
92
|
import { createInternalCallerSecrets, internalCallStatements } from './shared/internal-routes.js';
|
|
93
93
|
import { readSsmString, writeSsm } from './shared/cross-stack-refs.js';
|
|
94
94
|
import { validateEc2Descriptions } from './shared/ec2-descriptions.js';
|
|
95
|
+
import { HTTP_API_ROUTE_LIMIT, planApiShards } from './shared/api-shards.js';
|
|
95
96
|
import { APPLICATION_SIGNALS_POLICY, defaultOtelLayerArn, otelEnvironment } from './shared/otel-layer.js';
|
|
96
97
|
import { grantCustomSenderInvoke, resolveCustomSender } from './shared/custom-sender.js';
|
|
97
98
|
import { networkKeys, edgeKeys, identityKeys, dataKeys, internalKeys } from './shared/ssm-keys.js';
|
|
@@ -139,6 +140,7 @@ function fnv1a32(input) {
|
|
|
139
140
|
}
|
|
140
141
|
return hash >>> 0;
|
|
141
142
|
}
|
|
143
|
+
const routeKeyOf = (route) => `${route.method} ${route.apiPath}`;
|
|
142
144
|
/**
|
|
143
145
|
* App stack — see file header for the full lifecycle rationale.
|
|
144
146
|
*
|
|
@@ -214,6 +216,10 @@ export class VentureAppStack extends cdk.Stack {
|
|
|
214
216
|
* when needed.
|
|
215
217
|
*/
|
|
216
218
|
routeLambdas = new Map();
|
|
219
|
+
/** The edge tier's extra HTTP APIs by shard (1+). */
|
|
220
|
+
apiShards;
|
|
221
|
+
/** Which HTTP API serves each public route (`planApiShards`), once routes are discovered. */
|
|
222
|
+
shardPlan;
|
|
217
223
|
/** Queue consumer Lambdas keyed by handler name. */
|
|
218
224
|
queueLambdas = new Map();
|
|
219
225
|
/** Scheduled / cron Lambdas keyed by handler name. */
|
|
@@ -320,6 +326,7 @@ export class VentureAppStack extends cdk.Stack {
|
|
|
320
326
|
DATA_SAFETY_CONFIG[envConfig.dataSafety].removalPolicy === 'retain';
|
|
321
327
|
this.vpc = imports.vpc;
|
|
322
328
|
this.api = imports.api;
|
|
329
|
+
this.apiShards = imports.apiShards ?? new Map();
|
|
323
330
|
this.projectName = projectName;
|
|
324
331
|
this.stage = stage;
|
|
325
332
|
this.rdsDatabaseIds = new Set(imports.databaseEndpointsById?.keys() ?? []);
|
|
@@ -541,9 +548,6 @@ export class VentureAppStack extends cdk.Stack {
|
|
|
541
548
|
// resolution never depends on the fallback.
|
|
542
549
|
VENTURE_IDEMPOTENCY_TABLE: `${projectName}-idempotency-${stage}`,
|
|
543
550
|
VENTURE_SAGA_TABLE: `${projectName}-sagas-${stage}`,
|
|
544
|
-
// `--enable-source-maps` makes thrown errors point to the
|
|
545
|
-
// .ts source instead of bundled .js. Free win in CloudWatch.
|
|
546
|
-
NODE_OPTIONS: '--enable-source-maps',
|
|
547
551
|
// `lambda.otel`: the wrapper starts the layer's OpenTelemetry SDK
|
|
548
552
|
// (it appends its own `--require` to NODE_OPTIONS at startup).
|
|
549
553
|
...(otel
|
|
@@ -627,6 +631,13 @@ export class VentureAppStack extends cdk.Stack {
|
|
|
627
631
|
const [, primaryClientId] = imports.appClientIdsByAuthId.entries().next().value;
|
|
628
632
|
this.baseEnvVars['COGNITO_APP_CLIENT_ID'] = primaryClientId;
|
|
629
633
|
}
|
|
634
|
+
// The intent the `COGNITO_*` set describes: its `AUTH_<ID>_*` copy is
|
|
635
|
+
// not injected (Lambda's environment is capped at 4 KB), and
|
|
636
|
+
// `loadAuthServerConfig({ intent })` reads `COGNITO_*` for it instead.
|
|
637
|
+
const canonicalAuthId = imports.userPoolIdsByAuthId?.keys().next().value;
|
|
638
|
+
const hasCanonicalAuth = canonicalAuthId !== undefined && imports.appClientIdsByAuthId?.keys().next().value === canonicalAuthId;
|
|
639
|
+
if (hasCanonicalAuth)
|
|
640
|
+
this.baseEnvVars['COGNITO_AUTH_INTENT'] = canonicalAuthId;
|
|
630
641
|
// ─── Per-intent auth env (`AUTH_<ID>_*`) ──────────────────────
|
|
631
642
|
// `loadAuthServerConfig({ intent })` / `cookieAuthMiddleware({
|
|
632
643
|
// intents })` in `@venturekit/auth/server` address one declared
|
|
@@ -634,7 +645,8 @@ export class VentureAppStack extends cdk.Stack {
|
|
|
634
645
|
// maps; an `external` intent is another venture's pool, read from
|
|
635
646
|
// the SSM parameters ITS identity tier published (same account,
|
|
636
647
|
// region and stage — the owner deploys first, as with
|
|
637
|
-
// `events[].external`). The region is this stack's
|
|
648
|
+
// `events[].external`). The region is this stack's — `AWS_REGION`,
|
|
649
|
+
// which the reader falls back to, so it is not injected: an external
|
|
638
650
|
// pool in another region is not supported.
|
|
639
651
|
for (const intent of infrastructure.auth ?? []) {
|
|
640
652
|
const prefix = `AUTH_${upperSnake(intent.id)}`;
|
|
@@ -645,21 +657,19 @@ export class VentureAppStack extends cdk.Stack {
|
|
|
645
657
|
this.baseEnvVars[`${prefix}_APP_CLIENT_ID`] = readSsmString(this, identityKeys.primaryClientId(owner, stage, ownerIntent));
|
|
646
658
|
}
|
|
647
659
|
else {
|
|
660
|
+
const canonical = hasCanonicalAuth && intent.id === canonicalAuthId;
|
|
648
661
|
const poolId = imports.userPoolIdsByAuthId?.get(intent.id);
|
|
649
662
|
const clientId = imports.appClientIdsByAuthId?.get(intent.id);
|
|
650
|
-
if (poolId)
|
|
663
|
+
if (poolId && !canonical)
|
|
651
664
|
this.baseEnvVars[`${prefix}_USER_POOL_ID`] = poolId;
|
|
652
|
-
if (clientId)
|
|
665
|
+
if (clientId && !canonical)
|
|
653
666
|
this.baseEnvVars[`${prefix}_APP_CLIENT_ID`] = clientId;
|
|
654
667
|
// The primary client's refresh-token rotation, so `refreshSession`
|
|
655
668
|
// takes the rotating flow (`@venturekit/auth` `loadAuthServerConfig`).
|
|
656
669
|
if (intent.clients?.[0]?.refreshTokenRotation?.enabled) {
|
|
657
|
-
this.baseEnvVars[`${prefix}_REFRESH_TOKEN_ROTATION`] = 'true';
|
|
658
|
-
if (intent === (infrastructure.auth ?? [])[0])
|
|
659
|
-
this.baseEnvVars['COGNITO_REFRESH_TOKEN_ROTATION'] = 'true';
|
|
670
|
+
this.baseEnvVars[canonical ? 'COGNITO_REFRESH_TOKEN_ROTATION' : `${prefix}_REFRESH_TOKEN_ROTATION`] = 'true';
|
|
660
671
|
}
|
|
661
672
|
}
|
|
662
|
-
this.baseEnvVars[`${prefix}_REGION`] = cdk.Stack.of(this).region;
|
|
663
673
|
}
|
|
664
674
|
void hasAnyLambda;
|
|
665
675
|
void networkKeys;
|
|
@@ -695,10 +705,6 @@ export class VentureAppStack extends cdk.Stack {
|
|
|
695
705
|
if (entries.length > 0) {
|
|
696
706
|
const [primaryId, primaryConfigSet] = entries[0];
|
|
697
707
|
this.baseEnvVars['VENTURE_NOTIFY_CONFIG_SET'] = primaryConfigSet;
|
|
698
|
-
const primaryTopicArn = imports.notifyEventsTopicArnsById?.get(primaryId);
|
|
699
|
-
if (primaryTopicArn) {
|
|
700
|
-
this.baseEnvVars['VENTURE_NOTIFY_EVENTS_TOPIC_ARN'] = primaryTopicArn;
|
|
701
|
-
}
|
|
702
708
|
const primaryWhatsapp = imports.whatsappTokenSecretArnsById?.get(primaryId);
|
|
703
709
|
if (primaryWhatsapp) {
|
|
704
710
|
this.baseEnvVars['VENTURE_NOTIFY_WHATSAPP_TOKEN_SECRET'] = primaryWhatsapp;
|
|
@@ -725,13 +731,10 @@ export class VentureAppStack extends cdk.Stack {
|
|
|
725
731
|
primaryNotifyIntent.whatsapp.apiVersion;
|
|
726
732
|
}
|
|
727
733
|
}
|
|
734
|
+
// The events topic feeds the bounce handler's subscription; no
|
|
735
|
+
// function reads its ARN, so it is not injected.
|
|
728
736
|
for (const [id, configSet] of imports.notifyConfigurationSetNamesById) {
|
|
729
|
-
|
|
730
|
-
this.baseEnvVars[`NOTIFY_${idKey}_CONFIG_SET`] = configSet;
|
|
731
|
-
const topicArn = imports.notifyEventsTopicArnsById?.get(id);
|
|
732
|
-
if (topicArn) {
|
|
733
|
-
this.baseEnvVars[`NOTIFY_${idKey}_EVENTS_TOPIC_ARN`] = topicArn;
|
|
734
|
-
}
|
|
737
|
+
this.baseEnvVars[`NOTIFY_${upperSnake(id)}_CONFIG_SET`] = configSet;
|
|
735
738
|
}
|
|
736
739
|
}
|
|
737
740
|
// ─── Service URLs (`services` intents with a `dns`) ────────
|
|
@@ -753,13 +756,15 @@ export class VentureAppStack extends cdk.Stack {
|
|
|
753
756
|
// ─── Event-bus env injection (owned `events` intents) ──────
|
|
754
757
|
// `publishEvent()` resolves the destination bus from
|
|
755
758
|
// `EVENT_BUS_<ID>_NAME`, falling back to `VENTURE_EVENT_BUS_NAME`
|
|
756
|
-
// (the FIRST declared owned bus)
|
|
757
|
-
// (`external.busName`) never
|
|
759
|
+
// (the FIRST declared owned bus) — so the first bus is injected only
|
|
760
|
+
// under that name. Subscriber-only intents (`external.busName`) never
|
|
761
|
+
// publish and so are absent from the map.
|
|
758
762
|
if (imports.eventBusNamesById && imports.eventBusNamesById.size > 0) {
|
|
759
|
-
const [, primaryBusName] = imports.eventBusNamesById.entries().next().value;
|
|
763
|
+
const [primaryBusId, primaryBusName] = imports.eventBusNamesById.entries().next().value;
|
|
760
764
|
this.baseEnvVars['VENTURE_EVENT_BUS_NAME'] = primaryBusName;
|
|
761
765
|
for (const [id, busName] of imports.eventBusNamesById) {
|
|
762
|
-
|
|
766
|
+
if (id !== primaryBusId)
|
|
767
|
+
this.baseEnvVars[`EVENT_BUS_${upperSnake(id)}_NAME`] = busName;
|
|
763
768
|
}
|
|
764
769
|
}
|
|
765
770
|
// ─── Federated provider secret ARNs (auth intents) ─────────
|
|
@@ -991,14 +996,29 @@ export class VentureAppStack extends cdk.Stack {
|
|
|
991
996
|
// deploys touch only the buckets whose contents changed.
|
|
992
997
|
const ROUTES_PER_NESTED = 80;
|
|
993
998
|
const ROUTE_BUCKETS = 8;
|
|
999
|
+
// ─── HTTP API shards, deferred routes ────────────────────
|
|
1000
|
+
// Past 300 public routes they spread over the edge tier's extra
|
|
1001
|
+
// HTTP APIs (`planApiShards`). CloudFormation deletes last, so a
|
|
1002
|
+
// route moving to another API frees its old integration only
|
|
1003
|
+
// after the new ones exist: a brand-new route on an API that
|
|
1004
|
+
// would pass the limit mid-deploy waits for `vk deploy`'s next pass.
|
|
1005
|
+
const publicRoutes = discoveredRoutes.filter((r) => !isInternalRoute(r.apiPath));
|
|
1006
|
+
this.shardPlan = planApiShards(publicRoutes.map((r) => r.apiPath));
|
|
1007
|
+
const deferred = this.deferredRoutes(publicRoutes, props.routeDeferral?.existing);
|
|
1008
|
+
if (props.routeDeferral?.reportFile)
|
|
1009
|
+
fs.writeFileSync(props.routeDeferral.reportFile, JSON.stringify([...deferred], null, 2));
|
|
1010
|
+
if (deferred.size > 0) {
|
|
1011
|
+
cdk.Annotations.of(this).addWarningV2('venturekit:routes-deferred', `${deferred.size} new route(s) wait for the next deploy pass (HTTP API integration limit): ${[...deferred].join(', ')}`);
|
|
1012
|
+
}
|
|
1013
|
+
const routesToCreate = discoveredRoutes.filter((r) => !deferred.has(routeKeyOf(r)));
|
|
994
1014
|
if (discoveredRoutes.length <= ROUTES_PER_NESTED) {
|
|
995
|
-
for (const route of
|
|
1015
|
+
for (const route of routesToCreate) {
|
|
996
1016
|
this.createRouteFunction(route);
|
|
997
1017
|
}
|
|
998
1018
|
}
|
|
999
1019
|
else {
|
|
1000
1020
|
const buckets = Array.from({ length: ROUTE_BUCKETS }, () => []);
|
|
1001
|
-
for (const route of
|
|
1021
|
+
for (const route of routesToCreate) {
|
|
1002
1022
|
const idx = fnv1a32(route.slug) % ROUTE_BUCKETS;
|
|
1003
1023
|
buckets[idx].push(route);
|
|
1004
1024
|
}
|
|
@@ -1129,6 +1149,41 @@ export class VentureAppStack extends cdk.Stack {
|
|
|
1129
1149
|
}
|
|
1130
1150
|
return bundleHandlerCodeWithEsbuild(handlerFile, this.projectDir, this.envConfig.lambda.externalModules ?? []);
|
|
1131
1151
|
}
|
|
1152
|
+
/**
|
|
1153
|
+
* The new routes to hold back this deploy: on each HTTP API, the peak
|
|
1154
|
+
* during the deploy is what it holds now plus what this deploy creates
|
|
1155
|
+
* there (routes moving away are deleted only at the end). Over the
|
|
1156
|
+
* limit, brand-new routes wait; routes moving between APIs never do.
|
|
1157
|
+
*/
|
|
1158
|
+
deferredRoutes(routes, existing) {
|
|
1159
|
+
const deferred = new Set();
|
|
1160
|
+
if (!existing)
|
|
1161
|
+
return deferred;
|
|
1162
|
+
const deployedAnywhere = new Set(Object.values(existing.routesByShard).flat());
|
|
1163
|
+
const byShard = new Map();
|
|
1164
|
+
for (const r of routes) {
|
|
1165
|
+
const shard = this.shardPlan.shardOf(r.apiPath);
|
|
1166
|
+
byShard.set(shard, [...(byShard.get(shard) ?? []), r]);
|
|
1167
|
+
}
|
|
1168
|
+
for (const [shard, planned] of byShard) {
|
|
1169
|
+
const here = new Set(existing.routesByShard[shard] ?? []);
|
|
1170
|
+
const created = planned.filter((r) => !here.has(routeKeyOf(r)));
|
|
1171
|
+
let peak = (existing.integrationsByShard[shard] ?? 0) + created.length;
|
|
1172
|
+
for (const r of created) {
|
|
1173
|
+
if (peak <= HTTP_API_ROUTE_LIMIT)
|
|
1174
|
+
break;
|
|
1175
|
+
if (deployedAnywhere.has(routeKeyOf(r)))
|
|
1176
|
+
continue;
|
|
1177
|
+
deferred.add(routeKeyOf(r));
|
|
1178
|
+
peak--;
|
|
1179
|
+
}
|
|
1180
|
+
if (peak > HTTP_API_ROUTE_LIMIT) {
|
|
1181
|
+
throw new Error(`[venturekit] HTTP API shard ${shard} would hold ${peak} integrations during this deploy ` +
|
|
1182
|
+
`(API Gateway allows ${HTTP_API_ROUTE_LIMIT}), even with every new route held back.`);
|
|
1183
|
+
}
|
|
1184
|
+
}
|
|
1185
|
+
return deferred;
|
|
1186
|
+
}
|
|
1132
1187
|
/**
|
|
1133
1188
|
* Materialise one route handler: a Lambda function + an
|
|
1134
1189
|
* `HttpRoute` on the imported API + an `HttpLambdaIntegration`
|
|
@@ -1140,6 +1195,11 @@ export class VentureAppStack extends cdk.Stack {
|
|
|
1140
1195
|
const lambdaConfig = this.envConfig.lambda;
|
|
1141
1196
|
const functionName = clampLambdaFunctionName(`${this.projectName}-${this.stage}-route-${route.slug}`);
|
|
1142
1197
|
const resourceId = `route-${route.slug}`;
|
|
1198
|
+
// On an extra HTTP API, the custom domain strips the route's top-level
|
|
1199
|
+
// segment: the runtime restores it in `ctx.path` (VENTURE_ROUTE_PREFIX).
|
|
1200
|
+
const internal = isInternalRoute(route.apiPath);
|
|
1201
|
+
const shard = internal ? 0 : this.shardPlan?.shardOf(route.apiPath) ?? 0;
|
|
1202
|
+
const routePrefix = internal ? undefined : this.shardPlan?.prefixOf(route.apiPath);
|
|
1143
1203
|
// Explicit LogGroup, NOT the deprecated `logRetention` prop.
|
|
1144
1204
|
// `logRetention` provisions a stack-wide custom-resource Lambda
|
|
1145
1205
|
// (+ its own IAM role) that calls `PutRetentionPolicy` after
|
|
@@ -1187,6 +1247,7 @@ export class VentureAppStack extends cdk.Stack {
|
|
|
1187
1247
|
...this.baseEnvVars,
|
|
1188
1248
|
...lambdaConfig.environmentVariables,
|
|
1189
1249
|
...this.loginEnvFor(this.roleForRoute(route.apiPath)),
|
|
1250
|
+
...(routePrefix ? { VENTURE_ROUTE_PREFIX: routePrefix } : {}),
|
|
1190
1251
|
},
|
|
1191
1252
|
logGroup,
|
|
1192
1253
|
tracing: this.tracingActive ? lambda.Tracing.ACTIVE : lambda.Tracing.DISABLED,
|
|
@@ -1213,17 +1274,29 @@ export class VentureAppStack extends cdk.Stack {
|
|
|
1213
1274
|
this.routeLambdas.set(route.slug, fn);
|
|
1214
1275
|
// An internal route is on no public API: other ventures invoke its
|
|
1215
1276
|
// function directly (`internalFetch`), so a public request is a 404.
|
|
1216
|
-
if (
|
|
1277
|
+
if (internal)
|
|
1217
1278
|
return;
|
|
1218
|
-
|
|
1279
|
+
const httpApi = shard === 0 ? this.api : this.apiShards.get(shard);
|
|
1280
|
+
if (!httpApi) {
|
|
1281
|
+
throw new Error(`[venturekit] route ${routeKeyOf(route)} belongs to HTTP API shard ${shard}, which the edge tier did not create (imports.apiShards).`);
|
|
1282
|
+
}
|
|
1283
|
+
// Add the HttpRoute on its API. `HttpRouteKey.with`
|
|
1219
1284
|
// builds the canonical `${METHOD} ${path}` string AWS uses
|
|
1220
1285
|
// internally; passing path + method separately keeps us honest
|
|
1221
1286
|
// if AWS ever changes the format.
|
|
1222
|
-
new apigatewayv2.HttpRoute(scope, `${resourceId}-route`, {
|
|
1223
|
-
httpApi
|
|
1224
|
-
routeKey: apigatewayv2.HttpRouteKey.with(route.apiPath, apigatewayv2.HttpMethod[route.method]),
|
|
1287
|
+
const httpRoute = new apigatewayv2.HttpRoute(scope, `${resourceId}-route`, {
|
|
1288
|
+
httpApi,
|
|
1289
|
+
routeKey: apigatewayv2.HttpRouteKey.with(this.shardPlan?.pathOn(route.apiPath) ?? route.apiPath, apigatewayv2.HttpMethod[route.method]),
|
|
1225
1290
|
integration: new apigatewayv2Integrations.HttpLambdaIntegration(`${resourceId}-integration`, fn),
|
|
1226
1291
|
});
|
|
1292
|
+
// What `vk deploy` reads back from the deployed template to count
|
|
1293
|
+
// each API's routes and integrations (`resolveExistingRoutes`).
|
|
1294
|
+
for (const resource of httpRoute.node.findAll()) {
|
|
1295
|
+
if (resource instanceof apigatewayv2.CfnRoute || resource instanceof apigatewayv2.CfnIntegration) {
|
|
1296
|
+
resource.addMetadata('venturekit:apiShard', shard);
|
|
1297
|
+
resource.addMetadata('venturekit:route', routeKeyOf(route));
|
|
1298
|
+
}
|
|
1299
|
+
}
|
|
1227
1300
|
}
|
|
1228
1301
|
/** Every Lambda's groups: its own, and the VPC's internal clients group. */
|
|
1229
1302
|
get lambdaSecurityGroups() {
|