@incloodsolutions/devkit 0.0.3 → 0.0.5
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/README.md +180 -41
- package/dist/{aws/cdk/constructs/api-gateway-v2-construct.cjs → aws-cdk/constructs/api-gateway-v2.cjs} +2 -2
- package/dist/aws-cdk/constructs/api-gateway-v2.cjs.map +1 -0
- package/dist/{aws/cdk/constructs/api-gateway-v2-construct.d.ts → aws-cdk/constructs/api-gateway-v2.d.cts} +2 -1
- package/dist/{aws/cdk/constructs/api-gateway-v2-construct.d.cts → aws-cdk/constructs/api-gateway-v2.d.ts} +2 -1
- package/dist/{aws/cdk/constructs/api-gateway-v2-construct.js → aws-cdk/constructs/api-gateway-v2.js} +2 -2
- package/dist/aws-cdk/constructs/api-gateway-v2.js.map +1 -0
- package/dist/{aws/cdk/constructs/api-gateway-websocket-construct.cjs → aws-cdk/constructs/api-gateway-websocket.cjs} +18 -6
- package/dist/aws-cdk/constructs/api-gateway-websocket.cjs.map +1 -0
- package/dist/{aws/cdk/constructs/api-gateway-websocket-construct.d.ts → aws-cdk/constructs/api-gateway-websocket.d.cts} +2 -1
- package/dist/{aws/cdk/constructs/api-gateway-websocket-construct.d.cts → aws-cdk/constructs/api-gateway-websocket.d.ts} +2 -1
- package/dist/{aws/cdk/constructs/api-gateway-websocket-construct.js → aws-cdk/constructs/api-gateway-websocket.js} +18 -6
- package/dist/aws-cdk/constructs/api-gateway-websocket.js.map +1 -0
- package/dist/{aws/cdk/constructs/api-gateway-construct.cjs → aws-cdk/constructs/api-gateway.cjs} +6 -3
- package/dist/aws-cdk/constructs/api-gateway.cjs.map +1 -0
- package/dist/{aws/cdk/constructs/api-gateway-construct.d.ts → aws-cdk/constructs/api-gateway.d.cts} +2 -1
- package/dist/{aws/cdk/constructs/api-gateway-construct.d.cts → aws-cdk/constructs/api-gateway.d.ts} +2 -1
- package/dist/{aws/cdk/constructs/api-gateway-construct.js → aws-cdk/constructs/api-gateway.js} +6 -3
- package/dist/aws-cdk/constructs/api-gateway.js.map +1 -0
- package/dist/{aws/cdk/constructs/cloudfront-construct.cjs → aws-cdk/constructs/cloudfront.cjs} +2 -2
- package/dist/aws-cdk/constructs/cloudfront.cjs.map +1 -0
- package/dist/{aws/cdk/constructs/cloudfront-construct.d.ts → aws-cdk/constructs/cloudfront.d.cts} +2 -1
- package/dist/{aws/cdk/constructs/cloudfront-construct.d.cts → aws-cdk/constructs/cloudfront.d.ts} +2 -1
- package/dist/{aws/cdk/constructs/cloudfront-construct.js → aws-cdk/constructs/cloudfront.js} +2 -2
- package/dist/aws-cdk/constructs/cloudfront.js.map +1 -0
- package/dist/{aws/cdk/constructs/cloudwatch-construct.cjs → aws-cdk/constructs/cloudwatch.cjs} +2 -2
- package/dist/aws-cdk/constructs/cloudwatch.cjs.map +1 -0
- package/dist/{aws/cdk/constructs/cloudwatch-construct.d.ts → aws-cdk/constructs/cloudwatch.d.cts} +2 -1
- package/dist/{aws/cdk/constructs/cloudwatch-construct.d.cts → aws-cdk/constructs/cloudwatch.d.ts} +2 -1
- package/dist/{aws/cdk/constructs/cloudwatch-construct.js → aws-cdk/constructs/cloudwatch.js} +2 -2
- package/dist/aws-cdk/constructs/cloudwatch.js.map +1 -0
- package/dist/{aws/cdk/constructs/dynamo-db-construct.cjs → aws-cdk/constructs/dynamo-db.cjs} +2 -2
- package/dist/aws-cdk/constructs/dynamo-db.cjs.map +1 -0
- package/dist/{aws/cdk/constructs/dynamo-db-construct.d.ts → aws-cdk/constructs/dynamo-db.d.cts} +2 -1
- package/dist/{aws/cdk/constructs/dynamo-db-construct.d.cts → aws-cdk/constructs/dynamo-db.d.ts} +2 -1
- package/dist/{aws/cdk/constructs/dynamo-db-construct.js → aws-cdk/constructs/dynamo-db.js} +2 -2
- package/dist/aws-cdk/constructs/dynamo-db.js.map +1 -0
- package/dist/{aws/cdk/constructs/event-bridge-construct.cjs → aws-cdk/constructs/event-bridge.cjs} +2 -2
- package/dist/aws-cdk/constructs/event-bridge.cjs.map +1 -0
- package/dist/{aws/cdk/constructs/event-bridge-construct.d.ts → aws-cdk/constructs/event-bridge.d.cts} +2 -1
- package/dist/{aws/cdk/constructs/event-bridge-construct.d.cts → aws-cdk/constructs/event-bridge.d.ts} +2 -1
- package/dist/{aws/cdk/constructs/event-bridge-construct.js → aws-cdk/constructs/event-bridge.js} +2 -2
- package/dist/aws-cdk/constructs/event-bridge.js.map +1 -0
- package/dist/{aws/cdk/constructs/lambda-authorizer-v2-construct.cjs → aws-cdk/constructs/lambda-authorizer-v2.cjs} +6 -3
- package/dist/aws-cdk/constructs/lambda-authorizer-v2.cjs.map +1 -0
- package/dist/{aws/cdk/constructs/lambda-authorizer-v2-construct.d.ts → aws-cdk/constructs/lambda-authorizer-v2.d.cts} +2 -1
- package/dist/{aws/cdk/constructs/lambda-authorizer-v2-construct.d.cts → aws-cdk/constructs/lambda-authorizer-v2.d.ts} +2 -1
- package/dist/{aws/cdk/constructs/lambda-authorizer-v2-construct.js → aws-cdk/constructs/lambda-authorizer-v2.js} +6 -3
- package/dist/aws-cdk/constructs/lambda-authorizer-v2.js.map +1 -0
- package/dist/{aws/cdk/constructs/lambda-authorizer-construct.cjs → aws-cdk/constructs/lambda-authorizer.cjs} +2 -2
- package/dist/aws-cdk/constructs/lambda-authorizer.cjs.map +1 -0
- package/dist/{aws/cdk/constructs/lambda-authorizer-construct.d.cts → aws-cdk/constructs/lambda-authorizer.d.cts} +2 -1
- package/dist/{aws/cdk/constructs/lambda-authorizer-construct.d.ts → aws-cdk/constructs/lambda-authorizer.d.ts} +2 -1
- package/dist/{aws/cdk/constructs/lambda-authorizer-construct.js → aws-cdk/constructs/lambda-authorizer.js} +2 -2
- package/dist/aws-cdk/constructs/lambda-authorizer.js.map +1 -0
- package/dist/{aws/cdk/constructs/lambda-layer-construct.cjs → aws-cdk/constructs/lambda-layer.cjs} +3 -6
- package/dist/aws-cdk/constructs/lambda-layer.cjs.map +1 -0
- package/dist/{aws/cdk/constructs/lambda-layer-construct.d.ts → aws-cdk/constructs/lambda-layer.d.cts} +2 -1
- package/dist/{aws/cdk/constructs/lambda-layer-construct.d.cts → aws-cdk/constructs/lambda-layer.d.ts} +2 -1
- package/dist/{aws/cdk/constructs/lambda-layer-construct.js → aws-cdk/constructs/lambda-layer.js} +3 -6
- package/dist/aws-cdk/constructs/lambda-layer.js.map +1 -0
- package/dist/{aws/cdk/constructs/lambda-construct.cjs → aws-cdk/constructs/lambda.cjs} +4 -4
- package/dist/aws-cdk/constructs/lambda.cjs.map +1 -0
- package/dist/{aws/cdk/constructs/lambda-construct.d.ts → aws-cdk/constructs/lambda.d.cts} +2 -1
- package/dist/{aws/cdk/constructs/lambda-construct.d.cts → aws-cdk/constructs/lambda.d.ts} +2 -1
- package/dist/{aws/cdk/constructs/lambda-construct.js → aws-cdk/constructs/lambda.js} +4 -4
- package/dist/aws-cdk/constructs/lambda.js.map +1 -0
- package/dist/{aws/cdk/constructs/role-policy-construct.cjs → aws-cdk/constructs/role-policy.cjs} +2 -2
- package/dist/aws-cdk/constructs/role-policy.cjs.map +1 -0
- package/dist/{aws/cdk/constructs/role-policy-construct.d.ts → aws-cdk/constructs/role-policy.d.cts} +2 -1
- package/dist/{aws/cdk/constructs/role-policy-construct.d.cts → aws-cdk/constructs/role-policy.d.ts} +2 -1
- package/dist/{aws/cdk/constructs/role-policy-construct.js → aws-cdk/constructs/role-policy.js} +2 -2
- package/dist/aws-cdk/constructs/role-policy.js.map +1 -0
- package/dist/aws-cdk/constructs/route53.cjs +79 -0
- package/dist/aws-cdk/constructs/route53.cjs.map +1 -0
- package/dist/aws-cdk/constructs/route53.d.cts +95 -0
- package/dist/aws-cdk/constructs/route53.d.ts +95 -0
- package/dist/aws-cdk/constructs/route53.js +77 -0
- package/dist/aws-cdk/constructs/route53.js.map +1 -0
- package/dist/{aws/cdk/constructs/s3-deployment-construct.cjs → aws-cdk/constructs/s3-deployment.cjs} +20 -11
- package/dist/aws-cdk/constructs/s3-deployment.cjs.map +1 -0
- package/dist/{aws/cdk/constructs/s3-deployment-construct.d.ts → aws-cdk/constructs/s3-deployment.d.cts} +2 -1
- package/dist/{aws/cdk/constructs/s3-deployment-construct.d.cts → aws-cdk/constructs/s3-deployment.d.ts} +2 -1
- package/dist/{aws/cdk/constructs/s3-deployment-construct.js → aws-cdk/constructs/s3-deployment.js} +20 -11
- package/dist/aws-cdk/constructs/s3-deployment.js.map +1 -0
- package/dist/{aws/cdk/constructs/s3-construct.cjs → aws-cdk/constructs/s3.cjs} +2 -2
- package/dist/aws-cdk/constructs/s3.cjs.map +1 -0
- package/dist/{aws/cdk/constructs/s3-construct.d.ts → aws-cdk/constructs/s3.d.cts} +2 -1
- package/dist/{aws/cdk/constructs/s3-construct.d.cts → aws-cdk/constructs/s3.d.ts} +2 -1
- package/dist/{aws/cdk/constructs/s3-construct.js → aws-cdk/constructs/s3.js} +2 -2
- package/dist/aws-cdk/constructs/s3.js.map +1 -0
- package/dist/{aws/cdk/constructs/sns-construct.cjs → aws-cdk/constructs/sns.cjs} +2 -2
- package/dist/aws-cdk/constructs/sns.cjs.map +1 -0
- package/dist/{aws/cdk/constructs/sns-construct.d.ts → aws-cdk/constructs/sns.d.cts} +2 -1
- package/dist/{aws/cdk/constructs/sns-construct.d.cts → aws-cdk/constructs/sns.d.ts} +2 -1
- package/dist/{aws/cdk/constructs/sns-construct.js → aws-cdk/constructs/sns.js} +2 -2
- package/dist/aws-cdk/constructs/sns.js.map +1 -0
- package/dist/{aws/cdk/constructs/sqs-construct.cjs → aws-cdk/constructs/sqs.cjs} +2 -2
- package/dist/aws-cdk/constructs/sqs.cjs.map +1 -0
- package/dist/{aws/cdk/constructs/sqs-construct.d.ts → aws-cdk/constructs/sqs.d.cts} +2 -1
- package/dist/{aws/cdk/constructs/sqs-construct.d.cts → aws-cdk/constructs/sqs.d.ts} +2 -1
- package/dist/{aws/cdk/constructs/sqs-construct.js → aws-cdk/constructs/sqs.js} +2 -2
- package/dist/aws-cdk/constructs/sqs.js.map +1 -0
- package/dist/{aws/cdk/constructs/vpc-construct.cjs → aws-cdk/constructs/vpc.cjs} +2 -2
- package/dist/aws-cdk/constructs/vpc.cjs.map +1 -0
- package/dist/{aws/cdk/constructs/vpc-construct.d.ts → aws-cdk/constructs/vpc.d.cts} +2 -1
- package/dist/{aws/cdk/constructs/vpc-construct.d.cts → aws-cdk/constructs/vpc.d.ts} +2 -1
- package/dist/{aws/cdk/constructs/vpc-construct.js → aws-cdk/constructs/vpc.js} +2 -2
- package/dist/aws-cdk/constructs/vpc.js.map +1 -0
- package/dist/aws-cdk/stacks/lambda-api.cjs +252 -0
- package/dist/aws-cdk/stacks/lambda-api.cjs.map +1 -0
- package/dist/aws-cdk/stacks/lambda-api.d.cts +16 -0
- package/dist/aws-cdk/stacks/lambda-api.d.ts +16 -0
- package/dist/aws-cdk/stacks/lambda-api.js +250 -0
- package/dist/aws-cdk/stacks/lambda-api.js.map +1 -0
- package/dist/aws-cdk/stacks/lambda-sns.cjs +211 -0
- package/dist/aws-cdk/stacks/lambda-sns.cjs.map +1 -0
- package/dist/aws-cdk/stacks/lambda-sns.d.cts +17 -0
- package/dist/aws-cdk/stacks/lambda-sns.d.ts +17 -0
- package/dist/aws-cdk/stacks/lambda-sns.js +209 -0
- package/dist/aws-cdk/stacks/lambda-sns.js.map +1 -0
- package/dist/aws-cdk/stacks/lambda-sqs.cjs +220 -0
- package/dist/aws-cdk/stacks/lambda-sqs.cjs.map +1 -0
- package/dist/aws-cdk/stacks/lambda-sqs.d.cts +18 -0
- package/dist/aws-cdk/stacks/lambda-sqs.d.ts +18 -0
- package/dist/aws-cdk/stacks/lambda-sqs.js +218 -0
- package/dist/aws-cdk/stacks/lambda-sqs.js.map +1 -0
- package/dist/aws-types.cjs +4 -0
- package/dist/aws-types.cjs.map +1 -0
- package/dist/aws-types.d.cts +55 -0
- package/dist/aws-types.d.ts +55 -0
- package/dist/aws-types.js +3 -0
- package/dist/aws-types.js.map +1 -0
- package/dist/{aws/cdk/constructs/index.cjs → aws.cjs} +244 -23
- package/dist/aws.cjs.map +1 -0
- package/dist/aws.d.cts +40 -0
- package/dist/aws.d.ts +40 -0
- package/dist/{aws/index.js → aws.js} +243 -26
- package/dist/aws.js.map +1 -0
- package/dist/index.cjs +242 -21
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +24 -18
- package/dist/index.d.ts +24 -18
- package/dist/index.js +241 -24
- package/dist/index.js.map +1 -1
- package/package.json +160 -25
- package/dist/aws/cdk/constructs/api-gateway-construct.cjs.map +0 -1
- package/dist/aws/cdk/constructs/api-gateway-construct.js.map +0 -1
- package/dist/aws/cdk/constructs/api-gateway-v2-construct.cjs.map +0 -1
- package/dist/aws/cdk/constructs/api-gateway-v2-construct.js.map +0 -1
- package/dist/aws/cdk/constructs/api-gateway-websocket-construct.cjs.map +0 -1
- package/dist/aws/cdk/constructs/api-gateway-websocket-construct.js.map +0 -1
- package/dist/aws/cdk/constructs/cloudfront-construct.cjs.map +0 -1
- package/dist/aws/cdk/constructs/cloudfront-construct.js.map +0 -1
- package/dist/aws/cdk/constructs/cloudwatch-construct.cjs.map +0 -1
- package/dist/aws/cdk/constructs/cloudwatch-construct.js.map +0 -1
- package/dist/aws/cdk/constructs/dynamo-db-construct.cjs.map +0 -1
- package/dist/aws/cdk/constructs/dynamo-db-construct.js.map +0 -1
- package/dist/aws/cdk/constructs/event-bridge-construct.cjs.map +0 -1
- package/dist/aws/cdk/constructs/event-bridge-construct.js.map +0 -1
- package/dist/aws/cdk/constructs/index.cjs.map +0 -1
- package/dist/aws/cdk/constructs/index.d.cts +0 -34
- package/dist/aws/cdk/constructs/index.d.ts +0 -34
- package/dist/aws/cdk/constructs/index.js +0 -863
- package/dist/aws/cdk/constructs/index.js.map +0 -1
- package/dist/aws/cdk/constructs/lambda-authorizer-construct.cjs.map +0 -1
- package/dist/aws/cdk/constructs/lambda-authorizer-construct.js.map +0 -1
- package/dist/aws/cdk/constructs/lambda-authorizer-v2-construct.cjs.map +0 -1
- package/dist/aws/cdk/constructs/lambda-authorizer-v2-construct.js.map +0 -1
- package/dist/aws/cdk/constructs/lambda-construct.cjs.map +0 -1
- package/dist/aws/cdk/constructs/lambda-construct.js.map +0 -1
- package/dist/aws/cdk/constructs/lambda-layer-construct.cjs.map +0 -1
- package/dist/aws/cdk/constructs/lambda-layer-construct.js.map +0 -1
- package/dist/aws/cdk/constructs/role-policy-construct.cjs.map +0 -1
- package/dist/aws/cdk/constructs/role-policy-construct.js.map +0 -1
- package/dist/aws/cdk/constructs/s3-construct.cjs.map +0 -1
- package/dist/aws/cdk/constructs/s3-construct.js.map +0 -1
- package/dist/aws/cdk/constructs/s3-deployment-construct.cjs.map +0 -1
- package/dist/aws/cdk/constructs/s3-deployment-construct.js.map +0 -1
- package/dist/aws/cdk/constructs/sns-construct.cjs.map +0 -1
- package/dist/aws/cdk/constructs/sns-construct.js.map +0 -1
- package/dist/aws/cdk/constructs/sqs-construct.cjs.map +0 -1
- package/dist/aws/cdk/constructs/sqs-construct.js.map +0 -1
- package/dist/aws/cdk/constructs/vpc-construct.cjs.map +0 -1
- package/dist/aws/cdk/constructs/vpc-construct.js.map +0 -1
- package/dist/aws/cdk/index.cjs +0 -881
- package/dist/aws/cdk/index.cjs.map +0 -1
- package/dist/aws/cdk/index.d.cts +0 -34
- package/dist/aws/cdk/index.d.ts +0 -34
- package/dist/aws/cdk/index.js +0 -863
- package/dist/aws/cdk/index.js.map +0 -1
- package/dist/aws/cli/index.cjs +0 -4
- package/dist/aws/cli/index.cjs.map +0 -1
- package/dist/aws/cli/index.d.cts +0 -2
- package/dist/aws/cli/index.d.ts +0 -2
- package/dist/aws/cli/index.js +0 -3
- package/dist/aws/cli/index.js.map +0 -1
- package/dist/aws/index.cjs +0 -881
- package/dist/aws/index.cjs.map +0 -1
- package/dist/aws/index.d.cts +0 -34
- package/dist/aws/index.d.ts +0 -34
- package/dist/aws/index.js.map +0 -1
- package/dist/aws/types/index.cjs +0 -4
- package/dist/aws/types/index.cjs.map +0 -1
- package/dist/aws/types/index.d.cts +0 -18
- package/dist/aws/types/index.d.ts +0 -18
- package/dist/aws/types/index.js +0 -3
- package/dist/aws/types/index.js.map +0 -1
- package/dist/lint/index.cjs +0 -4
- package/dist/lint/index.cjs.map +0 -1
- package/dist/lint/index.d.cts +0 -2
- package/dist/lint/index.d.ts +0 -2
- package/dist/lint/index.js +0 -3
- package/dist/lint/index.js.map +0 -1
- package/dist/prettier/index.cjs +0 -4
- package/dist/prettier/index.cjs.map +0 -1
- package/dist/prettier/index.d.cts +0 -2
- package/dist/prettier/index.d.ts +0 -2
- package/dist/prettier/index.js +0 -3
- package/dist/prettier/index.js.map +0 -1
- package/dist/utility/index.cjs +0 -4
- package/dist/utility/index.cjs.map +0 -1
- package/dist/utility/index.d.cts +0 -2
- package/dist/utility/index.d.ts +0 -2
- package/dist/utility/index.js +0 -3
- package/dist/utility/index.js.map +0 -1
package/dist/aws/cdk/index.js
DELETED
|
@@ -1,863 +0,0 @@
|
|
|
1
|
-
import { Construct } from 'constructs';
|
|
2
|
-
import { Size, RemovalPolicy, CfnOutput, Duration } from 'aws-cdk-lib';
|
|
3
|
-
import { RestApi, Cors, LambdaIntegration, TokenAuthorizer } from 'aws-cdk-lib/aws-apigateway';
|
|
4
|
-
import { printLog, CustomException, detectDuplicateProperties, AppEnvironmentEnum } from '@incloodsolutions/toolkit';
|
|
5
|
-
import { HttpLambdaIntegration, WebSocketLambdaIntegration } from 'aws-cdk-lib/aws-apigatewayv2-integrations';
|
|
6
|
-
import { HttpApi, CorsHttpMethod, WebSocketApi, WebSocketStage } from 'aws-cdk-lib/aws-apigatewayv2';
|
|
7
|
-
import { Distribution, ViewerProtocolPolicy } from 'aws-cdk-lib/aws-cloudfront';
|
|
8
|
-
import { LogGroup, RetentionDays } from 'aws-cdk-lib/aws-logs';
|
|
9
|
-
import { Table, BillingMode } from 'aws-cdk-lib/aws-dynamodb';
|
|
10
|
-
import { Rule } from 'aws-cdk-lib/aws-events';
|
|
11
|
-
import { LambdaFunction } from 'aws-cdk-lib/aws-events-targets';
|
|
12
|
-
import { HttpLambdaAuthorizer, HttpLambdaResponseType } from 'aws-cdk-lib/aws-apigatewayv2-authorizers';
|
|
13
|
-
import { Function, Architecture, Runtime, Code, LayerVersion, EventSourceMapping } from 'aws-cdk-lib/aws-lambda';
|
|
14
|
-
import { Role, ManagedPolicy, PolicyStatement } from 'aws-cdk-lib/aws-iam';
|
|
15
|
-
import { Bucket } from 'aws-cdk-lib/aws-s3';
|
|
16
|
-
import { S3BucketOrigin } from 'aws-cdk-lib/aws-cloudfront-origins';
|
|
17
|
-
import { BucketDeployment } from 'aws-cdk-lib/aws-s3-deployment';
|
|
18
|
-
import { Topic } from 'aws-cdk-lib/aws-sns';
|
|
19
|
-
import { LambdaSubscription } from 'aws-cdk-lib/aws-sns-subscriptions';
|
|
20
|
-
import { Queue } from 'aws-cdk-lib/aws-sqs';
|
|
21
|
-
import { Vpc } from 'aws-cdk-lib/aws-ec2';
|
|
22
|
-
|
|
23
|
-
var __defProp = Object.defineProperty;
|
|
24
|
-
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
25
|
-
var BaseApiGatewayConstruct = class _BaseApiGatewayConstruct extends Construct {
|
|
26
|
-
static {
|
|
27
|
-
__name(this, "BaseApiGatewayConstruct");
|
|
28
|
-
}
|
|
29
|
-
/** The created REST API instance */
|
|
30
|
-
api;
|
|
31
|
-
/** Enables debug logging for route creation */
|
|
32
|
-
enableDebug = false;
|
|
33
|
-
/**
|
|
34
|
-
* @param scope Parent construct
|
|
35
|
-
* @param id Unique construct identifier
|
|
36
|
-
* @param props Configuration for API, routes, and Lambda handler
|
|
37
|
-
*/
|
|
38
|
-
constructor(scope, id, props) {
|
|
39
|
-
super(scope, id);
|
|
40
|
-
this.enableDebug = props.enableDebug;
|
|
41
|
-
this.api = new RestApi(this, id, {
|
|
42
|
-
...props?.options?.gatewayOptions,
|
|
43
|
-
/** Default API description if not provided */
|
|
44
|
-
description: props?.options?.gatewayOptions?.description || "This is a REST API using CDK",
|
|
45
|
-
/**
|
|
46
|
-
* CORS configuration
|
|
47
|
-
* Falls back to allowing all origins, methods, and standard headers
|
|
48
|
-
*/
|
|
49
|
-
defaultCorsPreflightOptions: {
|
|
50
|
-
...props?.options?.gatewayOptions?.defaultCorsPreflightOptions,
|
|
51
|
-
/** Allow all origins by default */
|
|
52
|
-
allowOrigins: props?.options?.gatewayOptions?.defaultCorsPreflightOptions?.allowOrigins || Cors.ALL_ORIGINS,
|
|
53
|
-
/** Allow all HTTP methods by default */
|
|
54
|
-
allowMethods: props?.options?.gatewayOptions?.defaultCorsPreflightOptions?.allowMethods || Cors.ALL_METHODS,
|
|
55
|
-
/** Merge default headers with user-defined headers */
|
|
56
|
-
allowHeaders: [
|
|
57
|
-
...props.options?.gatewayOptions?.defaultCorsPreflightOptions?.allowHeaders,
|
|
58
|
-
"Content-Type",
|
|
59
|
-
"Accept",
|
|
60
|
-
"X-Amz-Date",
|
|
61
|
-
"Authorization",
|
|
62
|
-
"X-Api-Key",
|
|
63
|
-
"X-Amz-Security-Token",
|
|
64
|
-
"X-Amz-User-Agent"
|
|
65
|
-
]
|
|
66
|
-
},
|
|
67
|
-
/** Minimum payload size (in bytes) before compression is applied */
|
|
68
|
-
minCompressionSize: props?.options?.gatewayOptions?.minCompressionSize || Size.bytes(1)
|
|
69
|
-
});
|
|
70
|
-
if (props?.options?.routeOptions?.length && props?.handlerFunction) {
|
|
71
|
-
const integration = new LambdaIntegration(props.handlerFunction);
|
|
72
|
-
this.addRoutes(this.api.root, props.options.routeOptions, integration);
|
|
73
|
-
}
|
|
74
|
-
this.api.applyRemovalPolicy(RemovalPolicy.DESTROY);
|
|
75
|
-
new CfnOutput(this, "ApiGateway", {
|
|
76
|
-
value: this.api.url
|
|
77
|
-
});
|
|
78
|
-
}
|
|
79
|
-
/**
|
|
80
|
-
* Recursively attaches routes to the API Gateway
|
|
81
|
-
*
|
|
82
|
-
* Behaviour:
|
|
83
|
-
* - Creates a resource for each route segment
|
|
84
|
-
* - Attaches method + Lambda integration
|
|
85
|
-
* - Traverses child routes for nested paths
|
|
86
|
-
*
|
|
87
|
-
* @param parent Parent API resource
|
|
88
|
-
* @param routes Route definitions
|
|
89
|
-
* @param integration Lambda integration applied to each route
|
|
90
|
-
* @param previousPath Accumulated path (used for debug logging)
|
|
91
|
-
* @private
|
|
92
|
-
*/
|
|
93
|
-
addRoutes(parent, routes, integration, previousPath) {
|
|
94
|
-
routes.forEach((route) => {
|
|
95
|
-
const currentPath = `${previousPath || ""}/${route.name}`;
|
|
96
|
-
const resource = parent.addResource(route.name);
|
|
97
|
-
resource.addMethod(route.method, integration);
|
|
98
|
-
if (route?.children.length) {
|
|
99
|
-
this.addRoutes(resource, route.children, integration, currentPath);
|
|
100
|
-
}
|
|
101
|
-
if (this.enableDebug) {
|
|
102
|
-
printLog(_BaseApiGatewayConstruct.name, `Route created: ${route.method} ${currentPath}`);
|
|
103
|
-
}
|
|
104
|
-
});
|
|
105
|
-
}
|
|
106
|
-
};
|
|
107
|
-
var BaseApiGatewayV2Construct = class extends Construct {
|
|
108
|
-
static {
|
|
109
|
-
__name(this, "BaseApiGatewayV2Construct");
|
|
110
|
-
}
|
|
111
|
-
/** The created HTTP API instance */
|
|
112
|
-
api;
|
|
113
|
-
/** Enables debug logging (if used externally) */
|
|
114
|
-
enableDebug = false;
|
|
115
|
-
/**
|
|
116
|
-
* @param scope Parent construct
|
|
117
|
-
* @param id Unique construct identifier
|
|
118
|
-
* @param props Configuration for API, routes, and handlers
|
|
119
|
-
*/
|
|
120
|
-
constructor(scope, id, props) {
|
|
121
|
-
super(scope, id);
|
|
122
|
-
this.enableDebug = props.enableDebug;
|
|
123
|
-
this.api = new HttpApi(this, id, {
|
|
124
|
-
...props?.options?.gatewayOptions,
|
|
125
|
-
/** Default API description if not provided */
|
|
126
|
-
description: props?.options?.gatewayOptions?.description || "This is an Http API using CDK",
|
|
127
|
-
/**
|
|
128
|
-
* CORS configuration
|
|
129
|
-
* Falls back to allowing all methods and standard headers if not explicitly defined
|
|
130
|
-
*/
|
|
131
|
-
corsPreflight: {
|
|
132
|
-
...props.options?.gatewayOptions?.corsPreflight,
|
|
133
|
-
/** Allow all HTTP methods by default */
|
|
134
|
-
allowMethods: props.options?.gatewayOptions?.corsPreflight?.allowMethods || Object.values(CorsHttpMethod),
|
|
135
|
-
/** Merge default headers with user-defined headers */
|
|
136
|
-
allowHeaders: [
|
|
137
|
-
"Content-Type",
|
|
138
|
-
"Accept",
|
|
139
|
-
"X-Amz-Date",
|
|
140
|
-
"Authorization",
|
|
141
|
-
"X-Api-Key",
|
|
142
|
-
"X-Amz-Security-Token",
|
|
143
|
-
"X-Amz-User-Agent",
|
|
144
|
-
...props.options?.gatewayOptions?.corsPreflight?.allowHeaders || []
|
|
145
|
-
]
|
|
146
|
-
}
|
|
147
|
-
});
|
|
148
|
-
if (!props?.handlerFunctions?.length) {
|
|
149
|
-
throw new CustomException("Construct requires atleast one function");
|
|
150
|
-
}
|
|
151
|
-
if (props?.options?.routeOptions?.length) {
|
|
152
|
-
props.handlerFunctions.forEach((handlerFunc) => {
|
|
153
|
-
props?.options?.routeOptions.forEach((route) => {
|
|
154
|
-
this.api.addRoutes({
|
|
155
|
-
...route,
|
|
156
|
-
/**
|
|
157
|
-
* Lambda integration for each route
|
|
158
|
-
*/
|
|
159
|
-
integration: new HttpLambdaIntegration("routes", handlerFunc)
|
|
160
|
-
});
|
|
161
|
-
});
|
|
162
|
-
});
|
|
163
|
-
}
|
|
164
|
-
this.api.applyRemovalPolicy(RemovalPolicy.DESTROY);
|
|
165
|
-
new CfnOutput(this, "ApiGatewayV2", {
|
|
166
|
-
value: this.api.url
|
|
167
|
-
});
|
|
168
|
-
}
|
|
169
|
-
};
|
|
170
|
-
var BaseApiGatewayWebSocketConstruct = class extends Construct {
|
|
171
|
-
static {
|
|
172
|
-
__name(this, "BaseApiGatewayWebSocketConstruct");
|
|
173
|
-
}
|
|
174
|
-
/** The created WebSocket API instance */
|
|
175
|
-
socketApi;
|
|
176
|
-
/**
|
|
177
|
-
* @param scope Parent construct
|
|
178
|
-
* @param id Unique construct identifier
|
|
179
|
-
* @param props Configuration for API, stage, and route handlers
|
|
180
|
-
*/
|
|
181
|
-
constructor(scope, id, props) {
|
|
182
|
-
super(scope, id);
|
|
183
|
-
this.socketApi = new WebSocketApi(this, id, {
|
|
184
|
-
...props.options.webSocketApiOptions,
|
|
185
|
-
/**
|
|
186
|
-
* Route for connection establishment ($connect)
|
|
187
|
-
*/
|
|
188
|
-
connectRouteOptions: {
|
|
189
|
-
...props.handlers.connect?.option,
|
|
190
|
-
integration: new WebSocketLambdaIntegration("connectIntegration", props.handlers.connect.function)
|
|
191
|
-
},
|
|
192
|
-
/**
|
|
193
|
-
* Route for disconnection events ($disconnect)
|
|
194
|
-
*/
|
|
195
|
-
disconnectRouteOptions: {
|
|
196
|
-
...props.handlers.disconnect?.option,
|
|
197
|
-
integration: new WebSocketLambdaIntegration("disconnectIntegration", props.handlers.disconnect.function)
|
|
198
|
-
},
|
|
199
|
-
/**
|
|
200
|
-
* Default route for unmatched messages ($default)
|
|
201
|
-
*/
|
|
202
|
-
defaultRouteOptions: {
|
|
203
|
-
...props.handlers.default?.option,
|
|
204
|
-
integration: new WebSocketLambdaIntegration("defaultIntegration", props.handlers.default.function)
|
|
205
|
-
}
|
|
206
|
-
});
|
|
207
|
-
this.socketApi.addRoute("notifications", {
|
|
208
|
-
...props.handlers.message?.option,
|
|
209
|
-
/** Lambda integration for message handling */
|
|
210
|
-
integration: new WebSocketLambdaIntegration("routes", props.handlers.message.function)
|
|
211
|
-
});
|
|
212
|
-
const webSocketStage = new WebSocketStage(this, `${id}_stage`, {
|
|
213
|
-
...props.options?.webSocketStageOptions,
|
|
214
|
-
webSocketApi: this.socketApi,
|
|
215
|
-
autoDeploy: true
|
|
216
|
-
});
|
|
217
|
-
new CfnOutput(this, "WebSocketURL", {
|
|
218
|
-
value: webSocketStage.url
|
|
219
|
-
});
|
|
220
|
-
}
|
|
221
|
-
};
|
|
222
|
-
var BaseCloudfrontConstruct = class extends Construct {
|
|
223
|
-
static {
|
|
224
|
-
__name(this, "BaseCloudfrontConstruct");
|
|
225
|
-
}
|
|
226
|
-
/** The created CloudFront distribution instance */
|
|
227
|
-
distribution;
|
|
228
|
-
/**
|
|
229
|
-
* @param scope Parent construct
|
|
230
|
-
* @param id Unique construct identifier
|
|
231
|
-
* @param props Configuration for CloudFront distribution
|
|
232
|
-
*/
|
|
233
|
-
constructor(scope, id, props) {
|
|
234
|
-
super(scope, id);
|
|
235
|
-
this.distribution = new Distribution(this, id, {
|
|
236
|
-
...props.options?.cloudfrontOptions,
|
|
237
|
-
/**
|
|
238
|
-
* Default behaviour configuration
|
|
239
|
-
* Enforces HTTPS if not explicitly defined
|
|
240
|
-
*/
|
|
241
|
-
defaultBehavior: {
|
|
242
|
-
...props.options?.cloudfrontOptions?.defaultBehavior,
|
|
243
|
-
viewerProtocolPolicy: props.options?.cloudfrontOptions?.defaultBehavior?.viewerProtocolPolicy || ViewerProtocolPolicy.REDIRECT_TO_HTTPS
|
|
244
|
-
},
|
|
245
|
-
/**
|
|
246
|
-
* Error response configuration
|
|
247
|
-
*
|
|
248
|
-
* Adds SPA-friendly fallbacks:
|
|
249
|
-
* - 400, 403, 404 responses are redirected to index.html
|
|
250
|
-
*/
|
|
251
|
-
errorResponses: [
|
|
252
|
-
...props.options?.cloudfrontOptions?.errorResponses || [],
|
|
253
|
-
/** Handle 400 errors */
|
|
254
|
-
{
|
|
255
|
-
httpStatus: 400,
|
|
256
|
-
responseHttpStatus: 200,
|
|
257
|
-
responsePagePath: "/index.html",
|
|
258
|
-
ttl: Duration.days(1)
|
|
259
|
-
},
|
|
260
|
-
/** Handle 403 errors */
|
|
261
|
-
{
|
|
262
|
-
httpStatus: 403,
|
|
263
|
-
responseHttpStatus: 200,
|
|
264
|
-
responsePagePath: "/index.html",
|
|
265
|
-
ttl: Duration.days(1)
|
|
266
|
-
},
|
|
267
|
-
/** Handle 404 errors */
|
|
268
|
-
{
|
|
269
|
-
httpStatus: 404,
|
|
270
|
-
responseHttpStatus: 200,
|
|
271
|
-
responsePagePath: "/index.html",
|
|
272
|
-
ttl: Duration.days(1)
|
|
273
|
-
}
|
|
274
|
-
]
|
|
275
|
-
});
|
|
276
|
-
}
|
|
277
|
-
};
|
|
278
|
-
var BaseCloudwatchLogGroupConstruct = class extends Construct {
|
|
279
|
-
static {
|
|
280
|
-
__name(this, "BaseCloudwatchLogGroupConstruct");
|
|
281
|
-
}
|
|
282
|
-
/** The created CloudWatch Log Group instance */
|
|
283
|
-
logGroup;
|
|
284
|
-
/**
|
|
285
|
-
* @param scope Parent construct
|
|
286
|
-
* @param id Unique construct identifier
|
|
287
|
-
* @param props Configuration for the log group
|
|
288
|
-
*/
|
|
289
|
-
constructor(scope, id, props) {
|
|
290
|
-
super(scope, id);
|
|
291
|
-
this.logGroup = new LogGroup(this, id, {
|
|
292
|
-
...props.options?.logGroupOptions,
|
|
293
|
-
/**
|
|
294
|
-
* Removal policy applied to the log group
|
|
295
|
-
* Defaults to DESTROY when not explicitly defined
|
|
296
|
-
*/
|
|
297
|
-
removalPolicy: props?.options?.logGroupOptions?.removalPolicy || RemovalPolicy.DESTROY,
|
|
298
|
-
/**
|
|
299
|
-
* Log retention period
|
|
300
|
-
* Defaults to INFINITE when not explicitly defined
|
|
301
|
-
*/
|
|
302
|
-
retention: props?.options?.logGroupOptions?.retention || RetentionDays.INFINITE
|
|
303
|
-
});
|
|
304
|
-
new CfnOutput(this, "CloudwatchArn", {
|
|
305
|
-
value: this.logGroup.logGroupArn
|
|
306
|
-
});
|
|
307
|
-
}
|
|
308
|
-
};
|
|
309
|
-
var BaseDynamoDBConstruct = class _BaseDynamoDBConstruct extends Construct {
|
|
310
|
-
static {
|
|
311
|
-
__name(this, "BaseDynamoDBConstruct");
|
|
312
|
-
}
|
|
313
|
-
/** Newly created DynamoDB table (null if importing existing table) */
|
|
314
|
-
table;
|
|
315
|
-
/** Imported DynamoDB table reference (null if creating new table) */
|
|
316
|
-
existingTable;
|
|
317
|
-
/** Enables debug logging */
|
|
318
|
-
enableDebug = false;
|
|
319
|
-
/**
|
|
320
|
-
* @param scope Parent construct
|
|
321
|
-
* @param id Unique construct identifier
|
|
322
|
-
* @param props Configuration for table creation or import
|
|
323
|
-
*/
|
|
324
|
-
constructor(scope, id, props) {
|
|
325
|
-
super(scope, id);
|
|
326
|
-
this.enableDebug = props?.enableDebug;
|
|
327
|
-
if (props.options?.fromExistingTableName) {
|
|
328
|
-
this.table = null;
|
|
329
|
-
this.existingTable = Table.fromTableName(
|
|
330
|
-
this,
|
|
331
|
-
`${id}-RefName`,
|
|
332
|
-
props.options.fromExistingTableName
|
|
333
|
-
);
|
|
334
|
-
if (this.enableDebug) {
|
|
335
|
-
printLog(
|
|
336
|
-
_BaseDynamoDBConstruct.name,
|
|
337
|
-
`Created Dynamo-DB table from existing using name ${props.options?.fromExistingTableName}`
|
|
338
|
-
);
|
|
339
|
-
}
|
|
340
|
-
} else if (props.options?.fromExistingTableArn) {
|
|
341
|
-
this.table = null;
|
|
342
|
-
this.existingTable = Table.fromTableArn(
|
|
343
|
-
this,
|
|
344
|
-
`${id}-RefArn`,
|
|
345
|
-
props.options.fromExistingTableArn
|
|
346
|
-
);
|
|
347
|
-
if (this.enableDebug) {
|
|
348
|
-
printLog(
|
|
349
|
-
_BaseDynamoDBConstruct.name,
|
|
350
|
-
`Created Dynamo-DB table from existing using ARN`
|
|
351
|
-
);
|
|
352
|
-
}
|
|
353
|
-
} else if (props.options?.fromExistingTableAttributes) {
|
|
354
|
-
this.table = null;
|
|
355
|
-
this.existingTable = Table.fromTableAttributes(
|
|
356
|
-
this,
|
|
357
|
-
`${id}-RefAttributes`,
|
|
358
|
-
props.options.fromExistingTableAttributes
|
|
359
|
-
);
|
|
360
|
-
if (this.enableDebug) {
|
|
361
|
-
printLog(
|
|
362
|
-
_BaseDynamoDBConstruct.name,
|
|
363
|
-
`Created Dynamo-DB table from existing attributes`
|
|
364
|
-
);
|
|
365
|
-
}
|
|
366
|
-
} else {
|
|
367
|
-
this.existingTable = null;
|
|
368
|
-
this.table = new Table(this, id, {
|
|
369
|
-
...props.options?.tableOptions,
|
|
370
|
-
/**
|
|
371
|
-
* Billing mode defaults to PAY_PER_REQUEST if not provided
|
|
372
|
-
*/
|
|
373
|
-
billingMode: props.options?.tableOptions?.billingMode || BillingMode.PAY_PER_REQUEST,
|
|
374
|
-
/**
|
|
375
|
-
* Deletion protection:
|
|
376
|
-
* - Uses explicit value if provided
|
|
377
|
-
* - Defaults to true in production stage
|
|
378
|
-
*/
|
|
379
|
-
deletionProtection: props.options?.tableOptions?.deletionProtection === true || props.options?.tableOptions?.deletionProtection === false ? props.options.tableOptions.deletionProtection : props.stage === "production"
|
|
380
|
-
});
|
|
381
|
-
if (props.options?.globalSecondaryIndexes?.length) {
|
|
382
|
-
props.options.globalSecondaryIndexes.forEach((globalIndex) => {
|
|
383
|
-
this.table.addGlobalSecondaryIndex(globalIndex);
|
|
384
|
-
if (this.enableDebug) {
|
|
385
|
-
printLog(
|
|
386
|
-
_BaseDynamoDBConstruct.name,
|
|
387
|
-
`Added GSI: ${globalIndex.indexName}`
|
|
388
|
-
);
|
|
389
|
-
}
|
|
390
|
-
});
|
|
391
|
-
}
|
|
392
|
-
if (props.options?.localSecondaryIndexes?.length) {
|
|
393
|
-
props.options.localSecondaryIndexes.forEach((localIndex) => {
|
|
394
|
-
this.table.addLocalSecondaryIndex(localIndex);
|
|
395
|
-
if (this.enableDebug) {
|
|
396
|
-
printLog(
|
|
397
|
-
_BaseDynamoDBConstruct.name,
|
|
398
|
-
`Added LSI: ${localIndex.indexName}`
|
|
399
|
-
);
|
|
400
|
-
}
|
|
401
|
-
});
|
|
402
|
-
}
|
|
403
|
-
}
|
|
404
|
-
new CfnOutput(this, "DynamoDbArn", {
|
|
405
|
-
value: props.options?.fromExistingTableName || props.options?.fromExistingTableArn ? this.existingTable.tableArn : this.table.tableArn
|
|
406
|
-
});
|
|
407
|
-
}
|
|
408
|
-
};
|
|
409
|
-
var BaseEventBridgeConstruct = class extends Construct {
|
|
410
|
-
static {
|
|
411
|
-
__name(this, "BaseEventBridgeConstruct");
|
|
412
|
-
}
|
|
413
|
-
/** The created EventBridge rule instance */
|
|
414
|
-
eventSchedule;
|
|
415
|
-
/**
|
|
416
|
-
* @param scope Parent construct
|
|
417
|
-
* @param id Unique construct identifier
|
|
418
|
-
* @param props Configuration for rule and target functions
|
|
419
|
-
*/
|
|
420
|
-
constructor(scope, id, props) {
|
|
421
|
-
super(scope, id);
|
|
422
|
-
this.eventSchedule = new Rule(this, id, {
|
|
423
|
-
...props.options?.eventBridgeOptions,
|
|
424
|
-
/** Default description if not explicitly provided */
|
|
425
|
-
description: props?.options?.eventBridgeOptions?.description || "An Event-bridge rule"
|
|
426
|
-
});
|
|
427
|
-
if (props.options?.targetFunctions?.length) {
|
|
428
|
-
props.options.targetFunctions.forEach((targetFunction) => {
|
|
429
|
-
this.eventSchedule.addTarget(
|
|
430
|
-
/**
|
|
431
|
-
* Lambda target integration
|
|
432
|
-
*/
|
|
433
|
-
new LambdaFunction(targetFunction)
|
|
434
|
-
);
|
|
435
|
-
});
|
|
436
|
-
}
|
|
437
|
-
this.eventSchedule.applyRemovalPolicy(RemovalPolicy.DESTROY);
|
|
438
|
-
new CfnOutput(this, "EventBridgeArn", {
|
|
439
|
-
value: this.eventSchedule.ruleArn
|
|
440
|
-
});
|
|
441
|
-
}
|
|
442
|
-
};
|
|
443
|
-
var BaseLambdaAuthoriserConstruct = class extends Construct {
|
|
444
|
-
static {
|
|
445
|
-
__name(this, "BaseLambdaAuthoriserConstruct");
|
|
446
|
-
}
|
|
447
|
-
/** The created Token Authorizer instance */
|
|
448
|
-
authoriser;
|
|
449
|
-
/**
|
|
450
|
-
* @param scope Parent construct
|
|
451
|
-
* @param id Unique construct identifier
|
|
452
|
-
* @param props Configuration for authorizer and handler function
|
|
453
|
-
*/
|
|
454
|
-
constructor(scope, id, props) {
|
|
455
|
-
super(scope, id);
|
|
456
|
-
this.authoriser = new TokenAuthorizer(this, id, {
|
|
457
|
-
...props.options?.authorizerOptions,
|
|
458
|
-
/**
|
|
459
|
-
* Lambda handler responsible for request authorization
|
|
460
|
-
*/
|
|
461
|
-
handler: props.handlerFunction
|
|
462
|
-
});
|
|
463
|
-
new CfnOutput(this, "LambdaAuthorizerArn", {
|
|
464
|
-
value: this.authoriser.authorizerArn
|
|
465
|
-
});
|
|
466
|
-
}
|
|
467
|
-
};
|
|
468
|
-
var BaseLambdaAuthoriserV2Construct = class extends Construct {
|
|
469
|
-
static {
|
|
470
|
-
__name(this, "BaseLambdaAuthoriserV2Construct");
|
|
471
|
-
}
|
|
472
|
-
/** The created HTTP Lambda Authorizer instance */
|
|
473
|
-
authoriser;
|
|
474
|
-
/**
|
|
475
|
-
* @param scope Parent construct
|
|
476
|
-
* @param id Unique construct identifier
|
|
477
|
-
* @param props Configuration for authorizer and handler function
|
|
478
|
-
*/
|
|
479
|
-
constructor(scope, id, props) {
|
|
480
|
-
super(scope, id);
|
|
481
|
-
this.authoriser = new HttpLambdaAuthorizer(id, props.handlerFunction, {
|
|
482
|
-
...props?.options?.authorizerOptions,
|
|
483
|
-
/**
|
|
484
|
-
* Identity sources used to extract credentials from incoming requests
|
|
485
|
-
* Defaults to Cookie and Authorization headers
|
|
486
|
-
*/
|
|
487
|
-
identitySource: [
|
|
488
|
-
"$request.header.Cookie",
|
|
489
|
-
"$request.header.Authorization",
|
|
490
|
-
...props?.options?.authorizerOptions?.identitySource
|
|
491
|
-
],
|
|
492
|
-
/**
|
|
493
|
-
* Supported response types for the authorizer
|
|
494
|
-
* Defaults to IAM and SIMPLE responses
|
|
495
|
-
*/
|
|
496
|
-
responseTypes: props?.options?.authorizerOptions?.responseTypes || [HttpLambdaResponseType.IAM, HttpLambdaResponseType.SIMPLE]
|
|
497
|
-
});
|
|
498
|
-
new CfnOutput(this, "LambdaAuthorizerV2_ID", {
|
|
499
|
-
value: this.authoriser.authorizerId
|
|
500
|
-
});
|
|
501
|
-
}
|
|
502
|
-
};
|
|
503
|
-
var BaseLambdaConstruct = class extends Construct {
|
|
504
|
-
static {
|
|
505
|
-
__name(this, "BaseLambdaConstruct");
|
|
506
|
-
}
|
|
507
|
-
/** The created Lambda function instance */
|
|
508
|
-
function;
|
|
509
|
-
/**
|
|
510
|
-
* @param scope Parent construct
|
|
511
|
-
* @param id Unique construct identifier
|
|
512
|
-
* @param props Configuration for Lambda function
|
|
513
|
-
*/
|
|
514
|
-
constructor(scope, id, props) {
|
|
515
|
-
super(scope, id);
|
|
516
|
-
const environment = {
|
|
517
|
-
...props.options?.lambdaOptions?.environment,
|
|
518
|
-
NODE_ENV: props.stage,
|
|
519
|
-
NODE_OPTIONS: "--enable-source-maps",
|
|
520
|
-
AWS_NODEJS_CONNECTION_REUSE_ENABLED: "1"
|
|
521
|
-
};
|
|
522
|
-
detectDuplicateProperties({ data: environment });
|
|
523
|
-
this.function = new Function(this, id, {
|
|
524
|
-
...props?.options?.lambdaOptions,
|
|
525
|
-
/**
|
|
526
|
-
* Lambda function name
|
|
527
|
-
* Defaults to "<stackName>-handler" if not provided
|
|
528
|
-
*/
|
|
529
|
-
functionName: `${props?.options?.lambdaOptions?.functionName || props?.stackName}-handler`,
|
|
530
|
-
/**
|
|
531
|
-
* Function description
|
|
532
|
-
*/
|
|
533
|
-
description: props?.options?.lambdaOptions?.description || "A lambda function",
|
|
534
|
-
/**
|
|
535
|
-
* Entry handler for the Lambda function
|
|
536
|
-
*/
|
|
537
|
-
handler: props?.options?.lambdaOptions?.handler || "lambda.handler",
|
|
538
|
-
/**
|
|
539
|
-
* Runtime environment
|
|
540
|
-
*/
|
|
541
|
-
runtime: props?.options?.lambdaOptions?.runtime || Runtime.NODEJS_24_X,
|
|
542
|
-
/**
|
|
543
|
-
* Execution timeout
|
|
544
|
-
* - 30 seconds in production
|
|
545
|
-
* - 15 seconds otherwise
|
|
546
|
-
*/
|
|
547
|
-
timeout: props?.options?.lambdaOptions?.timeout || Duration.seconds(
|
|
548
|
-
props.stage === AppEnvironmentEnum.PRODUCTION ? 30 : 15
|
|
549
|
-
),
|
|
550
|
-
/**
|
|
551
|
-
* Memory allocation (in MB)
|
|
552
|
-
*/
|
|
553
|
-
memorySize: props?.options?.lambdaOptions?.memorySize || 1024,
|
|
554
|
-
/**
|
|
555
|
-
* CPU architecture
|
|
556
|
-
*/
|
|
557
|
-
architecture: props?.options?.lambdaOptions?.architecture || Architecture.ARM_64,
|
|
558
|
-
/**
|
|
559
|
-
* Lambda deployment package source
|
|
560
|
-
*/
|
|
561
|
-
code: props?.options?.lambdaOptions?.code || Code.fromAsset("dist"),
|
|
562
|
-
/**
|
|
563
|
-
* Final merged environment variables
|
|
564
|
-
*/
|
|
565
|
-
environment
|
|
566
|
-
});
|
|
567
|
-
new CfnOutput(this, "LambdaFunctionArn", {
|
|
568
|
-
value: this.function.functionArn
|
|
569
|
-
});
|
|
570
|
-
}
|
|
571
|
-
};
|
|
572
|
-
var BaseLambdaLayerConstruct = class extends Construct {
|
|
573
|
-
static {
|
|
574
|
-
__name(this, "BaseLambdaLayerConstruct");
|
|
575
|
-
}
|
|
576
|
-
/** Newly created Lambda Layer (null if importing existing layer) */
|
|
577
|
-
layer;
|
|
578
|
-
/** Imported Lambda Layer reference (null if creating new layer) */
|
|
579
|
-
existingLayer;
|
|
580
|
-
/**
|
|
581
|
-
* @param scope Parent construct
|
|
582
|
-
* @param id Unique construct identifier
|
|
583
|
-
* @param props Configuration for layer creation or import
|
|
584
|
-
*/
|
|
585
|
-
constructor(scope, id, props) {
|
|
586
|
-
super(scope, id);
|
|
587
|
-
if (props?.options?.fromExistingLayerArn) {
|
|
588
|
-
this.existingLayer = LayerVersion.fromLayerVersionArn(
|
|
589
|
-
this,
|
|
590
|
-
`${id}-Arn`,
|
|
591
|
-
props?.options?.fromExistingLayerArn
|
|
592
|
-
);
|
|
593
|
-
} else if (props?.options?.fromExistingLayerAttribute) {
|
|
594
|
-
this.existingLayer = LayerVersion.fromLayerVersionAttributes(
|
|
595
|
-
this,
|
|
596
|
-
`${id}-Attribute`,
|
|
597
|
-
props?.options?.fromExistingLayerAttribute
|
|
598
|
-
);
|
|
599
|
-
} else {
|
|
600
|
-
this.layer = new LayerVersion(this, id, {
|
|
601
|
-
...props.options?.layerOptions,
|
|
602
|
-
/**
|
|
603
|
-
* Default layer code asset
|
|
604
|
-
*/
|
|
605
|
-
code: props?.options?.layerOptions?.code || Code.fromAsset("./dist-layer"),
|
|
606
|
-
/**
|
|
607
|
-
* Layer description
|
|
608
|
-
*/
|
|
609
|
-
description: props?.options?.layerOptions?.description || "Lambda Layer written in NodeJS, NestJS, NodeJS-express, serverless-express",
|
|
610
|
-
/**
|
|
611
|
-
* Supported CPU architectures
|
|
612
|
-
*/
|
|
613
|
-
compatibleArchitectures: [
|
|
614
|
-
Architecture.ARM_64,
|
|
615
|
-
Architecture.X86_64
|
|
616
|
-
],
|
|
617
|
-
/**
|
|
618
|
-
* Supported runtimes
|
|
619
|
-
*/
|
|
620
|
-
compatibleRuntimes: [
|
|
621
|
-
Runtime.NODEJS_22_X,
|
|
622
|
-
Runtime.NODEJS_24_X,
|
|
623
|
-
Runtime.NODEJS_LATEST
|
|
624
|
-
]
|
|
625
|
-
});
|
|
626
|
-
}
|
|
627
|
-
new CfnOutput(this, "LambdaLayerArn", {
|
|
628
|
-
value: props.options?.fromExistingLayerArn || props.options?.fromExistingLayerAttribute ? this.existingLayer.layerVersionArn : this.layer.layerVersionArn
|
|
629
|
-
});
|
|
630
|
-
}
|
|
631
|
-
};
|
|
632
|
-
var BaseRolePolicyConstruct = class extends Construct {
|
|
633
|
-
static {
|
|
634
|
-
__name(this, "BaseRolePolicyConstruct");
|
|
635
|
-
}
|
|
636
|
-
/** The created IAM Role instance */
|
|
637
|
-
role;
|
|
638
|
-
/**
|
|
639
|
-
* @param scope Parent construct
|
|
640
|
-
* @param id Unique construct identifier
|
|
641
|
-
* @param props Configuration for role and policies
|
|
642
|
-
*/
|
|
643
|
-
constructor(scope, id, props) {
|
|
644
|
-
super(scope, id);
|
|
645
|
-
this.role = new Role(this, id, {
|
|
646
|
-
...props.options?.roleOptions,
|
|
647
|
-
/**
|
|
648
|
-
* Managed policies attached to the role
|
|
649
|
-
* Defaults to AWSLambdaBasicExecutionRole if not provided
|
|
650
|
-
*/
|
|
651
|
-
managedPolicies: props.options?.roleOptions?.managedPolicies ? props.options.roleOptions.managedPolicies : [
|
|
652
|
-
ManagedPolicy.fromAwsManagedPolicyName(
|
|
653
|
-
"service-role/AWSLambdaBasicExecutionRole"
|
|
654
|
-
)
|
|
655
|
-
]
|
|
656
|
-
});
|
|
657
|
-
if (props?.policies?.length) {
|
|
658
|
-
props.policies.forEach((policy) => {
|
|
659
|
-
this.role.addToPolicy(
|
|
660
|
-
/**
|
|
661
|
-
* Inline policy statement
|
|
662
|
-
*/
|
|
663
|
-
new PolicyStatement(policy)
|
|
664
|
-
);
|
|
665
|
-
});
|
|
666
|
-
}
|
|
667
|
-
this.role.applyRemovalPolicy(RemovalPolicy.DESTROY);
|
|
668
|
-
new CfnOutput(this, "RolePolicyArn", {
|
|
669
|
-
value: this.role.roleArn
|
|
670
|
-
});
|
|
671
|
-
}
|
|
672
|
-
};
|
|
673
|
-
var BaseS3Construct = class extends Construct {
|
|
674
|
-
static {
|
|
675
|
-
__name(this, "BaseS3Construct");
|
|
676
|
-
}
|
|
677
|
-
/** The created S3 bucket instance */
|
|
678
|
-
bucket;
|
|
679
|
-
/**
|
|
680
|
-
* @param scope Parent construct
|
|
681
|
-
* @param id Unique construct identifier
|
|
682
|
-
* @param props Configuration for S3 bucket
|
|
683
|
-
*/
|
|
684
|
-
constructor(scope, id, props) {
|
|
685
|
-
super(scope, id);
|
|
686
|
-
this.bucket = new Bucket(this, id, {
|
|
687
|
-
...props.options?.bucketOptions,
|
|
688
|
-
/**
|
|
689
|
-
* Removal policy applied to the bucket
|
|
690
|
-
* Defaults to DESTROY if not explicitly defined
|
|
691
|
-
*/
|
|
692
|
-
removalPolicy: props.options?.bucketOptions?.removalPolicy || RemovalPolicy.DESTROY
|
|
693
|
-
});
|
|
694
|
-
new CfnOutput(this, "S3BucketArn", {
|
|
695
|
-
value: this.bucket.bucketArn
|
|
696
|
-
});
|
|
697
|
-
}
|
|
698
|
-
};
|
|
699
|
-
var BaseS3DeploymentConstruct = class extends Construct {
|
|
700
|
-
static {
|
|
701
|
-
__name(this, "BaseS3DeploymentConstruct");
|
|
702
|
-
}
|
|
703
|
-
/** The created or provided S3 bucket */
|
|
704
|
-
bucket;
|
|
705
|
-
/** The created CloudFront distribution */
|
|
706
|
-
distribution;
|
|
707
|
-
/** S3 bucket deployment instance */
|
|
708
|
-
bucketDeployment;
|
|
709
|
-
/**
|
|
710
|
-
* @param scope Parent construct
|
|
711
|
-
* @param id Unique construct identifier
|
|
712
|
-
* @param props Configuration for bucket, distribution, and deployment
|
|
713
|
-
*/
|
|
714
|
-
constructor(scope, id, props) {
|
|
715
|
-
super(scope, id);
|
|
716
|
-
if (!props.options?.cloudfrontOptions?.defaultBehavior?.origin && !props?.withS3Bucket && props.withCloudfront) {
|
|
717
|
-
throw new CustomException("Cloudfront distribution S3_Bucket origins must be defined!");
|
|
718
|
-
}
|
|
719
|
-
if (!props.options?.bucketDeploymentOptions?.destinationBucket && !props?.withS3Bucket) {
|
|
720
|
-
throw new CustomException("Deployment S3_Bucket destination must be defined!");
|
|
721
|
-
}
|
|
722
|
-
if (props?.withS3Bucket) {
|
|
723
|
-
this.bucket = new BaseS3Construct(this, "bucket", {
|
|
724
|
-
enableDebug: props.enableDebug,
|
|
725
|
-
options: { bucketOptions: props.options?.bucketOptions }
|
|
726
|
-
}).bucket;
|
|
727
|
-
}
|
|
728
|
-
if (props?.withCloudfront) {
|
|
729
|
-
const s3Origin = props.options?.cloudfrontOptions?.defaultBehavior?.origin || S3BucketOrigin.withOriginAccessControl(this.bucket);
|
|
730
|
-
this.distribution = new BaseCloudfrontConstruct(this, "distribution", {
|
|
731
|
-
enableDebug: props.enableDebug,
|
|
732
|
-
options: {
|
|
733
|
-
cloudfrontOptions: {
|
|
734
|
-
...props.options?.cloudfrontOptions,
|
|
735
|
-
/**
|
|
736
|
-
* Map additional behaviors and ensure origin is assigned
|
|
737
|
-
*/
|
|
738
|
-
additionalBehaviors: Object.entries(props.options?.cloudfrontOptions?.additionalBehaviors || {}).reduce((behavior, [pattern, behaviorOptions]) => {
|
|
739
|
-
behavior[pattern] = {
|
|
740
|
-
...behaviorOptions,
|
|
741
|
-
origin: behaviorOptions.origin || s3Origin
|
|
742
|
-
};
|
|
743
|
-
return behavior;
|
|
744
|
-
}, {}),
|
|
745
|
-
/**
|
|
746
|
-
* Default behavior configuration
|
|
747
|
-
*/
|
|
748
|
-
defaultBehavior: {
|
|
749
|
-
...props.options?.cloudfrontOptions?.defaultBehavior,
|
|
750
|
-
origin: s3Origin
|
|
751
|
-
}
|
|
752
|
-
}
|
|
753
|
-
}
|
|
754
|
-
}).distribution;
|
|
755
|
-
}
|
|
756
|
-
this.bucketDeployment = new BucketDeployment(this, "deployment", {
|
|
757
|
-
...props.options?.bucketDeploymentOptions,
|
|
758
|
-
/** Target distribution for cache invalidation */
|
|
759
|
-
distribution: props.options?.bucketDeploymentOptions?.distribution || this.distribution,
|
|
760
|
-
/** Paths to invalidate after deployment */
|
|
761
|
-
distributionPaths: props.options?.bucketDeploymentOptions?.distributionPaths || ["/*"],
|
|
762
|
-
/** Destination S3 bucket */
|
|
763
|
-
destinationBucket: props.options?.bucketDeploymentOptions?.destinationBucket || this.bucket
|
|
764
|
-
});
|
|
765
|
-
}
|
|
766
|
-
};
|
|
767
|
-
var BaseSnsConstruct = class extends Construct {
|
|
768
|
-
static {
|
|
769
|
-
__name(this, "BaseSnsConstruct");
|
|
770
|
-
}
|
|
771
|
-
/** The created SNS topic instance */
|
|
772
|
-
topic;
|
|
773
|
-
/**
|
|
774
|
-
* @param scope Parent construct
|
|
775
|
-
* @param id Unique construct identifier
|
|
776
|
-
* @param props Configuration for topic and subscriptions
|
|
777
|
-
*/
|
|
778
|
-
constructor(scope, id, props) {
|
|
779
|
-
super(scope, id);
|
|
780
|
-
this.topic = new Topic(this, id, props.options?.topicOptions);
|
|
781
|
-
if (props.options?.targetFunctions?.length) {
|
|
782
|
-
props.options.targetFunctions.forEach((targetFunction) => {
|
|
783
|
-
this.topic.addSubscription(
|
|
784
|
-
/**
|
|
785
|
-
* Lambda subscription target
|
|
786
|
-
*/
|
|
787
|
-
new LambdaSubscription(targetFunction)
|
|
788
|
-
);
|
|
789
|
-
});
|
|
790
|
-
}
|
|
791
|
-
this.topic.applyRemovalPolicy(RemovalPolicy.DESTROY);
|
|
792
|
-
new CfnOutput(this, "SnsTopicArn", {
|
|
793
|
-
value: this.topic.topicArn
|
|
794
|
-
});
|
|
795
|
-
}
|
|
796
|
-
};
|
|
797
|
-
var BaseSqsConstruct = class extends Construct {
|
|
798
|
-
static {
|
|
799
|
-
__name(this, "BaseSqsConstruct");
|
|
800
|
-
}
|
|
801
|
-
/** The created SQS queue instance */
|
|
802
|
-
queue;
|
|
803
|
-
/**
|
|
804
|
-
* @param scope Parent construct
|
|
805
|
-
* @param id Unique construct identifier
|
|
806
|
-
* @param props Configuration for queue and Lambda consumers
|
|
807
|
-
*/
|
|
808
|
-
constructor(scope, id, props) {
|
|
809
|
-
super(scope, id);
|
|
810
|
-
this.queue = new Queue(this, id, {
|
|
811
|
-
...props?.options?.queueOptions,
|
|
812
|
-
/**
|
|
813
|
-
* Removal policy applied to the queue
|
|
814
|
-
* Defaults to DESTROY if not explicitly defined
|
|
815
|
-
*/
|
|
816
|
-
removalPolicy: props?.options?.queueOptions?.removalPolicy || RemovalPolicy.DESTROY
|
|
817
|
-
});
|
|
818
|
-
if (props?.targetFunctions?.length) {
|
|
819
|
-
props.targetFunctions.forEach((targetFunction, index) => {
|
|
820
|
-
new EventSourceMapping(this, `${id}-eventSourceMap${index + 1}`, {
|
|
821
|
-
...props?.options?.eventSourceMappingOptions,
|
|
822
|
-
/** Target Lambda function */
|
|
823
|
-
target: targetFunction,
|
|
824
|
-
/** Source SQS queue ARN */
|
|
825
|
-
eventSourceArn: this.queue.queueArn,
|
|
826
|
-
/**
|
|
827
|
-
* Retry attempts for failed batch processing
|
|
828
|
-
* Defaults to 3 if not explicitly defined
|
|
829
|
-
*/
|
|
830
|
-
retryAttempts: props?.options?.eventSourceMappingOptions?.retryAttempts || 3
|
|
831
|
-
});
|
|
832
|
-
});
|
|
833
|
-
}
|
|
834
|
-
new CfnOutput(this, "SqsQueueArn", {
|
|
835
|
-
value: this.queue.queueArn
|
|
836
|
-
});
|
|
837
|
-
}
|
|
838
|
-
};
|
|
839
|
-
var BaseVpcConstruct = class extends Construct {
|
|
840
|
-
static {
|
|
841
|
-
__name(this, "BaseVpcConstruct");
|
|
842
|
-
}
|
|
843
|
-
/** The created VPC instance */
|
|
844
|
-
vpc;
|
|
845
|
-
/**
|
|
846
|
-
* @param scope Parent construct
|
|
847
|
-
* @param id Unique construct identifier
|
|
848
|
-
* @param props Configuration for VPC
|
|
849
|
-
*/
|
|
850
|
-
constructor(scope, id, props) {
|
|
851
|
-
super(scope, id);
|
|
852
|
-
this.vpc = new Vpc(this, id, {
|
|
853
|
-
...props.options.vpcOptions
|
|
854
|
-
});
|
|
855
|
-
new CfnOutput(this, "VpcArn", {
|
|
856
|
-
value: this.vpc.vpcArn
|
|
857
|
-
});
|
|
858
|
-
}
|
|
859
|
-
};
|
|
860
|
-
|
|
861
|
-
export { BaseApiGatewayConstruct, BaseApiGatewayV2Construct, BaseApiGatewayWebSocketConstruct, BaseCloudfrontConstruct, BaseCloudwatchLogGroupConstruct, BaseDynamoDBConstruct, BaseEventBridgeConstruct, BaseLambdaAuthoriserConstruct, BaseLambdaAuthoriserV2Construct, BaseLambdaConstruct, BaseLambdaLayerConstruct, BaseRolePolicyConstruct, BaseS3Construct, BaseS3DeploymentConstruct, BaseSnsConstruct, BaseSqsConstruct, BaseVpcConstruct };
|
|
862
|
-
//# sourceMappingURL=index.js.map
|
|
863
|
-
//# sourceMappingURL=index.js.map
|