@mettlecast/domain-cdk-packer 0.2.40 → 0.2.41
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,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.
|
|
31
|
+
httpApi?: apigwv2.IHttpApi;
|
|
32
32
|
/** Enable CMK encryption for DynamoDB, S3, SQS. */
|
|
33
33
|
enableCmk?: boolean;
|
|
34
34
|
/** Enable WAF WebACL on the domain API Gateway. */
|
|
@@ -55,13 +55,9 @@ 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
|
-
*/
|
|
62
58
|
export declare class DomainStack extends cdk.Stack {
|
|
63
59
|
/** Shared HTTP API for routing API and webhook requests. */
|
|
64
|
-
readonly httpApi: apigwv2.
|
|
60
|
+
readonly httpApi: apigwv2.IHttpApi;
|
|
65
61
|
/** Map of primitive-type key to Lambda function ARN, used by FlowsStack for direct invocation. */
|
|
66
62
|
readonly lambdaArns: Record<string, string>;
|
|
67
63
|
/**
|
package/dist/DomainStack.js
CHANGED
|
@@ -22,6 +22,26 @@ 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 CfnRoute + CfnIntegration to an existing HTTP API. */
|
|
26
|
+
function addRouteToApi(scope, fn, path, methods, apiId) {
|
|
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
|
+
new apigwv2.CfnRoute(scope, 'Route_' + id, {
|
|
40
|
+
apiId,
|
|
41
|
+
routeKey,
|
|
42
|
+
target: 'integrations/' + integ.ref,
|
|
43
|
+
});
|
|
44
|
+
}
|
|
25
45
|
export class DomainStack extends cdk.Stack {
|
|
26
46
|
/** Shared HTTP API for routing API and webhook requests. */
|
|
27
47
|
httpApi;
|
|
@@ -177,7 +197,7 @@ export class DomainStack extends cdk.Stack {
|
|
|
177
197
|
else {
|
|
178
198
|
apiRoute = apiRouteBase;
|
|
179
199
|
}
|
|
180
|
-
this.httpApi.
|
|
200
|
+
addRouteToApi(this, fn, api.path, [toHttpMethod(api.method)], this.httpApi.httpApiId);
|
|
181
201
|
}
|
|
182
202
|
}
|
|
183
203
|
// Deploy webhooks as grouped Lambdas
|
|
@@ -220,11 +240,7 @@ export class DomainStack extends cdk.Stack {
|
|
|
220
240
|
// Add routes for each webhook entry
|
|
221
241
|
for (const webhook of registry.webhooks) {
|
|
222
242
|
const fn = webhookLambdas[0]; // Grouped Lambda or first dedicated
|
|
223
|
-
this.httpApi.
|
|
224
|
-
path: webhook.path,
|
|
225
|
-
methods: [apigwv2.HttpMethod.POST],
|
|
226
|
-
integration: new apigwv2integrations.HttpLambdaIntegration(`Webhooks${toPascalCase(webhook.id)}Integration`, fn),
|
|
227
|
-
});
|
|
243
|
+
addRouteToApi(this, fn, webhook.path, [apigwv2.HttpMethod.POST], this.httpApi.httpApiId);
|
|
228
244
|
}
|
|
229
245
|
}
|
|
230
246
|
// Deploy event subscribers as grouped Lambdas
|
|
@@ -489,16 +505,8 @@ export class DomainStack extends cdk.Stack {
|
|
|
489
505
|
DB_SECRET_ARN: dbSecretArn ?? '',
|
|
490
506
|
},
|
|
491
507
|
});
|
|
492
|
-
this.httpApi.
|
|
493
|
-
|
|
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
|
-
});
|
|
508
|
+
addRouteToApi(this, healthConstruct.healthFn, '/_health', [apigwv2.HttpMethod.GET], this.httpApi.httpApiId);
|
|
509
|
+
addRouteToApi(this, healthConstruct.readyFn, '/_ready', [apigwv2.HttpMethod.GET], this.httpApi.httpApiId);
|
|
502
510
|
// Create CloudWatch dashboard for all primitives
|
|
503
511
|
const allEndpoints = [
|
|
504
512
|
...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.IHttpApi;
|
|
7
7
|
/** Requests per 5-minute window per IP before blocking. Default: 2000. */
|
|
8
8
|
rateLimit?: number;
|
|
9
9
|
}
|