@venturekit/infra 0.0.50 → 0.0.51
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 +55 -4
- package/dist/cdk/app-stack.d.ts.map +1 -1
- package/dist/cdk/app-stack.js +181 -33
- package/dist/cdk/app-stack.js.map +1 -1
- package/dist/cdk/compute-stack.d.ts +3 -0
- package/dist/cdk/compute-stack.d.ts.map +1 -1
- package/dist/cdk/compute-stack.js +16 -1
- package/dist/cdk/compute-stack.js.map +1 -1
- package/dist/cdk/config-stack.d.ts.map +1 -1
- package/dist/cdk/config-stack.js +2 -0
- package/dist/cdk/config-stack.js.map +1 -1
- package/dist/cdk/data-stack.d.ts +15 -1
- package/dist/cdk/data-stack.d.ts.map +1 -1
- package/dist/cdk/data-stack.js +120 -18
- package/dist/cdk/data-stack.js.map +1 -1
- package/dist/cdk/edge-stack.d.ts +2 -0
- package/dist/cdk/edge-stack.d.ts.map +1 -1
- package/dist/cdk/edge-stack.js +15 -0
- package/dist/cdk/edge-stack.js.map +1 -1
- package/dist/cdk/identity-stack.d.ts.map +1 -1
- package/dist/cdk/identity-stack.js +13 -3
- package/dist/cdk/identity-stack.js.map +1 -1
- package/dist/cdk/migration-runner.d.ts +16 -0
- package/dist/cdk/migration-runner.d.ts.map +1 -1
- package/dist/cdk/migration-runner.js +22 -2
- package/dist/cdk/migration-runner.js.map +1 -1
- package/dist/cdk/network-stack.d.ts +8 -0
- package/dist/cdk/network-stack.d.ts.map +1 -1
- package/dist/cdk/network-stack.js +20 -0
- package/dist/cdk/network-stack.js.map +1 -1
- package/dist/cdk/services-stack.d.ts +5 -0
- package/dist/cdk/services-stack.d.ts.map +1 -1
- package/dist/cdk/services-stack.js +30 -5
- package/dist/cdk/services-stack.js.map +1 -1
- package/dist/cdk/shared/admin-routes.d.ts +8 -9
- package/dist/cdk/shared/admin-routes.d.ts.map +1 -1
- package/dist/cdk/shared/admin-routes.js +12 -38
- package/dist/cdk/shared/admin-routes.js.map +1 -1
- package/dist/cdk/shared/internal-routes.d.ts +17 -0
- package/dist/cdk/shared/internal-routes.d.ts.map +1 -0
- package/dist/cdk/shared/internal-routes.js +127 -0
- package/dist/cdk/shared/internal-routes.js.map +1 -0
- package/dist/cdk/shared/lambda-helpers.d.ts +1 -14
- package/dist/cdk/shared/lambda-helpers.d.ts.map +1 -1
- package/dist/cdk/shared/lambda-helpers.js +2 -24
- package/dist/cdk/shared/lambda-helpers.js.map +1 -1
- package/dist/cdk/shared/ssm-keys.d.ts +50 -4
- package/dist/cdk/shared/ssm-keys.d.ts.map +1 -1
- package/dist/cdk/shared/ssm-keys.js +30 -2
- package/dist/cdk/shared/ssm-keys.js.map +1 -1
- package/dist/cdk/shared/websocket-construct.d.ts +8 -0
- package/dist/cdk/shared/websocket-construct.d.ts.map +1 -1
- package/dist/cdk/shared/websocket-construct.js +7 -2
- package/dist/cdk/shared/websocket-construct.js.map +1 -1
- package/dist/cdk/shared-network-stack.d.ts +44 -0
- package/dist/cdk/shared-network-stack.d.ts.map +1 -0
- package/dist/cdk/shared-network-stack.js +61 -0
- package/dist/cdk/shared-network-stack.js.map +1 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -0
- package/dist/index.js.map +1 -1
- package/dist/venture.d.ts +8 -1
- package/dist/venture.d.ts.map +1 -1
- package/dist/venture.js +9 -0
- package/dist/venture.js.map +1 -1
- package/package.json +2 -2
package/dist/cdk/app-stack.d.ts
CHANGED
|
@@ -87,6 +87,12 @@ export interface AppStackImports {
|
|
|
87
87
|
* functions.
|
|
88
88
|
*/
|
|
89
89
|
vpc?: ec2.IVpc;
|
|
90
|
+
/**
|
|
91
|
+
* The VPC's INTERNAL CLIENTS security group (network tier): every Lambda
|
|
92
|
+
* joins it, which is what admits it to the VPC's internal service ports
|
|
93
|
+
* (`expose: 'vpc'`) — its own venture's and, in a shared VPC, the others'.
|
|
94
|
+
*/
|
|
95
|
+
internalClientsSecurityGroupId?: string;
|
|
90
96
|
/**
|
|
91
97
|
* HttpApi imported from the edge stack via
|
|
92
98
|
* `HttpApi.fromHttpApiAttributes({ httpApiId, apiEndpoint })`.
|
|
@@ -218,7 +224,12 @@ export interface AppStackImports {
|
|
|
218
224
|
host: string;
|
|
219
225
|
port: string;
|
|
220
226
|
name: string;
|
|
227
|
+
/** The secret functions connect with — the APP login when provisioned. */
|
|
221
228
|
secretArn?: string;
|
|
229
|
+
/** The SYSTEM login's secret — only the functions `systemFunctions` selects read it. */
|
|
230
|
+
systemSecretArn?: string;
|
|
231
|
+
/** `databases[].logins.system.functions` patterns. */
|
|
232
|
+
systemFunctions?: string[];
|
|
222
233
|
}>;
|
|
223
234
|
/**
|
|
224
235
|
* Per-database connection params (RDS SG id + numeric port) used
|
|
@@ -362,10 +373,26 @@ export declare class VentureAppStack extends cdk.Stack {
|
|
|
362
373
|
* single-role layout, where the shared role holds the admin grants.
|
|
363
374
|
*/
|
|
364
375
|
readonly authAdminRole?: iam.Role;
|
|
376
|
+
/**
|
|
377
|
+
* Execution roles of the functions that connect as the SYSTEM database
|
|
378
|
+
* login (`databases[].logins.system.functions`): the only roles that may
|
|
379
|
+
* read its secret. Kept apart from the shared role so no app-login
|
|
380
|
+
* function — whatever runs in it — can fetch the system credential.
|
|
381
|
+
*/
|
|
382
|
+
readonly dbSystemRole?: iam.Role;
|
|
383
|
+
readonly authAdminDbSystemRole?: iam.Role;
|
|
384
|
+
/** `logins.system.functions` of the primary database. */
|
|
385
|
+
private readonly systemLoginPatterns;
|
|
386
|
+
/** The primary database's two secrets, when the two logins are provisioned. */
|
|
387
|
+
private readonly dbLoginSecrets?;
|
|
365
388
|
/** `adminRoutes` patterns collected across every auth intent. */
|
|
366
389
|
private readonly adminRoutePatterns;
|
|
390
|
+
/** `auth[].adminRoutes: 'all'` — the explicit legacy layout (admin grants on the shared role). */
|
|
391
|
+
private readonly legacyAdminGrants;
|
|
367
392
|
/** Shared SG when a VPC is imported; undefined for VPC-less projects. */
|
|
368
393
|
readonly lambdaSecurityGroup?: ec2.SecurityGroup;
|
|
394
|
+
/** The VPC's internal clients group (see `AppStackImports.internalClientsSecurityGroupId`). */
|
|
395
|
+
readonly internalClientsSecurityGroup?: ec2.ISecurityGroup;
|
|
369
396
|
/** Internal HMAC signing secret for Lambda-to-Lambda `invoke()`. */
|
|
370
397
|
readonly internalHmacSecret: secretsmanager.Secret;
|
|
371
398
|
/**
|
|
@@ -490,23 +517,47 @@ export declare class VentureAppStack extends cdk.Stack {
|
|
|
490
517
|
* cross-stack pattern works the same as in-stack.
|
|
491
518
|
*/
|
|
492
519
|
private createRouteFunction;
|
|
520
|
+
/** Every Lambda's groups: its own, and the VPC's internal clients group. */
|
|
521
|
+
private get lambdaSecurityGroups();
|
|
493
522
|
/**
|
|
494
523
|
* Every execution role in this stack: the shared role, plus the
|
|
495
524
|
* auth-admin role when one exists. Baseline grants (secrets, S3,
|
|
496
525
|
* SES, rate-limit table, …) are applied to all of them.
|
|
497
526
|
*/
|
|
498
527
|
private get executionRoles();
|
|
528
|
+
/** The roles whose functions connect as the system database login. */
|
|
529
|
+
private get systemLoginRoles();
|
|
530
|
+
/**
|
|
531
|
+
* The role for a function: Cognito admin or not (`auth[].adminRoutes`),
|
|
532
|
+
* system database login or not (`databases[].logins.system.functions`).
|
|
533
|
+
*/
|
|
534
|
+
private roleFor;
|
|
535
|
+
/** The database env a function running as `role` gets on top of the base env. */
|
|
536
|
+
private loginEnvFor;
|
|
499
537
|
/**
|
|
500
|
-
* Roles that receive the Cognito admin grants:
|
|
501
|
-
*
|
|
502
|
-
*
|
|
538
|
+
* Roles that receive the Cognito admin grants: the shared role under
|
|
539
|
+
* the explicit legacy layout (`adminRoutes: 'all'`), the auth-admin role
|
|
540
|
+
* when routes are listed, and none otherwise.
|
|
503
541
|
*/
|
|
504
542
|
private get cognitoAdminRoles();
|
|
505
543
|
/** Apply one grant to every execution role. */
|
|
506
544
|
private grantEachRole;
|
|
545
|
+
/**
|
|
546
|
+
* Caches: the data stack's cache security group admits THIS stack's
|
|
547
|
+
* Lambda security group only, and every Lambda gets the endpoint and
|
|
548
|
+
* its AUTH token's secret (`VENTURE_CACHE_<ID>_HOST` / `_PORT` /
|
|
549
|
+
* `_AUTH_SECRET_ARN`; `cacheConnection(id)` in `@venturekit/runtime`
|
|
550
|
+
* turns them into TLS + AUTH connection options).
|
|
551
|
+
*/
|
|
552
|
+
private wireCaches;
|
|
553
|
+
/**
|
|
554
|
+
* Internal routes (`internal` intent): the pair secrets this venture keeps
|
|
555
|
+
* for its callers, and the rights to call the ventures it calls.
|
|
556
|
+
*/
|
|
557
|
+
private wireInternalRoutes;
|
|
507
558
|
/** The role a route Lambda runs as — auth-admin when its API path matches `adminRoutes`. */
|
|
508
559
|
private roleForRoute;
|
|
509
|
-
/** The role a standalone / queue / schedule Lambda runs as
|
|
560
|
+
/** The role a standalone / queue / schedule Lambda runs as (`fn:<id>`). */
|
|
510
561
|
private roleForFunction;
|
|
511
562
|
/**
|
|
512
563
|
* Build a Lambda function with the standard app-stack properties
|
|
@@ -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,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B;;;;;;;;;;;;;;;;;;;;;;OAsBG;IACH,OAAO,CAAC,mBAAmB;IA0Q3B;;;;;;;;;;;;;;;;;;OAkBG;IACH,OAAO,CAAC,uBAAuB;CAsKhC"}
|
package/dist/cdk/app-stack.js
CHANGED
|
@@ -87,11 +87,13 @@ import * as cloudwatchActions from 'aws-cdk-lib/aws-cloudwatch-actions';
|
|
|
87
87
|
import * as secretsmanager from 'aws-cdk-lib/aws-secretsmanager';
|
|
88
88
|
import * as logs from 'aws-cdk-lib/aws-logs';
|
|
89
89
|
import { DATA_SAFETY_CONFIG, isExternalAuthIntent, } from '@venturekit/core';
|
|
90
|
-
import { collectAdminRoutePatterns, matchesAdminRoute } from './shared/admin-routes.js';
|
|
91
|
-
import {
|
|
90
|
+
import { collectAdminRoutePatterns, matchesAdminRoute, usesLegacyAdminGrants } from './shared/admin-routes.js';
|
|
91
|
+
import { isInternalRoute, matchesFunctionPattern } from '@venturekit/core';
|
|
92
|
+
import { createInternalCallerSecrets, internalCallStatements } from './shared/internal-routes.js';
|
|
93
|
+
import { readSsmString, writeSsm } from './shared/cross-stack-refs.js';
|
|
92
94
|
import { APPLICATION_SIGNALS_POLICY, defaultOtelLayerArn, otelEnvironment } from './shared/otel-layer.js';
|
|
93
95
|
import { grantCustomSenderInvoke, resolveCustomSender } from './shared/custom-sender.js';
|
|
94
|
-
import { networkKeys, edgeKeys, identityKeys, dataKeys } from './shared/ssm-keys.js';
|
|
96
|
+
import { networkKeys, edgeKeys, identityKeys, dataKeys, internalKeys } from './shared/ssm-keys.js';
|
|
95
97
|
import { bundleHandlerCodeWithEsbuild, inlineStubLambdaCode, toLambdaArchitecture, toLambdaRuntime, toLogRetention, clampLambdaFunctionName, uniqueLogGroupName, discoverFunctionFiles, } from './shared/lambda-helpers.js';
|
|
96
98
|
import { discoverRouteFiles, } from './shared/route-discovery.js';
|
|
97
99
|
import { discoverWsRoutes } from './shared/ws-discovery.js';
|
|
@@ -169,10 +171,26 @@ export class VentureAppStack extends cdk.Stack {
|
|
|
169
171
|
* single-role layout, where the shared role holds the admin grants.
|
|
170
172
|
*/
|
|
171
173
|
authAdminRole;
|
|
174
|
+
/**
|
|
175
|
+
* Execution roles of the functions that connect as the SYSTEM database
|
|
176
|
+
* login (`databases[].logins.system.functions`): the only roles that may
|
|
177
|
+
* read its secret. Kept apart from the shared role so no app-login
|
|
178
|
+
* function — whatever runs in it — can fetch the system credential.
|
|
179
|
+
*/
|
|
180
|
+
dbSystemRole;
|
|
181
|
+
authAdminDbSystemRole;
|
|
182
|
+
/** `logins.system.functions` of the primary database. */
|
|
183
|
+
systemLoginPatterns;
|
|
184
|
+
/** The primary database's two secrets, when the two logins are provisioned. */
|
|
185
|
+
dbLoginSecrets;
|
|
172
186
|
/** `adminRoutes` patterns collected across every auth intent. */
|
|
173
187
|
adminRoutePatterns;
|
|
188
|
+
/** `auth[].adminRoutes: 'all'` — the explicit legacy layout (admin grants on the shared role). */
|
|
189
|
+
legacyAdminGrants;
|
|
174
190
|
/** Shared SG when a VPC is imported; undefined for VPC-less projects. */
|
|
175
191
|
lambdaSecurityGroup;
|
|
192
|
+
/** The VPC's internal clients group (see `AppStackImports.internalClientsSecurityGroupId`). */
|
|
193
|
+
internalClientsSecurityGroup;
|
|
176
194
|
/** Internal HMAC signing secret for Lambda-to-Lambda `invoke()`. */
|
|
177
195
|
internalHmacSecret;
|
|
178
196
|
/**
|
|
@@ -360,7 +378,13 @@ export class VentureAppStack extends cdk.Stack {
|
|
|
360
378
|
// CFN's 500-resource limit on large projects is the reason the
|
|
361
379
|
// per-function layout was never adopted.
|
|
362
380
|
this.adminRoutePatterns = collectAdminRoutePatterns(infrastructure.auth ?? []);
|
|
363
|
-
|
|
381
|
+
this.legacyAdminGrants = usesLegacyAdminGrants(infrastructure.auth ?? []);
|
|
382
|
+
if (this.legacyAdminGrants) {
|
|
383
|
+
cdk.Annotations.of(this).addWarning(`[venturekit] auth[].adminRoutes is 'all': every Lambda in ${projectName}/${stage} shares one role ` +
|
|
384
|
+
`that can create users, set passwords and edit attributes on the user pool. List the routes that ` +
|
|
385
|
+
`call @venturekit/auth/server admin flows (e.g. adminRoutes: ['/auth/**']) to confine those grants.`);
|
|
386
|
+
}
|
|
387
|
+
else if (this.adminRoutePatterns.length > 0) {
|
|
364
388
|
this.authAdminRole = new iam.Role(this, 'AuthAdminRole', {
|
|
365
389
|
assumedBy: new iam.ServicePrincipal('lambda.amazonaws.com'),
|
|
366
390
|
description: `Execution role for ${projectName}-${stage} Lambdas allowed to call Cognito admin APIs (auth[].adminRoutes)`,
|
|
@@ -370,10 +394,26 @@ export class VentureAppStack extends cdk.Stack {
|
|
|
370
394
|
});
|
|
371
395
|
}
|
|
372
396
|
else if ((infrastructure.auth ?? []).length > 0) {
|
|
373
|
-
cdk.Annotations.of(this).
|
|
374
|
-
`
|
|
375
|
-
`
|
|
376
|
-
|
|
397
|
+
cdk.Annotations.of(this).addInfo(`[venturekit] auth intents declare no 'adminRoutes': no Lambda in ${projectName}/${stage} can call ` +
|
|
398
|
+
`Cognito admin APIs. Routes that run @venturekit/auth/server admin flows (sign-up, federated ` +
|
|
399
|
+
`sign-in, password reset, …) must be listed in auth[].adminRoutes.`);
|
|
400
|
+
}
|
|
401
|
+
// ─── System-login execution roles (databases[].logins) ──────
|
|
402
|
+
const primaryDb = imports.databaseEndpointsById?.values().next().value;
|
|
403
|
+
this.systemLoginPatterns = (primaryDb?.systemFunctions ?? []).map((p) => p.trim()).filter(Boolean);
|
|
404
|
+
if (primaryDb?.secretArn && primaryDb.systemSecretArn) {
|
|
405
|
+
this.dbLoginSecrets = { app: primaryDb.secretArn, system: primaryDb.systemSecretArn };
|
|
406
|
+
}
|
|
407
|
+
if (this.dbLoginSecrets && this.systemLoginPatterns.length > 0) {
|
|
408
|
+
const executionRole = (id, description) => new iam.Role(this, id, {
|
|
409
|
+
assumedBy: new iam.ServicePrincipal('lambda.amazonaws.com'),
|
|
410
|
+
description,
|
|
411
|
+
managedPolicies: [iam.ManagedPolicy.fromAwsManagedPolicyName('service-role/AWSLambdaBasicExecutionRole')],
|
|
412
|
+
});
|
|
413
|
+
this.dbSystemRole = executionRole('DbSystemRole', `Execution role for ${projectName}-${stage} Lambdas on the system database login (databases[].logins.system)`);
|
|
414
|
+
if (this.authAdminRole) {
|
|
415
|
+
this.authAdminDbSystemRole = executionRole('AuthAdminDbSystemRole', `Execution role for ${projectName}-${stage} Lambdas with Cognito admin grants on the system database login`);
|
|
416
|
+
}
|
|
377
417
|
}
|
|
378
418
|
if (otel?.applicationSignals) {
|
|
379
419
|
// CloudWatch Application Signals: the layer publishes service
|
|
@@ -389,6 +429,9 @@ export class VentureAppStack extends cdk.Stack {
|
|
|
389
429
|
for (const role of this.executionRoles) {
|
|
390
430
|
role.addManagedPolicy(iam.ManagedPolicy.fromAwsManagedPolicyName('service-role/AWSLambdaVPCAccessExecutionRole'));
|
|
391
431
|
}
|
|
432
|
+
if (imports.internalClientsSecurityGroupId) {
|
|
433
|
+
this.internalClientsSecurityGroup = ec2.SecurityGroup.fromSecurityGroupId(this, 'InternalClientsSg', imports.internalClientsSecurityGroupId);
|
|
434
|
+
}
|
|
392
435
|
this.lambdaSecurityGroup = new ec2.SecurityGroup(this, 'LambdaSg', {
|
|
393
436
|
vpc: this.vpc,
|
|
394
437
|
description: `Shared SG for ${projectName}-${stage} Lambdas`,
|
|
@@ -508,6 +551,9 @@ export class VentureAppStack extends cdk.Stack {
|
|
|
508
551
|
})
|
|
509
552
|
: {}),
|
|
510
553
|
};
|
|
554
|
+
// Caches need the env map (endpoint + AUTH secret) and the Lambda SG.
|
|
555
|
+
this.wireCaches(infrastructure.caches ?? [], projectName, stage);
|
|
556
|
+
this.wireInternalRoutes(infrastructure.internal, projectName, stage);
|
|
511
557
|
// ─── Cross-tier env injection (cheap, static keys only) ────
|
|
512
558
|
// Per-intent keys go through helpers in sub-steps 9b/c/d. The
|
|
513
559
|
// ones below are stack-wide singletons — primary DB, primary
|
|
@@ -534,6 +580,11 @@ export class VentureAppStack extends cdk.Stack {
|
|
|
534
580
|
if (primaryIntent?.tenantRole) {
|
|
535
581
|
this.baseEnvVars['DB_TENANT_ROLE'] = primaryIntent.tenantRole;
|
|
536
582
|
}
|
|
583
|
+
// Two logins: every function is on the APP login unless its role is a
|
|
584
|
+
// system-login one (`loginEnvFor` switches the secret and DB_LOGIN).
|
|
585
|
+
if (primary.systemSecretArn) {
|
|
586
|
+
this.baseEnvVars['DB_LOGIN'] = 'app';
|
|
587
|
+
}
|
|
537
588
|
}
|
|
538
589
|
if (imports.storageBucketNamesById && imports.storageBucketNamesById.size > 0) {
|
|
539
590
|
const [, primaryBucket] = imports.storageBucketNamesById.entries().next().value;
|
|
@@ -598,6 +649,13 @@ export class VentureAppStack extends cdk.Stack {
|
|
|
598
649
|
this.baseEnvVars[`${prefix}_USER_POOL_ID`] = poolId;
|
|
599
650
|
if (clientId)
|
|
600
651
|
this.baseEnvVars[`${prefix}_APP_CLIENT_ID`] = clientId;
|
|
652
|
+
// The primary client's refresh-token rotation, so `refreshSession`
|
|
653
|
+
// takes the rotating flow (`@venturekit/auth` `loadAuthServerConfig`).
|
|
654
|
+
if (intent.clients?.[0]?.refreshTokenRotation?.enabled) {
|
|
655
|
+
this.baseEnvVars[`${prefix}_REFRESH_TOKEN_ROTATION`] = 'true';
|
|
656
|
+
if (intent === (infrastructure.auth ?? [])[0])
|
|
657
|
+
this.baseEnvVars['COGNITO_REFRESH_TOKEN_ROTATION'] = 'true';
|
|
658
|
+
}
|
|
601
659
|
}
|
|
602
660
|
this.baseEnvVars[`${prefix}_REGION`] = cdk.Stack.of(this).region;
|
|
603
661
|
}
|
|
@@ -754,14 +812,14 @@ export class VentureAppStack extends cdk.Stack {
|
|
|
754
812
|
this.baseEnvVars['COGNITO_CUSTOM_SENDER_KMS_KEY_ARN'] ??= keyArn;
|
|
755
813
|
}
|
|
756
814
|
// ─── Billing provider secret ARNs (billing intents) ─────
|
|
757
|
-
// `@venturekit/billing`'s
|
|
815
|
+
// `@venturekit/billing`'s resolveManzaConfig() reads the API key,
|
|
758
816
|
// account id, and webhook secret from the Secrets Manager entry named
|
|
759
|
-
// by `
|
|
817
|
+
// by `MANZA_SECRET_ARN`. Inject it here — the matching read grant is
|
|
760
818
|
// attached in applyImportedGrants — so a project that declares a
|
|
761
819
|
// billing intent needs no wiring of its own.
|
|
762
820
|
//
|
|
763
821
|
// The env var name is derived from the provider, not the intent id,
|
|
764
|
-
// because the runtime resolver is provider-scoped (one
|
|
822
|
+
// because the runtime resolver is provider-scoped (one Manza account
|
|
765
823
|
// per stage). The first declared intent for a given provider wins,
|
|
766
824
|
// mirroring COGNITO_FEDERATED_<PROVIDER>_SECRET_ARN.
|
|
767
825
|
if (imports.billingSecretArnsById) {
|
|
@@ -769,7 +827,9 @@ export class VentureAppStack extends cdk.Stack {
|
|
|
769
827
|
const intent = infrastructure.billing?.find((b) => b.id === id);
|
|
770
828
|
if (!intent)
|
|
771
829
|
continue;
|
|
772
|
-
|
|
830
|
+
// `'zazu'` is the deprecated name of `'manza'`.
|
|
831
|
+
const provider = intent.provider === 'zazu' ? 'manza' : intent.provider;
|
|
832
|
+
const key = `${provider.toUpperCase()}_SECRET_ARN`;
|
|
773
833
|
if (!(key in this.baseEnvVars)) {
|
|
774
834
|
this.baseEnvVars[key] = arn;
|
|
775
835
|
}
|
|
@@ -816,7 +876,11 @@ export class VentureAppStack extends cdk.Stack {
|
|
|
816
876
|
stage,
|
|
817
877
|
envConfig,
|
|
818
878
|
lambdaRole: this.lambdaRole,
|
|
879
|
+
roleFor: (routeKey) => this.roleFor({ wsRoute: routeKey }),
|
|
880
|
+
envFor: (routeKey) => this.loginEnvFor(this.roleFor({ wsRoute: routeKey })),
|
|
881
|
+
extraRoles: this.executionRoles.filter((r) => r !== this.lambdaRole),
|
|
819
882
|
lambdaSecurityGroup: this.lambdaSecurityGroup,
|
|
883
|
+
extraSecurityGroups: this.internalClientsSecurityGroup ? [this.internalClientsSecurityGroup] : [],
|
|
820
884
|
vpc: this.vpc,
|
|
821
885
|
baseEnvVars: this.baseEnvVars,
|
|
822
886
|
skipBundling: this.skipBundling,
|
|
@@ -1120,6 +1184,7 @@ export class VentureAppStack extends cdk.Stack {
|
|
|
1120
1184
|
environment: {
|
|
1121
1185
|
...this.baseEnvVars,
|
|
1122
1186
|
...lambdaConfig.environmentVariables,
|
|
1187
|
+
...this.loginEnvFor(this.roleForRoute(route.apiPath)),
|
|
1123
1188
|
},
|
|
1124
1189
|
logGroup,
|
|
1125
1190
|
tracing: this.tracingActive ? lambda.Tracing.ACTIVE : lambda.Tracing.DISABLED,
|
|
@@ -1133,7 +1198,7 @@ export class VentureAppStack extends cdk.Stack {
|
|
|
1133
1198
|
? {
|
|
1134
1199
|
vpc: this.vpc,
|
|
1135
1200
|
vpcSubnets: { subnetType: ec2.SubnetType.PRIVATE_WITH_EGRESS },
|
|
1136
|
-
securityGroups:
|
|
1201
|
+
securityGroups: this.lambdaSecurityGroups,
|
|
1137
1202
|
}
|
|
1138
1203
|
: {}),
|
|
1139
1204
|
});
|
|
@@ -1144,6 +1209,10 @@ export class VentureAppStack extends cdk.Stack {
|
|
|
1144
1209
|
cdk.Tags.of(fn).add('deployedAt', this.deployedAt);
|
|
1145
1210
|
cdk.Tags.of(logGroup).add('deployedAt', this.deployedAt);
|
|
1146
1211
|
this.routeLambdas.set(route.slug, fn);
|
|
1212
|
+
// An internal route is on no public API: other ventures invoke its
|
|
1213
|
+
// function directly (`internalFetch`), so a public request is a 404.
|
|
1214
|
+
if (isInternalRoute(route.apiPath))
|
|
1215
|
+
return;
|
|
1147
1216
|
// Add the HttpRoute on the imported API. `HttpRouteKey.with`
|
|
1148
1217
|
// builds the canonical `${METHOD} ${path}` string AWS uses
|
|
1149
1218
|
// internally; passing path + method separately keeps us honest
|
|
@@ -1154,40 +1223,110 @@ export class VentureAppStack extends cdk.Stack {
|
|
|
1154
1223
|
integration: new apigatewayv2Integrations.HttpLambdaIntegration(`${resourceId}-integration`, fn),
|
|
1155
1224
|
});
|
|
1156
1225
|
}
|
|
1226
|
+
/** Every Lambda's groups: its own, and the VPC's internal clients group. */
|
|
1227
|
+
get lambdaSecurityGroups() {
|
|
1228
|
+
return [this.lambdaSecurityGroup, ...(this.internalClientsSecurityGroup ? [this.internalClientsSecurityGroup] : [])];
|
|
1229
|
+
}
|
|
1157
1230
|
/**
|
|
1158
1231
|
* Every execution role in this stack: the shared role, plus the
|
|
1159
1232
|
* auth-admin role when one exists. Baseline grants (secrets, S3,
|
|
1160
1233
|
* SES, rate-limit table, …) are applied to all of them.
|
|
1161
1234
|
*/
|
|
1162
1235
|
get executionRoles() {
|
|
1163
|
-
return
|
|
1236
|
+
return [this.lambdaRole, this.authAdminRole, this.dbSystemRole, this.authAdminDbSystemRole].filter((r) => r !== undefined);
|
|
1237
|
+
}
|
|
1238
|
+
/** The roles whose functions connect as the system database login. */
|
|
1239
|
+
get systemLoginRoles() {
|
|
1240
|
+
return [this.dbSystemRole, this.authAdminDbSystemRole].filter((r) => r !== undefined);
|
|
1164
1241
|
}
|
|
1165
1242
|
/**
|
|
1166
|
-
*
|
|
1167
|
-
*
|
|
1168
|
-
|
|
1243
|
+
* The role for a function: Cognito admin or not (`auth[].adminRoutes`),
|
|
1244
|
+
* system database login or not (`databases[].logins.system.functions`).
|
|
1245
|
+
*/
|
|
1246
|
+
roleFor(subject) {
|
|
1247
|
+
const admin = Boolean(this.authAdminRole) && matchesAdminRoute(this.adminRoutePatterns, subject);
|
|
1248
|
+
const system = Boolean(this.dbSystemRole) && matchesFunctionPattern(this.systemLoginPatterns, subject);
|
|
1249
|
+
if (admin && system)
|
|
1250
|
+
return this.authAdminDbSystemRole;
|
|
1251
|
+
if (admin)
|
|
1252
|
+
return this.authAdminRole;
|
|
1253
|
+
if (system)
|
|
1254
|
+
return this.dbSystemRole;
|
|
1255
|
+
return this.lambdaRole;
|
|
1256
|
+
}
|
|
1257
|
+
/** The database env a function running as `role` gets on top of the base env. */
|
|
1258
|
+
loginEnvFor(role) {
|
|
1259
|
+
if (!this.dbLoginSecrets || !role || !this.systemLoginRoles.includes(role))
|
|
1260
|
+
return {};
|
|
1261
|
+
return { DB_SECRET_ARN: this.dbLoginSecrets.system, DB_LOGIN: 'system' };
|
|
1262
|
+
}
|
|
1263
|
+
/**
|
|
1264
|
+
* Roles that receive the Cognito admin grants: the shared role under
|
|
1265
|
+
* the explicit legacy layout (`adminRoutes: 'all'`), the auth-admin role
|
|
1266
|
+
* when routes are listed, and none otherwise.
|
|
1169
1267
|
*/
|
|
1170
1268
|
get cognitoAdminRoles() {
|
|
1171
|
-
|
|
1269
|
+
if (this.legacyAdminGrants)
|
|
1270
|
+
return [this.lambdaRole, ...(this.dbSystemRole ? [this.dbSystemRole] : [])];
|
|
1271
|
+
return [this.authAdminRole, this.authAdminDbSystemRole].filter((r) => r !== undefined);
|
|
1172
1272
|
}
|
|
1173
1273
|
/** Apply one grant to every execution role. */
|
|
1174
1274
|
grantEachRole(grant) {
|
|
1175
1275
|
for (const role of this.executionRoles)
|
|
1176
1276
|
grant(role);
|
|
1177
1277
|
}
|
|
1278
|
+
/**
|
|
1279
|
+
* Caches: the data stack's cache security group admits THIS stack's
|
|
1280
|
+
* Lambda security group only, and every Lambda gets the endpoint and
|
|
1281
|
+
* its AUTH token's secret (`VENTURE_CACHE_<ID>_HOST` / `_PORT` /
|
|
1282
|
+
* `_AUTH_SECRET_ARN`; `cacheConnection(id)` in `@venturekit/runtime`
|
|
1283
|
+
* turns them into TLS + AUTH connection options).
|
|
1284
|
+
*/
|
|
1285
|
+
wireCaches(caches, projectName, stage) {
|
|
1286
|
+
if (!this.lambdaSecurityGroup)
|
|
1287
|
+
return;
|
|
1288
|
+
for (const cache of caches) {
|
|
1289
|
+
const cacheSg = ec2.SecurityGroup.fromSecurityGroupId(this, `imported-cache-sg-${cache.id}`, readSsmString(this, dataKeys.cacheSecurityGroupId(projectName, stage, cache.id)), { mutable: true });
|
|
1290
|
+
cacheSg.connections.allowFrom(this.lambdaSecurityGroup, ec2.Port.tcp(6379), `Allow ${projectName}-${stage} Lambdas to connect to cache ${cache.id}`);
|
|
1291
|
+
const prefix = `VENTURE_CACHE_${upperSnake(cache.id)}`;
|
|
1292
|
+
const secretArn = readSsmString(this, dataKeys.cacheAuthSecretArn(projectName, stage, cache.id));
|
|
1293
|
+
this.baseEnvVars[`${prefix}_HOST`] = readSsmString(this, dataKeys.cacheEndpoint(projectName, stage, cache.id));
|
|
1294
|
+
this.baseEnvVars[`${prefix}_PORT`] = readSsmString(this, dataKeys.cachePort(projectName, stage, cache.id));
|
|
1295
|
+
this.baseEnvVars[`${prefix}_AUTH_SECRET_ARN`] = secretArn;
|
|
1296
|
+
const secret = secretsmanager.Secret.fromSecretCompleteArn(this, `imported-cache-auth-${cache.id}`, secretArn);
|
|
1297
|
+
this.grantEachRole((role) => secret.grantRead(role));
|
|
1298
|
+
}
|
|
1299
|
+
}
|
|
1300
|
+
/**
|
|
1301
|
+
* Internal routes (`internal` intent): the pair secrets this venture keeps
|
|
1302
|
+
* for its callers, and the rights to call the ventures it calls.
|
|
1303
|
+
*/
|
|
1304
|
+
wireInternalRoutes(internal, projectName, stage) {
|
|
1305
|
+
const secrets = createInternalCallerSecrets(this, projectName, stage, internal, this.isStrictRetain);
|
|
1306
|
+
if (secrets.size > 0) {
|
|
1307
|
+
for (const [caller, secret] of secrets) {
|
|
1308
|
+
this.grantEachRole((role) => secret.grantRead(role));
|
|
1309
|
+
// What the caller's `vk deploy` checks before deploying (`verifyInternalCalls`).
|
|
1310
|
+
writeSsm(this, internalKeys.callerSecretArn(projectName, stage, caller), secret.secretArn, {
|
|
1311
|
+
description: `Pair secret ${caller} → ${projectName} internal routes`,
|
|
1312
|
+
});
|
|
1313
|
+
}
|
|
1314
|
+
this.baseEnvVars.VENTURE_INTERNAL_CALLER_SECRET_ARNS = JSON.stringify(Object.fromEntries([...secrets].map(([caller, secret]) => [caller, secret.secretArn])));
|
|
1315
|
+
// Who may call — what a caller's `vk deploy` checks it is part of.
|
|
1316
|
+
writeSsm(this, internalKeys.callers(projectName, stage), [...secrets.keys()].join(','), {
|
|
1317
|
+
description: `Ventures allowed to call ${projectName} internal routes`,
|
|
1318
|
+
});
|
|
1319
|
+
}
|
|
1320
|
+
const statements = internalCallStatements(this, projectName, stage, internal);
|
|
1321
|
+
this.grantEachRole((role) => statements.forEach((s) => role.addToPolicy(s)));
|
|
1322
|
+
}
|
|
1178
1323
|
/** The role a route Lambda runs as — auth-admin when its API path matches `adminRoutes`. */
|
|
1179
1324
|
roleForRoute(apiPath) {
|
|
1180
|
-
|
|
1181
|
-
return this.authAdminRole;
|
|
1182
|
-
}
|
|
1183
|
-
return this.lambdaRole;
|
|
1325
|
+
return this.roleFor({ apiPath });
|
|
1184
1326
|
}
|
|
1185
|
-
/** The role a standalone / queue / schedule Lambda runs as
|
|
1327
|
+
/** The role a standalone / queue / schedule Lambda runs as (`fn:<id>`). */
|
|
1186
1328
|
roleForFunction(id) {
|
|
1187
|
-
|
|
1188
|
-
return this.authAdminRole;
|
|
1189
|
-
}
|
|
1190
|
-
return this.lambdaRole;
|
|
1329
|
+
return this.roleFor({ functionId: id });
|
|
1191
1330
|
}
|
|
1192
1331
|
/**
|
|
1193
1332
|
* Build a Lambda function with the standard app-stack properties
|
|
@@ -1219,10 +1358,6 @@ export class VentureAppStack extends cdk.Stack {
|
|
|
1219
1358
|
memorySize: lambdaConfig.memoryMb,
|
|
1220
1359
|
timeout: cdk.Duration.seconds(lambdaConfig.timeoutSec),
|
|
1221
1360
|
description,
|
|
1222
|
-
environment: {
|
|
1223
|
-
...this.baseEnvVars,
|
|
1224
|
-
...lambdaConfig.environmentVariables,
|
|
1225
|
-
},
|
|
1226
1361
|
logGroup,
|
|
1227
1362
|
tracing: this.tracingActive ? lambda.Tracing.ACTIVE : lambda.Tracing.DISABLED,
|
|
1228
1363
|
reservedConcurrentExecutions: lambdaConfig.reservedConcurrency,
|
|
@@ -1235,6 +1370,11 @@ export class VentureAppStack extends cdk.Stack {
|
|
|
1235
1370
|
}
|
|
1236
1371
|
: {}),
|
|
1237
1372
|
...overrides,
|
|
1373
|
+
// The database login follows the role (a system-login role reads the system secret).
|
|
1374
|
+
environment: {
|
|
1375
|
+
...(overrides.environment ?? { ...this.baseEnvVars, ...lambdaConfig.environmentVariables }),
|
|
1376
|
+
...this.loginEnvFor(overrides.role),
|
|
1377
|
+
},
|
|
1238
1378
|
});
|
|
1239
1379
|
}
|
|
1240
1380
|
/**
|
|
@@ -1637,7 +1777,14 @@ export class VentureAppStack extends cdk.Stack {
|
|
|
1637
1777
|
if (!db.secretArn)
|
|
1638
1778
|
continue;
|
|
1639
1779
|
const importedSecret = secretsmanager.Secret.fromSecretCompleteArn(this, `imported-db-secret-${id}`, db.secretArn);
|
|
1780
|
+
// The app login's secret to every role; the system login's to the
|
|
1781
|
+
// system-login roles ONLY.
|
|
1640
1782
|
this.grantEachRole((role) => importedSecret.grantRead(role));
|
|
1783
|
+
if (db.systemSecretArn && this.systemLoginRoles.length > 0) {
|
|
1784
|
+
const systemSecret = secretsmanager.Secret.fromSecretCompleteArn(this, `imported-db-system-secret-${id}`, db.systemSecretArn);
|
|
1785
|
+
for (const role of this.systemLoginRoles)
|
|
1786
|
+
systemSecret.grantRead(role);
|
|
1787
|
+
}
|
|
1641
1788
|
}
|
|
1642
1789
|
}
|
|
1643
1790
|
// ── Federated provider secrets ────────────────────────────
|
|
@@ -1706,8 +1853,9 @@ export class VentureAppStack extends cdk.Stack {
|
|
|
1706
1853
|
}
|
|
1707
1854
|
}
|
|
1708
1855
|
// ── Cognito admin actions per user pool ──────────────────
|
|
1709
|
-
// Attached to the auth-admin role
|
|
1710
|
-
//
|
|
1856
|
+
// Attached to the auth-admin role when `adminRoutes` lists routes,
|
|
1857
|
+
// to the shared role under `adminRoutes: 'all'`, and to no role
|
|
1858
|
+
// otherwise (see `cognitoAdminRoles`).
|
|
1711
1859
|
if (imports.userPoolArnsByAuthId) {
|
|
1712
1860
|
for (const [, poolArn] of imports.userPoolArnsByAuthId) {
|
|
1713
1861
|
// Scope to the Cognito admin actions `@venturekit/auth/server`
|