@mettlecast/domain-cdk-packer 0.2.38 → 0.2.39
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/DomainStack.d.ts
CHANGED
|
@@ -28,9 +28,7 @@ export interface DomainStackProps extends cdk.StackProps {
|
|
|
28
28
|
/** Security group for domain Lambdas — must allow egress to Aurora SG. */
|
|
29
29
|
lambdaSg?: ec2.ISecurityGroup;
|
|
30
30
|
/** Shared HTTP API Gateway — when provided, domain routes are added here instead of creating a separate API. */
|
|
31
|
-
httpApi?: apigwv2.
|
|
32
|
-
/** Path to domain source root — required for dedicated Lambdas. Defaults to ../../domains/{domainId}. */
|
|
33
|
-
domainRoot?: string;
|
|
31
|
+
httpApi?: apigwv2.HttpApi;
|
|
34
32
|
/** Enable CMK encryption for DynamoDB, S3, SQS. */
|
|
35
33
|
enableCmk?: boolean;
|
|
36
34
|
/** Enable WAF WebACL on the domain API Gateway. */
|
|
@@ -57,9 +55,13 @@ export interface DomainStackProps extends cdk.StackProps {
|
|
|
57
55
|
*/
|
|
58
56
|
allowCredentials?: boolean;
|
|
59
57
|
}
|
|
58
|
+
/**
|
|
59
|
+
* Top-level CDK Stack that composes all domain constructs from a single DomainRegistry input.
|
|
60
|
+
* Uses grouped Lambdas for each primitive type to reduce deployment artifact size.
|
|
61
|
+
*/
|
|
60
62
|
export declare class DomainStack extends cdk.Stack {
|
|
61
63
|
/** Shared HTTP API for routing API and webhook requests. */
|
|
62
|
-
readonly httpApi: apigwv2.
|
|
64
|
+
readonly httpApi: apigwv2.HttpApi;
|
|
63
65
|
/** Map of primitive-type key to Lambda function ARN, used by FlowsStack for direct invocation. */
|
|
64
66
|
readonly lambdaArns: Record<string, string>;
|
|
65
67
|
/**
|
package/dist/DomainStack.js
CHANGED
|
@@ -22,30 +22,6 @@ import { CanaryConstruct } from './constructs/canary-construct.js';
|
|
|
22
22
|
* Top-level CDK Stack that composes all domain constructs from a single DomainRegistry input.
|
|
23
23
|
* Uses grouped Lambdas for each primitive type to reduce deployment artifact size.
|
|
24
24
|
*/
|
|
25
|
-
/** L1 helper: adds a route to an existing HTTP API using CfnRoute + CfnIntegration. */
|
|
26
|
-
function addRouteToApi(scope, fn, path, methods, apiId, authType, authorizer) {
|
|
27
|
-
const id = path.replace(/[^a-zA-Z0-9]/g, '_').replace(/^_/, 'api');
|
|
28
|
-
const integ = new apigwv2.CfnIntegration(scope, 'Integ_' + id, {
|
|
29
|
-
apiId,
|
|
30
|
-
integrationType: 'AWS_PROXY',
|
|
31
|
-
integrationUri: fn.functionArn,
|
|
32
|
-
payloadFormatVersion: '2.0',
|
|
33
|
-
});
|
|
34
|
-
fn.addPermission('Perm_' + id, {
|
|
35
|
-
principal: new iam.ServicePrincipal('apigateway.amazonaws.com'),
|
|
36
|
-
sourceArn: 'arn:aws:execute-api:' + cdk.Aws.REGION + ':' + cdk.Aws.ACCOUNT_ID + ':' + apiId + '/*',
|
|
37
|
-
});
|
|
38
|
-
const routeKey = methods[0] === apigwv2.HttpMethod.GET ? 'GET ' + path : 'POST ' + path;
|
|
39
|
-
const route = new apigwv2.CfnRoute(scope, 'Route_' + id, {
|
|
40
|
-
apiId,
|
|
41
|
-
routeKey,
|
|
42
|
-
target: 'integrations/' + integ.ref,
|
|
43
|
-
});
|
|
44
|
-
if (authType === 'jwt' && authorizer) {
|
|
45
|
-
route.authorizationType = 'JWT';
|
|
46
|
-
route.authorizerId = authorizer.ref ?? authorizer.authorizerId ?? '';
|
|
47
|
-
}
|
|
48
|
-
}
|
|
49
25
|
export class DomainStack extends cdk.Stack {
|
|
50
26
|
/** Shared HTTP API for routing API and webhook requests. */
|
|
51
27
|
httpApi;
|
|
@@ -61,7 +37,6 @@ export class DomainStack extends cdk.Stack {
|
|
|
61
37
|
super(scope, id, props);
|
|
62
38
|
const { registry, eventBusArn, eventBusName, databaseUrl, dbSecretArn, userPoolArn, userPoolId, userPoolClientId, vpc, lambdaSg, httpApi, enableCmk, enableWaf, enableAlarms, alarmSnsTopicArn, enableCanaryDeploy, reservedConcurrency, logRetentionDays, corsAllowedOrigins, allowCredentials } = props;
|
|
63
39
|
const domainId = registry.domain.id;
|
|
64
|
-
const domainRoot = props.domainRoot ?? "../../domains/" + domainId;
|
|
65
40
|
const vpcProps = vpc ? { vpc, securityGroups: lambdaSg ? [lambdaSg] : undefined } : {};
|
|
66
41
|
const allowedOrigins = corsAllowedOrigins ?? ['*'];
|
|
67
42
|
this.httpApi = httpApi ?? new apigwv2.HttpApi(this, 'HttpApi', {
|
|
@@ -166,7 +141,6 @@ export class DomainStack extends cdk.Stack {
|
|
|
166
141
|
environment,
|
|
167
142
|
eventBusArn,
|
|
168
143
|
dedicated: true,
|
|
169
|
-
domainRoot,
|
|
170
144
|
reservedConcurrency,
|
|
171
145
|
logRetentionDays: logRetentionDays ?? 30,
|
|
172
146
|
...vpcProps,
|
|
@@ -203,7 +177,7 @@ export class DomainStack extends cdk.Stack {
|
|
|
203
177
|
else {
|
|
204
178
|
apiRoute = apiRouteBase;
|
|
205
179
|
}
|
|
206
|
-
|
|
180
|
+
this.httpApi.addRoutes(apiRoute);
|
|
207
181
|
}
|
|
208
182
|
}
|
|
209
183
|
// Deploy webhooks as grouped Lambdas
|
|
@@ -246,7 +220,11 @@ export class DomainStack extends cdk.Stack {
|
|
|
246
220
|
// Add routes for each webhook entry
|
|
247
221
|
for (const webhook of registry.webhooks) {
|
|
248
222
|
const fn = webhookLambdas[0]; // Grouped Lambda or first dedicated
|
|
249
|
-
|
|
223
|
+
this.httpApi.addRoutes({
|
|
224
|
+
path: webhook.path,
|
|
225
|
+
methods: [apigwv2.HttpMethod.POST],
|
|
226
|
+
integration: new apigwv2integrations.HttpLambdaIntegration(`Webhooks${toPascalCase(webhook.id)}Integration`, fn),
|
|
227
|
+
});
|
|
250
228
|
}
|
|
251
229
|
}
|
|
252
230
|
// Deploy event subscribers as grouped Lambdas
|
|
@@ -511,8 +489,16 @@ export class DomainStack extends cdk.Stack {
|
|
|
511
489
|
DB_SECRET_ARN: dbSecretArn ?? '',
|
|
512
490
|
},
|
|
513
491
|
});
|
|
514
|
-
|
|
515
|
-
|
|
492
|
+
this.httpApi.addRoutes({
|
|
493
|
+
path: '/_health',
|
|
494
|
+
methods: [apigwv2.HttpMethod.GET],
|
|
495
|
+
integration: new apigwv2integrations.HttpLambdaIntegration('HealthIntegration', healthConstruct.healthFn),
|
|
496
|
+
});
|
|
497
|
+
this.httpApi.addRoutes({
|
|
498
|
+
path: '/_ready',
|
|
499
|
+
methods: [apigwv2.HttpMethod.GET],
|
|
500
|
+
integration: new apigwv2integrations.HttpLambdaIntegration('ReadyIntegration', healthConstruct.readyFn),
|
|
501
|
+
});
|
|
516
502
|
// Create CloudWatch dashboard for all primitives
|
|
517
503
|
const allEndpoints = [
|
|
518
504
|
...registry.apis.map(a => ({ id: a.id, primitiveClass: 'api' })),
|
|
@@ -3,7 +3,7 @@ import * as apigwv2 from 'aws-cdk-lib/aws-apigatewayv2';
|
|
|
3
3
|
import { Construct } from 'constructs';
|
|
4
4
|
export interface WafConstructProps {
|
|
5
5
|
domainId: string;
|
|
6
|
-
httpApi: apigwv2.
|
|
6
|
+
httpApi: apigwv2.HttpApi;
|
|
7
7
|
/** Requests per 5-minute window per IP before blocking. Default: 2000. */
|
|
8
8
|
rateLimit?: number;
|
|
9
9
|
}
|