@certenza/aws-cdk-infrastructure-commons 1.0.0

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 ADDED
@@ -0,0 +1,76 @@
1
+ # @certenza/aws-cdk-infrastructure-commons
2
+
3
+ A private npm package containing common infrastructure utilities and resources for CDK typescript projects. This package provides reusable AWS CDK constructs and utilities to maintain consistency across infrastructure codebases.
4
+
5
+ ## Installation
6
+
7
+ ```bash
8
+ npm install @certenza/aws-cdk-infrastructure-commons
9
+ ```
10
+
11
+ ## Usage
12
+
13
+ ```typescript
14
+ import { cdkOutput } from "@certenza/aws-cdk-infrastructure-commons";
15
+
16
+ // Use the utilities in your CDK stack
17
+ cdkOutput(stack, "MyOutput", "my-value", "Description of the output");
18
+ ```
19
+
20
+ ## Available Resources
21
+
22
+ ### CDK Utilities
23
+
24
+ - **`cdkOutput`** - Creates CDK outputs with consistent naming conventions
25
+
26
+ ### AWS Resources
27
+
28
+ - **ACM** - AWS Certificate Manager utilities
29
+ - **API Gateway** - API Gateway constructs and utilities
30
+ - **CDK** - CDK and utilities
31
+ - **DynamoDB** - DynamoDB table and index utilities
32
+ - **Lambda** - Lambda function utilities
33
+ - **Open Search** - Open Search utilities
34
+ - **Route53** - DNS and routing utilities
35
+ - **Secrets Manager** - Secrets Manager utilities
36
+ - **SQS** - Simple Queue Service utilities
37
+
38
+ ## Project Structure
39
+
40
+ ```
41
+ src/
42
+ ├── acm.ts # AWS Certificate Manager utilities
43
+ ├── apigateway.ts # API Gateway constructs
44
+ ├── cdk.ts # CDK utility functions
45
+ ├── dynamodb.ts # DynamoDB utilities
46
+ ├── lambda.ts # Lambda function utilities
47
+ ├── opensearch.ts # Open Search utilities
48
+ ├── route53.ts # Route53 DNS utilities
49
+ └── sqs.ts # SQS queue utilities
50
+ └── secretsmanager.ts # Secrets manager utilities
51
+ ```
52
+
53
+ ## Development
54
+
55
+ ### Prerequisites
56
+
57
+ - Node.js >= 22.0.0
58
+ - npm
59
+
60
+ ### Setup
61
+
62
+ ```bash
63
+ npm install
64
+ ```
65
+
66
+ ### Build
67
+
68
+ ```bash
69
+ npm run build
70
+ ```
71
+
72
+ ### Publish
73
+
74
+ ```bash
75
+ npm publish
76
+ ```
@@ -0,0 +1,12 @@
1
+ export * as cdk from "aws-cdk-lib";
2
+ export * as apigateway from "aws-cdk-lib/aws-apigateway";
3
+ export { Construct } from "constructs";
4
+ export * from "./src/acm";
5
+ export * from "./src/apigateway";
6
+ export * from "./src/cdk";
7
+ export * from "./src/dynamodb";
8
+ export * from "./src/lambda";
9
+ export * from "./src/route53";
10
+ export * from "./src/sqs";
11
+ export * from "./src/secretsmanager";
12
+ export * from "./src/opensearch";
package/dist/index.js ADDED
@@ -0,0 +1,54 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || (function () {
19
+ var ownKeys = function(o) {
20
+ ownKeys = Object.getOwnPropertyNames || function (o) {
21
+ var ar = [];
22
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
+ return ar;
24
+ };
25
+ return ownKeys(o);
26
+ };
27
+ return function (mod) {
28
+ if (mod && mod.__esModule) return mod;
29
+ var result = {};
30
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
+ __setModuleDefault(result, mod);
32
+ return result;
33
+ };
34
+ })();
35
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
36
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
37
+ };
38
+ Object.defineProperty(exports, "__esModule", { value: true });
39
+ exports.Construct = exports.apigateway = exports.cdk = void 0;
40
+ // Export all CDK libraries
41
+ exports.cdk = __importStar(require("aws-cdk-lib"));
42
+ exports.apigateway = __importStar(require("aws-cdk-lib/aws-apigateway"));
43
+ var constructs_1 = require("constructs");
44
+ Object.defineProperty(exports, "Construct", { enumerable: true, get: function () { return constructs_1.Construct; } });
45
+ // Export all infrastructure resources
46
+ __exportStar(require("./src/acm"), exports);
47
+ __exportStar(require("./src/apigateway"), exports);
48
+ __exportStar(require("./src/cdk"), exports);
49
+ __exportStar(require("./src/dynamodb"), exports);
50
+ __exportStar(require("./src/lambda"), exports);
51
+ __exportStar(require("./src/route53"), exports);
52
+ __exportStar(require("./src/sqs"), exports);
53
+ __exportStar(require("./src/secretsmanager"), exports);
54
+ __exportStar(require("./src/opensearch"), exports);
@@ -0,0 +1,13 @@
1
+ import * as acm from "aws-cdk-lib/aws-certificatemanager";
2
+ import { Construct } from "constructs";
3
+ import * as route53 from "aws-cdk-lib/aws-route53";
4
+ /**
5
+ * Creates a certificate for a domain name
6
+ * @param scope - The scope of the certificate
7
+ * @param id - The id of the certificate
8
+ * @param domainName - The domain name of the certificate
9
+ * @param hostedZone - The hosted zone of the certificate
10
+ * @returns The certificate
11
+ */
12
+ declare const createCertificate: (scope: Construct, id: string, domainName: string, hostedZone: route53.IHostedZone) => acm.Certificate;
13
+ export { createCertificate };
@@ -0,0 +1,52 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || (function () {
19
+ var ownKeys = function(o) {
20
+ ownKeys = Object.getOwnPropertyNames || function (o) {
21
+ var ar = [];
22
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
+ return ar;
24
+ };
25
+ return ownKeys(o);
26
+ };
27
+ return function (mod) {
28
+ if (mod && mod.__esModule) return mod;
29
+ var result = {};
30
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
+ __setModuleDefault(result, mod);
32
+ return result;
33
+ };
34
+ })();
35
+ Object.defineProperty(exports, "__esModule", { value: true });
36
+ exports.createCertificate = void 0;
37
+ const acm = __importStar(require("aws-cdk-lib/aws-certificatemanager"));
38
+ /**
39
+ * Creates a certificate for a domain name
40
+ * @param scope - The scope of the certificate
41
+ * @param id - The id of the certificate
42
+ * @param domainName - The domain name of the certificate
43
+ * @param hostedZone - The hosted zone of the certificate
44
+ * @returns The certificate
45
+ */
46
+ const createCertificate = (scope, id, domainName, hostedZone) => {
47
+ return new acm.Certificate(scope, id, {
48
+ domainName: domainName,
49
+ validation: acm.CertificateValidation.fromDns(hostedZone),
50
+ });
51
+ };
52
+ exports.createCertificate = createCertificate;
@@ -0,0 +1,20 @@
1
+ import * as apigateway from "aws-cdk-lib/aws-apigateway";
2
+ import { Construct } from "constructs";
3
+ /**
4
+ * Gets the domain name for the API Gateway
5
+ * @param environment - The environment to get the domain name for
6
+ * @param domainName - The root domain name (example: mydomain.com)
7
+ * @returns The domain name for the API Gateway
8
+ */
9
+ declare const getApiGatewayDomainName: (service: string, domainName: string, environment: string) => string;
10
+ /**
11
+ * Creates an API Gateway with the given parameters
12
+ * @param scope - The scope of the API Gateway
13
+ * @param apiName - The name of the API Gateway
14
+ * @param domainName - The domain name of the API Gateway
15
+ * @param hostedZoneId - The ID of the hosted zone
16
+ * @param zoneName - The name of the hosted zone
17
+ * @returns The API Gateway
18
+ */
19
+ declare const createApiGateway: (scope: Construct, apiName: string, domainName: string, hostedZoneId: string, zoneName: string) => apigateway.RestApi;
20
+ export { createApiGateway, getApiGatewayDomainName };
@@ -0,0 +1,95 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || (function () {
19
+ var ownKeys = function(o) {
20
+ ownKeys = Object.getOwnPropertyNames || function (o) {
21
+ var ar = [];
22
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
+ return ar;
24
+ };
25
+ return ownKeys(o);
26
+ };
27
+ return function (mod) {
28
+ if (mod && mod.__esModule) return mod;
29
+ var result = {};
30
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
+ __setModuleDefault(result, mod);
32
+ return result;
33
+ };
34
+ })();
35
+ Object.defineProperty(exports, "__esModule", { value: true });
36
+ exports.getApiGatewayDomainName = exports.createApiGateway = void 0;
37
+ const apigateway = __importStar(require("aws-cdk-lib/aws-apigateway"));
38
+ const logs = __importStar(require("aws-cdk-lib/aws-logs"));
39
+ const route53 = __importStar(require("aws-cdk-lib/aws-route53"));
40
+ const route53targets = __importStar(require("aws-cdk-lib/aws-route53-targets"));
41
+ const acm_1 = require("./acm");
42
+ const route53_1 = require("./route53");
43
+ /**
44
+ * Gets the domain name for the API Gateway
45
+ * @param environment - The environment to get the domain name for
46
+ * @param domainName - The root domain name (example: mydomain.com)
47
+ * @returns The domain name for the API Gateway
48
+ */
49
+ const getApiGatewayDomainName = (service, domainName, environment) => {
50
+ return environment === "production"
51
+ ? `api.${service}.${domainName}`
52
+ : `api.${service}.${environment}.${domainName}`;
53
+ };
54
+ exports.getApiGatewayDomainName = getApiGatewayDomainName;
55
+ /**
56
+ * Creates an API Gateway with the given parameters
57
+ * @param scope - The scope of the API Gateway
58
+ * @param apiName - The name of the API Gateway
59
+ * @param domainName - The domain name of the API Gateway
60
+ * @param hostedZoneId - The ID of the hosted zone
61
+ * @param zoneName - The name of the hosted zone
62
+ * @returns The API Gateway
63
+ */
64
+ const createApiGateway = (scope, apiName, domainName, hostedZoneId, zoneName) => {
65
+ // Import the existing hosted zone
66
+ const hostedZone = (0, route53_1.getHostedZone)(scope, "HostedZone", hostedZoneId, zoneName);
67
+ // Create a certificate for the API Gateway domain
68
+ const certificate = (0, acm_1.createCertificate)(scope, `ApiGatewayCertificate`, domainName, hostedZone);
69
+ const api = new apigateway.RestApi(scope, apiName, {
70
+ description: `Public API Gateway for ${apiName}`,
71
+ endpointTypes: [apigateway.EndpointType.REGIONAL],
72
+ domainName: {
73
+ domainName: domainName,
74
+ certificate: certificate,
75
+ securityPolicy: apigateway.SecurityPolicy.TLS_1_2,
76
+ endpointType: apigateway.EndpointType.REGIONAL,
77
+ },
78
+ deployOptions: {
79
+ loggingLevel: apigateway.MethodLoggingLevel.INFO,
80
+ dataTraceEnabled: false,
81
+ accessLogDestination: new apigateway.LogGroupLogDestination(new logs.LogGroup(scope, `${apiName}-AccessLogs`, {
82
+ retention: logs.RetentionDays.ONE_WEEK,
83
+ })),
84
+ },
85
+ });
86
+ // Create Route53 A record pointing to the API Gateway
87
+ new route53.ARecord(scope, `${apiName}-AliasRecord`, {
88
+ zone: hostedZone,
89
+ recordName: domainName.replace(`${hostedZone.zoneName}.`, ""),
90
+ target: route53.RecordTarget.fromAlias(new route53targets.ApiGateway(api)),
91
+ });
92
+ // Return the API Gateway
93
+ return api;
94
+ };
95
+ exports.createApiGateway = createApiGateway;
@@ -0,0 +1,10 @@
1
+ import * as cdk from "aws-cdk-lib";
2
+ /**
3
+ * Creates a CDK output
4
+ * @param stack - The stack to create the output in
5
+ * @param id - The id of the output
6
+ * @param value - The value of the output
7
+ * @param description - The description of the output
8
+ */
9
+ declare const cdkOutput: (stack: cdk.Stack, id: string, value: string, description: string) => void;
10
+ export { cdkOutput };
@@ -0,0 +1,52 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || (function () {
19
+ var ownKeys = function(o) {
20
+ ownKeys = Object.getOwnPropertyNames || function (o) {
21
+ var ar = [];
22
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
+ return ar;
24
+ };
25
+ return ownKeys(o);
26
+ };
27
+ return function (mod) {
28
+ if (mod && mod.__esModule) return mod;
29
+ var result = {};
30
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
+ __setModuleDefault(result, mod);
32
+ return result;
33
+ };
34
+ })();
35
+ Object.defineProperty(exports, "__esModule", { value: true });
36
+ exports.cdkOutput = void 0;
37
+ const cdk = __importStar(require("aws-cdk-lib"));
38
+ /**
39
+ * Creates a CDK output
40
+ * @param stack - The stack to create the output in
41
+ * @param id - The id of the output
42
+ * @param value - The value of the output
43
+ * @param description - The description of the output
44
+ */
45
+ const cdkOutput = (stack, id, value, description) => {
46
+ new cdk.CfnOutput(stack, id, {
47
+ value,
48
+ description,
49
+ exportName: `${stack.stackName}-${id}`,
50
+ });
51
+ };
52
+ exports.cdkOutput = cdkOutput;
@@ -0,0 +1,33 @@
1
+ import * as cdk from "aws-cdk-lib";
2
+ import * as dynamodb from "aws-cdk-lib/aws-dynamodb";
3
+ import { Construct } from "constructs";
4
+ /**
5
+ * The key for the DynamoDB table
6
+ * @param pk - The partition key
7
+ * @param sk - The sort key
8
+ */
9
+ type DynamoDBKeys = {
10
+ pk: string;
11
+ sk?: string;
12
+ };
13
+ /**
14
+ * The index for the DynamoDB table
15
+ * @param name - The name of the index
16
+ * @param keys - The keys for the index
17
+ */
18
+ type DynamoDBIndex = {
19
+ name: string;
20
+ keys: DynamoDBKeys;
21
+ };
22
+ /**
23
+ * Creates a DynamoDB table
24
+ * @param scope - The scope of the DynamoDB table
25
+ * @param tableName - The name of the DynamoDB table
26
+ * @param keys - The keys of the DynamoDB table
27
+ * @param indexes - The indexes of the DynamoDB table
28
+ * @param options - The options of the DynamoDB table
29
+ * @returns The DynamoDB table
30
+ */
31
+ declare const createDynamoDBTable: (scope: Construct, tableName: string, keys: DynamoDBKeys, indexes: DynamoDBIndex[], options?: Partial<dynamodb.TableProps>) => cdk.aws_dynamodb.Table;
32
+ export { createDynamoDBTable };
33
+ export type { DynamoDBIndex, DynamoDBKeys };
@@ -0,0 +1,99 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || (function () {
19
+ var ownKeys = function(o) {
20
+ ownKeys = Object.getOwnPropertyNames || function (o) {
21
+ var ar = [];
22
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
+ return ar;
24
+ };
25
+ return ownKeys(o);
26
+ };
27
+ return function (mod) {
28
+ if (mod && mod.__esModule) return mod;
29
+ var result = {};
30
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
+ __setModuleDefault(result, mod);
32
+ return result;
33
+ };
34
+ })();
35
+ Object.defineProperty(exports, "__esModule", { value: true });
36
+ exports.createDynamoDBTable = void 0;
37
+ const cdk = __importStar(require("aws-cdk-lib"));
38
+ const dynamodb = __importStar(require("aws-cdk-lib/aws-dynamodb"));
39
+ /**
40
+ * Creates a DynamoDB table
41
+ * @param scope - The scope of the DynamoDB table
42
+ * @param tableName - The name of the DynamoDB table
43
+ * @param keys - The keys of the DynamoDB table
44
+ * @param indexes - The indexes of the DynamoDB table
45
+ * @param options - The options of the DynamoDB table
46
+ * @returns The DynamoDB table
47
+ */
48
+ const createDynamoDBTable = (scope, tableName, keys, indexes, options = {}) => {
49
+ // Create the table props
50
+ let tableProps = {
51
+ tableName,
52
+ partitionKey: {
53
+ name: keys.pk,
54
+ type: dynamodb.AttributeType.STRING,
55
+ },
56
+ billingMode: dynamodb.BillingMode.PAY_PER_REQUEST, // On-demand
57
+ removalPolicy: cdk.RemovalPolicy.DESTROY, // For testing; use RETAIN in production
58
+ ...options,
59
+ };
60
+ // If a sort key is provided, add it to the table props
61
+ if (keys.sk) {
62
+ tableProps = {
63
+ ...tableProps,
64
+ sortKey: {
65
+ name: keys.sk,
66
+ type: dynamodb.AttributeType.STRING,
67
+ },
68
+ };
69
+ }
70
+ // Create the DynamoDB table
71
+ let table = new dynamodb.Table(scope, `${tableName}Table`, tableProps);
72
+ // Add the Global Secondary Indexes
73
+ indexes.forEach(index => {
74
+ // Create the index props
75
+ let indexProps = {
76
+ indexName: index.name,
77
+ partitionKey: {
78
+ name: index.keys.pk,
79
+ type: dynamodb.AttributeType.STRING,
80
+ },
81
+ projectionType: dynamodb.ProjectionType.ALL, // Include all attributes in the index
82
+ };
83
+ // If a sort key is provided, add it to the index props
84
+ if (index.keys.sk) {
85
+ indexProps = {
86
+ ...indexProps,
87
+ sortKey: {
88
+ name: index.keys.sk,
89
+ type: dynamodb.AttributeType.STRING,
90
+ },
91
+ };
92
+ }
93
+ // Add the index to the table
94
+ table.addGlobalSecondaryIndex(indexProps);
95
+ });
96
+ // Return the DynamoDB table
97
+ return table;
98
+ };
99
+ exports.createDynamoDBTable = createDynamoDBTable;
@@ -0,0 +1,35 @@
1
+ /**
2
+ * Lambda functions and integrations
3
+ */
4
+ import * as cdk from "aws-cdk-lib";
5
+ import * as lambda from "aws-cdk-lib/aws-lambda";
6
+ import * as nodejs from "aws-cdk-lib/aws-lambda-nodejs";
7
+ import { Construct } from "constructs";
8
+ /**
9
+ * Properties for creating a lambda function
10
+ * @param policies - The policies of the lambda function
11
+ * @param environmentVariables - The environment variables of the lambda function
12
+ * @param options - The options of the lambda function
13
+ */
14
+ type CreateLambdaFunctionProps = {
15
+ policies?: cdk.aws_iam.PolicyStatementProps[];
16
+ environmentVariables?: Record<string, string>;
17
+ options?: Partial<nodejs.NodejsFunctionProps>;
18
+ };
19
+ /**
20
+ * Creates a lambda function with the given parameters
21
+ * @param scope - The scope of the lambda function
22
+ * @param functionName - The name of the lambda function (will be also used as the id)
23
+ * @param environment - The environment of the lambda function
24
+ * @param props - The properties of the lambda function
25
+ * @returns The lambda function
26
+ */
27
+ declare const createLambdaFunction: (scope: Construct, functionName: string, environment: string, props?: CreateLambdaFunctionProps) => nodejs.NodejsFunction;
28
+ /**
29
+ * Creates a lambda integration for a lambda function
30
+ * @param lambdaFunction - The lambda function to create an integration for
31
+ * @returns The lambda integration
32
+ */
33
+ declare const createLambdaApiGatewayIntegration: (lambdaFunction: lambda.Function) => cdk.aws_apigateway.LambdaIntegration;
34
+ export { createLambdaFunction, createLambdaApiGatewayIntegration };
35
+ export type { CreateLambdaFunctionProps };
@@ -0,0 +1,121 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || (function () {
19
+ var ownKeys = function(o) {
20
+ ownKeys = Object.getOwnPropertyNames || function (o) {
21
+ var ar = [];
22
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
+ return ar;
24
+ };
25
+ return ownKeys(o);
26
+ };
27
+ return function (mod) {
28
+ if (mod && mod.__esModule) return mod;
29
+ var result = {};
30
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
+ __setModuleDefault(result, mod);
32
+ return result;
33
+ };
34
+ })();
35
+ Object.defineProperty(exports, "__esModule", { value: true });
36
+ exports.createLambdaApiGatewayIntegration = exports.createLambdaFunction = void 0;
37
+ /**
38
+ * Lambda functions and integrations
39
+ */
40
+ const cdk = __importStar(require("aws-cdk-lib"));
41
+ const lambda = __importStar(require("aws-cdk-lib/aws-lambda"));
42
+ const nodejs = __importStar(require("aws-cdk-lib/aws-lambda-nodejs"));
43
+ const logs = __importStar(require("aws-cdk-lib/aws-logs"));
44
+ const apigateway = __importStar(require("aws-cdk-lib/aws-apigateway"));
45
+ /**
46
+ * Creates a lambda function with the given parameters
47
+ * @param scope - The scope of the lambda function
48
+ * @param functionName - The name of the lambda function (will be also used as the id)
49
+ * @param environment - The environment of the lambda function
50
+ * @param props - The properties of the lambda function
51
+ * @returns The lambda function
52
+ */
53
+ const createLambdaFunction = (scope, functionName, environment, props = {}) => {
54
+ // Define the id of the lambda function
55
+ const id = functionName;
56
+ // Define the policies of the lambda function
57
+ const policies = props.policies ?? [];
58
+ // Define the environment variables of the lambda function
59
+ const environmentVariables = props.environmentVariables ?? {};
60
+ // Define the options of the lambda function
61
+ const options = props.options ?? {};
62
+ // Create the lambda function
63
+ const lambdaFunction = new nodejs.NodejsFunction(scope, id, {
64
+ entry: `src/lambdas/${functionName}/handler.ts`,
65
+ functionName: functionName,
66
+ handler: "handler",
67
+ runtime: lambda.Runtime.NODEJS_22_X,
68
+ architecture: lambda.Architecture.ARM_64,
69
+ memorySize: 256,
70
+ timeout: cdk.Duration.seconds(30),
71
+ environment: {
72
+ ENVIRONMENT: environment,
73
+ NODE_ENV: environment === "production" ? "production" : "development",
74
+ ...environmentVariables,
75
+ },
76
+ bundling: {
77
+ minify: true,
78
+ sourceMap: false,
79
+ target: "es2022",
80
+ format: nodejs.OutputFormat.CJS,
81
+ mainFields: ["module", "main"],
82
+ externalModules: ["aws-sdk", "util", "crypto", "stream"], // AWS SDK is provided by Lambda runtime
83
+ forceDockerBundling: false, // Use esbuild directly instead of Docker
84
+ platform: "node",
85
+ },
86
+ description: `${id} lambda function for ${environment} environment`,
87
+ logGroup: new logs.LogGroup(scope, `${id}-LogGroup`, {
88
+ retention: logs.RetentionDays.ONE_WEEK, // Budget-friendly: 1 week retention
89
+ removalPolicy: environment === "production"
90
+ ? cdk.RemovalPolicy.RETAIN
91
+ : cdk.RemovalPolicy.DESTROY,
92
+ }),
93
+ ...options,
94
+ });
95
+ // Add the policies to the lambda function
96
+ policies.forEach((policy) => {
97
+ // Add the policy to the lambda function
98
+ lambdaFunction.addToRolePolicy(new cdk.aws_iam.PolicyStatement(policy));
99
+ });
100
+ // Return the lambda function
101
+ return lambdaFunction;
102
+ };
103
+ exports.createLambdaFunction = createLambdaFunction;
104
+ /**
105
+ * Creates a lambda integration for a lambda function
106
+ * @param lambdaFunction - The lambda function to create an integration for
107
+ * @returns The lambda integration
108
+ */
109
+ const createLambdaApiGatewayIntegration = (lambdaFunction) => {
110
+ return new apigateway.LambdaIntegration(lambdaFunction, {
111
+ requestTemplates: {
112
+ "application/json": JSON.stringify({
113
+ httpMethod: "$context.httpMethod",
114
+ path: "$context.path",
115
+ queryStringParameters: "$input.params().querystring",
116
+ body: "$input.json('$')",
117
+ }),
118
+ },
119
+ });
120
+ };
121
+ exports.createLambdaApiGatewayIntegration = createLambdaApiGatewayIntegration;
@@ -0,0 +1,13 @@
1
+ import * as opensearch from "aws-cdk-lib/aws-opensearchservice";
2
+ import { Construct } from "constructs";
3
+ /**
4
+ * Creates an OpenSearch domain
5
+ * @param scope - The scope to create the domain in
6
+ * @param id - The id of the domain
7
+ * @param account - The account to create the domain in
8
+ * @param capacity - The capacity of the domain
9
+ * @param volumeSize - The size of the volume in GB
10
+ * @returns The OpenSearch domain
11
+ */
12
+ declare const createOpenSearchDomain: (scope: Construct, id: string, account: string, capacity: opensearch.CapacityConfig, volumeSize: number) => opensearch.Domain;
13
+ export { createOpenSearchDomain };
@@ -0,0 +1,72 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || (function () {
19
+ var ownKeys = function(o) {
20
+ ownKeys = Object.getOwnPropertyNames || function (o) {
21
+ var ar = [];
22
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
+ return ar;
24
+ };
25
+ return ownKeys(o);
26
+ };
27
+ return function (mod) {
28
+ if (mod && mod.__esModule) return mod;
29
+ var result = {};
30
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
+ __setModuleDefault(result, mod);
32
+ return result;
33
+ };
34
+ })();
35
+ Object.defineProperty(exports, "__esModule", { value: true });
36
+ exports.createOpenSearchDomain = void 0;
37
+ const cdk = __importStar(require("aws-cdk-lib"));
38
+ const opensearch = __importStar(require("aws-cdk-lib/aws-opensearchservice"));
39
+ const ec2 = __importStar(require("aws-cdk-lib/aws-ec2"));
40
+ const iam = __importStar(require("aws-cdk-lib/aws-iam"));
41
+ /**
42
+ * Creates an OpenSearch domain
43
+ * @param scope - The scope to create the domain in
44
+ * @param id - The id of the domain
45
+ * @param account - The account to create the domain in
46
+ * @param capacity - The capacity of the domain
47
+ * @param volumeSize - The size of the volume in GB
48
+ * @returns The OpenSearch domain
49
+ */
50
+ const createOpenSearchDomain = (scope, id, account, capacity, volumeSize) => {
51
+ return new opensearch.Domain(scope, id, {
52
+ version: opensearch.EngineVersion.OPENSEARCH_2_19,
53
+ capacity,
54
+ ebs: {
55
+ volumeSize,
56
+ volumeType: ec2.EbsDeviceVolumeType.GP3,
57
+ },
58
+ encryptionAtRest: { enabled: true },
59
+ nodeToNodeEncryption: true,
60
+ enforceHttps: true,
61
+ accessPolicies: [
62
+ new iam.PolicyStatement({
63
+ effect: iam.Effect.ALLOW,
64
+ principals: [new iam.AccountPrincipal(account)],
65
+ actions: ["es:*"],
66
+ resources: ["*"],
67
+ }),
68
+ ],
69
+ removalPolicy: cdk.RemovalPolicy.DESTROY,
70
+ });
71
+ };
72
+ exports.createOpenSearchDomain = createOpenSearchDomain;
@@ -0,0 +1,19 @@
1
+ import * as route53 from "aws-cdk-lib/aws-route53";
2
+ import { Construct } from "constructs";
3
+ /**
4
+ * Gets the hosted zone name for the API Gateway
5
+ * @param environment - The environment to get the hosted zone name for
6
+ * @param domainName - The root domain name (example: mydomain.com)
7
+ * @returns The hosted zone name for the API Gateway
8
+ */
9
+ declare const getHostedZoneName: (environment: string, domainName: string) => string;
10
+ /**
11
+ * Gets a hosted zone from an ID and name
12
+ * @param scope - The scope of the hosted zone
13
+ * @param id - The id of the hosted zone
14
+ * @param hostedZoneId - The ID of the hosted zone
15
+ * @param zoneName - The name of the hosted zone
16
+ * @returns The imported hosted zone
17
+ */
18
+ declare const getHostedZone: (scope: Construct, id: string, hostedZoneId: string, zoneName: string) => route53.IHostedZone;
19
+ export { getHostedZone, getHostedZoneName };
@@ -0,0 +1,64 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || (function () {
19
+ var ownKeys = function(o) {
20
+ ownKeys = Object.getOwnPropertyNames || function (o) {
21
+ var ar = [];
22
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
+ return ar;
24
+ };
25
+ return ownKeys(o);
26
+ };
27
+ return function (mod) {
28
+ if (mod && mod.__esModule) return mod;
29
+ var result = {};
30
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
+ __setModuleDefault(result, mod);
32
+ return result;
33
+ };
34
+ })();
35
+ Object.defineProperty(exports, "__esModule", { value: true });
36
+ exports.getHostedZoneName = exports.getHostedZone = void 0;
37
+ const route53 = __importStar(require("aws-cdk-lib/aws-route53"));
38
+ /**
39
+ * Gets the hosted zone name for the API Gateway
40
+ * @param environment - The environment to get the hosted zone name for
41
+ * @param domainName - The root domain name (example: mydomain.com)
42
+ * @returns The hosted zone name for the API Gateway
43
+ */
44
+ const getHostedZoneName = (environment, domainName) => {
45
+ return environment === "production"
46
+ ? domainName
47
+ : `${environment}.${domainName}`;
48
+ };
49
+ exports.getHostedZoneName = getHostedZoneName;
50
+ /**
51
+ * Gets a hosted zone from an ID and name
52
+ * @param scope - The scope of the hosted zone
53
+ * @param id - The id of the hosted zone
54
+ * @param hostedZoneId - The ID of the hosted zone
55
+ * @param zoneName - The name of the hosted zone
56
+ * @returns The imported hosted zone
57
+ */
58
+ const getHostedZone = (scope, id, hostedZoneId, zoneName) => {
59
+ return route53.HostedZone.fromHostedZoneAttributes(scope, id, {
60
+ hostedZoneId,
61
+ zoneName,
62
+ });
63
+ };
64
+ exports.getHostedZone = getHostedZone;
@@ -0,0 +1,18 @@
1
+ import { Construct } from "constructs";
2
+ import * as secretsmanager from "aws-cdk-lib/aws-secretsmanager";
3
+ /**
4
+ * Creates a secret in the AWS Secrets Manager
5
+ * @param scope - The scope of the secret
6
+ * @param id - The id of the secret
7
+ * @param props - The properties of the secret
8
+ * @returns The secret
9
+ */
10
+ declare const createSecret: (scope: Construct, id: string, props?: Partial<secretsmanager.SecretProps>) => secretsmanager.Secret;
11
+ /**
12
+ * Gets a secret from the AWS Secrets Manager
13
+ * @param scope - The scope of the secret
14
+ * @param id - The id of the secret
15
+ * @returns The secret
16
+ */
17
+ declare const getSecret: (scope: Construct, id: string, secretName: string) => secretsmanager.ISecret;
18
+ export { createSecret, getSecret };
@@ -0,0 +1,66 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || (function () {
19
+ var ownKeys = function(o) {
20
+ ownKeys = Object.getOwnPropertyNames || function (o) {
21
+ var ar = [];
22
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
+ return ar;
24
+ };
25
+ return ownKeys(o);
26
+ };
27
+ return function (mod) {
28
+ if (mod && mod.__esModule) return mod;
29
+ var result = {};
30
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
+ __setModuleDefault(result, mod);
32
+ return result;
33
+ };
34
+ })();
35
+ Object.defineProperty(exports, "__esModule", { value: true });
36
+ exports.getSecret = exports.createSecret = void 0;
37
+ const secretsmanager = __importStar(require("aws-cdk-lib/aws-secretsmanager"));
38
+ /**
39
+ * Creates a secret in the AWS Secrets Manager
40
+ * @param scope - The scope of the secret
41
+ * @param id - The id of the secret
42
+ * @param props - The properties of the secret
43
+ * @returns The secret
44
+ */
45
+ const createSecret = (scope, id, props = {}) => {
46
+ // Create the secret
47
+ const secret = new secretsmanager.Secret(scope, id, {
48
+ secretName: id,
49
+ description: `${id} secret`,
50
+ ...props,
51
+ });
52
+ return secret;
53
+ };
54
+ exports.createSecret = createSecret;
55
+ /**
56
+ * Gets a secret from the AWS Secrets Manager
57
+ * @param scope - The scope of the secret
58
+ * @param id - The id of the secret
59
+ * @returns The secret
60
+ */
61
+ const getSecret = (scope, id, secretName) => {
62
+ // Get the secret from the AWS Secrets Manager
63
+ const secret = secretsmanager.Secret.fromSecretNameV2(scope, id, secretName);
64
+ return secret;
65
+ };
66
+ exports.getSecret = getSecret;
@@ -0,0 +1,23 @@
1
+ /**
2
+ * Library to create SQS queues
3
+ */
4
+ import * as cdk from "aws-cdk-lib";
5
+ import * as sqs from "aws-cdk-lib/aws-sqs";
6
+ import * as apigateway from "aws-cdk-lib/aws-apigateway";
7
+ import { Construct } from "constructs";
8
+ /**
9
+ * Creates a new SQS queue
10
+ * @param scope - The scope of the queue
11
+ * @param id - The id of the queue
12
+ * @param props - The properties of the queue
13
+ * @returns The queue
14
+ */
15
+ declare const createSqsQueue: (scope: Construct, id: string, props: Partial<sqs.QueueProps>) => cdk.aws_sqs.Queue;
16
+ /**
17
+ * Creates an API Gateway integration with an SQS queue
18
+ * @param scope - The scope of the construct
19
+ * @param queue - The SQS queue to integrate with
20
+ * @returns The SQS API Gateway integration
21
+ */
22
+ declare const createSQSApiGatewayIntegration: (scope: Construct, queue: sqs.Queue) => apigateway.AwsIntegration;
23
+ export { createSqsQueue, createSQSApiGatewayIntegration };
@@ -0,0 +1,113 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || (function () {
19
+ var ownKeys = function(o) {
20
+ ownKeys = Object.getOwnPropertyNames || function (o) {
21
+ var ar = [];
22
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
+ return ar;
24
+ };
25
+ return ownKeys(o);
26
+ };
27
+ return function (mod) {
28
+ if (mod && mod.__esModule) return mod;
29
+ var result = {};
30
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
+ __setModuleDefault(result, mod);
32
+ return result;
33
+ };
34
+ })();
35
+ Object.defineProperty(exports, "__esModule", { value: true });
36
+ exports.createSQSApiGatewayIntegration = exports.createSqsQueue = void 0;
37
+ /**
38
+ * Library to create SQS queues
39
+ */
40
+ const cdk = __importStar(require("aws-cdk-lib"));
41
+ const sqs = __importStar(require("aws-cdk-lib/aws-sqs"));
42
+ const iam = __importStar(require("aws-cdk-lib/aws-iam"));
43
+ const apigateway = __importStar(require("aws-cdk-lib/aws-apigateway"));
44
+ /**
45
+ * Creates a new SQS queue
46
+ * @param scope - The scope of the queue
47
+ * @param id - The id of the queue
48
+ * @param props - The properties of the queue
49
+ * @returns The queue
50
+ */
51
+ const createSqsQueue = (scope, id, props) => {
52
+ const queue = new sqs.Queue(scope, id, {
53
+ visibilityTimeout: cdk.Duration.seconds(30),
54
+ ...props,
55
+ });
56
+ return queue;
57
+ };
58
+ exports.createSqsQueue = createSqsQueue;
59
+ /**
60
+ * Creates an API Gateway integration with an SQS queue
61
+ * @param scope - The scope of the construct
62
+ * @param queue - The SQS queue to integrate with
63
+ * @returns The SQS API Gateway integration
64
+ */
65
+ const createSQSApiGatewayIntegration = (scope, queue) => {
66
+ // Add resource policy to allow API Gateway to send messages to SQS
67
+ const apiGatewaySqsRole = new iam.Role(scope, "ApiGatewaySqsRole", {
68
+ assumedBy: new iam.ServicePrincipal("apigateway.amazonaws.com"),
69
+ });
70
+ // Grant send messages permission to the API Gateway role
71
+ queue.grantSendMessages(apiGatewaySqsRole);
72
+ // Define the error response
73
+ const error500Response = [
74
+ {
75
+ origin: "server",
76
+ code: "server_error",
77
+ message: "Something went wrong",
78
+ },
79
+ ];
80
+ // Define the success response
81
+ const success200Response = { message: "Message sent" };
82
+ // Create the SQS API Gateway integration
83
+ return new apigateway.AwsIntegration({
84
+ service: "sqs",
85
+ action: "SendMessage",
86
+ integrationHttpMethod: "POST",
87
+ options: {
88
+ credentialsRole: apiGatewaySqsRole,
89
+ requestParameters: {
90
+ "integration.request.header.Content-Type": "'application/x-www-form-urlencoded'",
91
+ },
92
+ requestTemplates: {
93
+ "application/json": `Action=SendMessage&MessageBody=$util.urlEncode($input.body)&QueueUrl=${queue.queueUrl}`,
94
+ },
95
+ integrationResponses: [
96
+ {
97
+ statusCode: "200",
98
+ responseTemplates: {
99
+ "application/json": JSON.stringify(success200Response),
100
+ },
101
+ },
102
+ {
103
+ statusCode: "500",
104
+ selectionPattern: ".*Error.*",
105
+ responseTemplates: {
106
+ "application/json": JSON.stringify(error500Response),
107
+ },
108
+ },
109
+ ],
110
+ },
111
+ });
112
+ };
113
+ exports.createSQSApiGatewayIntegration = createSQSApiGatewayIntegration;
package/package.json ADDED
@@ -0,0 +1,50 @@
1
+ {
2
+ "name": "@certenza/aws-cdk-infrastructure-commons",
3
+ "version": "1.0.0",
4
+ "description": "Common infrastructure reusable utilities and resources for Certenza projects",
5
+ "main": "dist/index.js",
6
+ "types": "dist/index.d.ts",
7
+ "files": [
8
+ "dist/**/*"
9
+ ],
10
+ "scripts": {
11
+ "build": "tsc",
12
+ "clean": "rimraf dist",
13
+ "prebuild": "npm run clean",
14
+ "prepublishOnly": "npm run build",
15
+ "test": "echo \"Error: no test specified\" && exit 1",
16
+ "format": "prettier --write .",
17
+ "format:check": "prettier --check ."
18
+ },
19
+ "keywords": [
20
+ "aws",
21
+ "cdk",
22
+ "infrastructure",
23
+ "typescript"
24
+ ],
25
+ "author": "Certenza",
26
+ "license": "MIT",
27
+ "publishConfig": {
28
+ "access": "restricted"
29
+ },
30
+ "repository": {
31
+ "type": "git",
32
+ "url": "git+https://github.com/certenza/aws-cdk-infrastructure-commons.git"
33
+ },
34
+ "bugs": {
35
+ "url": "https://github.com/certenza/aws-cdk-infrastructure-commons/issues"
36
+ },
37
+ "homepage": "https://github.com/certenza/aws-cdk-infrastructure-commons#readme",
38
+ "dependencies": {
39
+ "aws-cdk-lib": "^2.227.0"
40
+ },
41
+ "devDependencies": {
42
+ "@types/node": "^22.0.0",
43
+ "prettier": "^3.0.0",
44
+ "rimraf": "^6.1.2",
45
+ "typescript": "^5.9.3"
46
+ },
47
+ "engines": {
48
+ "node": ">=22.0.0"
49
+ }
50
+ }