@gradientedge/cdk-utils 8.29.0 → 8.31.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.
@@ -5,7 +5,7 @@
5
5
  "main": "dist/index.js",
6
6
  "license": "UNLICENSED",
7
7
  "engines": {
8
- "node": ">=14.16.0 <17"
8
+ "node": ">=14.16.0 <=18"
9
9
  },
10
10
  "repository": {
11
11
  "type": "git",
@@ -5,7 +5,7 @@
5
5
  "main": "dist/index.js",
6
6
  "license": "UNLICENSED",
7
7
  "engines": {
8
- "node": ">=14.16.0 <17"
8
+ "node": ">=14.16.0 <=18"
9
9
  },
10
10
  "repository": {
11
11
  "type": "git",
@@ -18,6 +18,7 @@ import { CommonConstruct } from './construct';
18
18
  * }
19
19
  */
20
20
  export declare class CommonStack extends cdk.Stack {
21
+ static NODEJS_RUNTIME: cdk.aws_lambda.Runtime;
21
22
  construct: CommonConstruct;
22
23
  props: CommonStackProps;
23
24
  constructor(parent: cdk.App, name: string, props: cdk.StackProps);
@@ -36,6 +37,7 @@ export declare class CommonStack extends cdk.Stack {
36
37
  extraContexts: any;
37
38
  skipStageForARecords: any;
38
39
  logRetention: any;
40
+ nodejsRuntime: any;
39
41
  };
40
42
  /**
41
43
  * @summary Method to determine extra cdk contexts apart from the main cdk.json
@@ -25,6 +25,7 @@ var __importStar = (this && this.__importStar) || function (mod) {
25
25
  Object.defineProperty(exports, "__esModule", { value: true });
26
26
  exports.CommonStack = void 0;
27
27
  const cdk = __importStar(require("aws-cdk-lib"));
28
+ const lambda = __importStar(require("aws-cdk-lib/aws-lambda"));
28
29
  const utils_1 = require("../utils");
29
30
  const construct_1 = require("./construct");
30
31
  const appRoot = require('app-root-path');
@@ -46,6 +47,7 @@ const fs = require('fs');
46
47
  * }
47
48
  */
48
49
  class CommonStack extends cdk.Stack {
50
+ static NODEJS_RUNTIME = lambda.Runtime.NODEJS_16_X;
49
51
  construct;
50
52
  props;
51
53
  constructor(parent, name, props) {
@@ -74,6 +76,7 @@ class CommonStack extends cdk.Stack {
74
76
  extraContexts: this.node.tryGetContext('extraContexts'),
75
77
  skipStageForARecords: this.node.tryGetContext('skipStageForARecords'),
76
78
  logRetention: this.node.tryGetContext('logRetention'),
79
+ nodejsRuntime: this.node.tryGetContext('nodejsRuntime') ?? CommonStack.NODEJS_RUNTIME,
77
80
  };
78
81
  }
79
82
  /**
@@ -28,8 +28,8 @@ const cdk = __importStar(require("aws-cdk-lib"));
28
28
  const cloudfront = __importStar(require("aws-cdk-lib/aws-cloudfront"));
29
29
  const lambda = __importStar(require("aws-cdk-lib/aws-lambda"));
30
30
  const cr = __importStar(require("aws-cdk-lib/custom-resources"));
31
+ const common_1 = require("../../common");
31
32
  const utils = __importStar(require("../../utils"));
32
- const lambda_manager_1 = require("./lambda-manager");
33
33
  /**
34
34
  * @stability stable
35
35
  * @category cdk-utils.cloudfront-manager
@@ -239,7 +239,7 @@ class CloudFrontManager {
239
239
  memorySize: props.memorySize,
240
240
  reservedConcurrentExecutions: props.reservedConcurrentExecutions,
241
241
  role: role,
242
- runtime: props.runtime ?? lambda_manager_1.LambdaManager.NODEJS_RUNTIME,
242
+ runtime: props.runtime ?? scope.props.nodejsRuntime ?? common_1.CommonStack.NODEJS_RUNTIME,
243
243
  securityGroups: securityGroups,
244
244
  stackId: `${id}-stack-id-${scope.props.stage}`,
245
245
  timeout: props.timeoutInSecs ? cdk.Duration.seconds(props.timeoutInSecs) : cdk.Duration.minutes(1),
@@ -26,7 +26,6 @@ import * as types from '../../types';
26
26
  * @see [CDK Lambda Module]{@link https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_lambda-readme.html}
27
27
  */
28
28
  export declare class LambdaManager {
29
- static NODEJS_RUNTIME: cdk.aws_lambda.Runtime;
30
29
  /**
31
30
  * @summary Method to create a lambda layer (nodejs)
32
31
  * @param {string} id scoped id of the resource
@@ -27,6 +27,7 @@ exports.LambdaManager = void 0;
27
27
  const cdk = __importStar(require("aws-cdk-lib"));
28
28
  const iam = __importStar(require("aws-cdk-lib/aws-iam"));
29
29
  const lambda = __importStar(require("aws-cdk-lib/aws-lambda"));
30
+ const common_1 = require("../../common");
30
31
  const utils = __importStar(require("../../utils"));
31
32
  const cloudfront_manager_1 = require("./cloudfront-manager");
32
33
  const ssm_manager_1 = require("./ssm-manager");
@@ -51,7 +52,6 @@ const ssm_manager_1 = require("./ssm-manager");
51
52
  * @see [CDK Lambda Module]{@link https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_lambda-readme.html}
52
53
  */
53
54
  class LambdaManager {
54
- static NODEJS_RUNTIME = lambda.Runtime.NODEJS_16_X;
55
55
  /**
56
56
  * @summary Method to create a lambda layer (nodejs)
57
57
  * @param {string} id scoped id of the resource
@@ -60,7 +60,7 @@ class LambdaManager {
60
60
  */
61
61
  createLambdaLayer(id, scope, code) {
62
62
  const lambdaLayer = new lambda.LayerVersion(scope, `${id}`, {
63
- compatibleRuntimes: [LambdaManager.NODEJS_RUNTIME],
63
+ compatibleRuntimes: [scope.props.nodejsRuntime ?? common_1.CommonStack.NODEJS_RUNTIME],
64
64
  code: code,
65
65
  description: `${id}`,
66
66
  layerVersionName: `${id}-${scope.props.stage}`,
@@ -99,7 +99,7 @@ class LambdaManager {
99
99
  allowPublicSubnet: !!vpc,
100
100
  functionName: functionName,
101
101
  handler: handler || 'index.lambda_handler',
102
- runtime: LambdaManager.NODEJS_RUNTIME,
102
+ runtime: props.runtime ?? scope.props.nodejsRuntime ?? common_1.CommonStack.NODEJS_RUNTIME,
103
103
  code: code,
104
104
  deadLetterQueue: deadLetterQueue,
105
105
  architecture: props.architecture ?? lambda.Architecture.ARM_64,
@@ -176,7 +176,7 @@ class LambdaManager {
176
176
  ...{
177
177
  allowPublicSubnet: !!vpc,
178
178
  functionName: functionName,
179
- runtime: LambdaManager.NODEJS_RUNTIME,
179
+ runtime: props.runtime ?? scope.props.nodejsRuntime ?? common_1.CommonStack.NODEJS_RUNTIME,
180
180
  code: code,
181
181
  deadLetterQueue: deadLetterQueue,
182
182
  architecture: props.architecture ?? lambda.Architecture.ARM_64,
@@ -53,6 +53,7 @@ export interface CommonStackProps extends cdk.StackProps {
53
53
  stageContextPath?: string;
54
54
  skipStageForARecords: boolean;
55
55
  logRetention?: logs.RetentionDays;
56
+ nodejsRuntime?: lambda.Runtime;
56
57
  }
57
58
  /**
58
59
  * @category cdk-utils.site-with-ecs-backend
package/package.json CHANGED
@@ -1,10 +1,10 @@
1
1
  {
2
2
  "name": "@gradientedge/cdk-utils",
3
- "version": "8.29.0",
3
+ "version": "8.31.0",
4
4
  "description": "Utilities for AWS CDK provisioning",
5
5
  "main": "dist/index.js",
6
6
  "engines": {
7
- "node": ">=14.16.0 <17"
7
+ "node": ">=14.16.0 <=18"
8
8
  },
9
9
  "repository": {
10
10
  "type": "git",
@@ -1,4 +1,5 @@
1
1
  import * as cdk from 'aws-cdk-lib'
2
+ import * as lambda from 'aws-cdk-lib/aws-lambda'
2
3
  import { CommonStackProps } from '../types'
3
4
  import { isDevStage } from '../utils'
4
5
  import { CommonConstruct } from './construct'
@@ -23,6 +24,8 @@ const fs = require('fs')
23
24
  * }
24
25
  */
25
26
  export class CommonStack extends cdk.Stack {
27
+ public static NODEJS_RUNTIME = lambda.Runtime.NODEJS_16_X
28
+
26
29
  construct: CommonConstruct
27
30
  props: CommonStackProps
28
31
 
@@ -57,6 +60,7 @@ export class CommonStack extends cdk.Stack {
57
60
  extraContexts: this.node.tryGetContext('extraContexts'),
58
61
  skipStageForARecords: this.node.tryGetContext('skipStageForARecords'),
59
62
  logRetention: this.node.tryGetContext('logRetention'),
63
+ nodejsRuntime: this.node.tryGetContext('nodejsRuntime') ?? CommonStack.NODEJS_RUNTIME,
60
64
  }
61
65
  }
62
66
 
@@ -9,9 +9,9 @@ import * as lambda from 'aws-cdk-lib/aws-lambda'
9
9
  import * as s3 from 'aws-cdk-lib/aws-s3'
10
10
  import * as cr from 'aws-cdk-lib/custom-resources'
11
11
  import * as common from '../../common'
12
+ import { CommonStack } from '../../common'
12
13
  import * as types from '../../types'
13
14
  import * as utils from '../../utils'
14
- import { LambdaManager } from './lambda-manager'
15
15
 
16
16
  /**
17
17
  * @stability stable
@@ -272,7 +272,7 @@ export class CloudFrontManager {
272
272
  memorySize: props.memorySize,
273
273
  reservedConcurrentExecutions: props.reservedConcurrentExecutions,
274
274
  role: role,
275
- runtime: props.runtime ?? LambdaManager.NODEJS_RUNTIME,
275
+ runtime: props.runtime ?? scope.props.nodejsRuntime ?? CommonStack.NODEJS_RUNTIME,
276
276
  securityGroups: securityGroups,
277
277
  stackId: `${id}-stack-id-${scope.props.stage}`,
278
278
  timeout: props.timeoutInSecs ? cdk.Duration.seconds(props.timeoutInSecs) : cdk.Duration.minutes(1),
@@ -4,6 +4,7 @@ import * as efs from 'aws-cdk-lib/aws-efs'
4
4
  import * as iam from 'aws-cdk-lib/aws-iam'
5
5
  import * as lambda from 'aws-cdk-lib/aws-lambda'
6
6
  import * as common from '../../common'
7
+ import { CommonStack } from '../../common'
7
8
  import * as types from '../../types'
8
9
  import * as utils from '../../utils'
9
10
  import { CloudFrontManager } from './cloudfront-manager'
@@ -30,8 +31,6 @@ import { SsmManager } from './ssm-manager'
30
31
  * @see [CDK Lambda Module]{@link https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_lambda-readme.html}
31
32
  */
32
33
  export class LambdaManager {
33
- public static NODEJS_RUNTIME = lambda.Runtime.NODEJS_16_X
34
-
35
34
  /**
36
35
  * @summary Method to create a lambda layer (nodejs)
37
36
  * @param {string} id scoped id of the resource
@@ -40,7 +39,7 @@ export class LambdaManager {
40
39
  */
41
40
  public createLambdaLayer(id: string, scope: common.CommonConstruct, code: lambda.AssetCode) {
42
41
  const lambdaLayer = new lambda.LayerVersion(scope, `${id}`, {
43
- compatibleRuntimes: [LambdaManager.NODEJS_RUNTIME],
42
+ compatibleRuntimes: [scope.props.nodejsRuntime ?? CommonStack.NODEJS_RUNTIME],
44
43
  code: code,
45
44
  description: `${id}`,
46
45
  layerVersionName: `${id}-${scope.props.stage}`,
@@ -98,7 +97,7 @@ export class LambdaManager {
98
97
  allowPublicSubnet: !!vpc,
99
98
  functionName: functionName,
100
99
  handler: handler || 'index.lambda_handler',
101
- runtime: LambdaManager.NODEJS_RUNTIME,
100
+ runtime: props.runtime ?? scope.props.nodejsRuntime ?? CommonStack.NODEJS_RUNTIME,
102
101
  code: code,
103
102
  deadLetterQueue: deadLetterQueue,
104
103
  architecture: props.architecture ?? lambda.Architecture.ARM_64,
@@ -221,7 +220,7 @@ export class LambdaManager {
221
220
  ...{
222
221
  allowPublicSubnet: !!vpc,
223
222
  functionName: functionName,
224
- runtime: LambdaManager.NODEJS_RUNTIME,
223
+ runtime: props.runtime ?? scope.props.nodejsRuntime ?? CommonStack.NODEJS_RUNTIME,
225
224
  code: code,
226
225
  deadLetterQueue: deadLetterQueue,
227
226
  architecture: props.architecture ?? lambda.Architecture.ARM_64,
@@ -55,6 +55,7 @@ export interface CommonStackProps extends cdk.StackProps {
55
55
  stageContextPath?: string
56
56
  skipStageForARecords: boolean
57
57
  logRetention?: logs.RetentionDays
58
+ nodejsRuntime?: lambda.Runtime
58
59
  }
59
60
 
60
61
  /**