@mettlecast/domain-cdk-packer 0.2.37 → 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.
@@ -28,7 +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.IHttpApi;
31
+ httpApi?: apigwv2.HttpApi;
32
32
  /** Enable CMK encryption for DynamoDB, S3, SQS. */
33
33
  enableCmk?: boolean;
34
34
  /** Enable WAF WebACL on the domain API Gateway. */
@@ -55,9 +55,13 @@ export interface DomainStackProps extends cdk.StackProps {
55
55
  */
56
56
  allowCredentials?: boolean;
57
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
+ */
58
62
  export declare class DomainStack extends cdk.Stack {
59
63
  /** Shared HTTP API for routing API and webhook requests. */
60
- readonly httpApi: apigwv2.IHttpApi;
64
+ readonly httpApi: apigwv2.HttpApi;
61
65
  /** Map of primitive-type key to Lambda function ARN, used by FlowsStack for direct invocation. */
62
66
  readonly lambdaArns: Record<string, string>;
63
67
  /**
@@ -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;
@@ -201,7 +177,7 @@ export class DomainStack extends cdk.Stack {
201
177
  else {
202
178
  apiRoute = apiRouteBase;
203
179
  }
204
- addRouteToApi(this, fn, api.path, [toHttpMethod(api.method)], this.httpApi.httpApiId, api.authType, jwtAuthorizer);
180
+ this.httpApi.addRoutes(apiRoute);
205
181
  }
206
182
  }
207
183
  // Deploy webhooks as grouped Lambdas
@@ -244,7 +220,11 @@ export class DomainStack extends cdk.Stack {
244
220
  // Add routes for each webhook entry
245
221
  for (const webhook of registry.webhooks) {
246
222
  const fn = webhookLambdas[0]; // Grouped Lambda or first dedicated
247
- addRouteToApi(this, fn, webhook.path, [apigwv2.HttpMethod.POST], this.httpApi.httpApiId);
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
+ });
248
228
  }
249
229
  }
250
230
  // Deploy event subscribers as grouped Lambdas
@@ -509,8 +489,16 @@ export class DomainStack extends cdk.Stack {
509
489
  DB_SECRET_ARN: dbSecretArn ?? '',
510
490
  },
511
491
  });
512
- addRouteToApi(this, healthConstruct.healthFn, '/_health', [apigwv2.HttpMethod.GET], this.httpApi.httpApiId);
513
- addRouteToApi(this, healthConstruct.readyFn, '/_ready', [apigwv2.HttpMethod.GET], this.httpApi.httpApiId);
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
+ });
514
502
  // Create CloudWatch dashboard for all primitives
515
503
  const allEndpoints = [
516
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.IHttpApi;
6
+ httpApi: apigwv2.HttpApi;
7
7
  /** Requests per 5-minute window per IP before blocking. Default: 2000. */
8
8
  rateLimit?: number;
9
9
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mettlecast/domain-cdk-packer",
3
- "version": "0.2.37",
3
+ "version": "0.2.39",
4
4
  "type": "module",
5
5
  "publishConfig": {
6
6
  "registry": "https://registry.npmjs.org",