@gradientedge/cdk-utils 4.15.0 → 5.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.
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import * as pylambda from '@aws-cdk/aws-lambda-python-alpha';
|
|
2
1
|
import * as cdk from 'aws-cdk-lib';
|
|
3
2
|
import * as ec2 from 'aws-cdk-lib/aws-ec2';
|
|
4
3
|
import * as efs from 'aws-cdk-lib/aws-efs';
|
|
@@ -34,31 +33,6 @@ export declare class LambdaManager {
|
|
|
34
33
|
* @param {lambda.AssetCode} code
|
|
35
34
|
*/
|
|
36
35
|
createLambdaLayer(id: string, scope: common.CommonConstruct, code: lambda.AssetCode): cdk.aws_lambda.LayerVersion;
|
|
37
|
-
/**
|
|
38
|
-
* @summary Method to create a lambda layer (python)
|
|
39
|
-
* @param {string} id scoped id of the resource
|
|
40
|
-
* @param {common.CommonConstruct} scope scope in which this resource is defined
|
|
41
|
-
* @param {string} entry path to layer source
|
|
42
|
-
*/
|
|
43
|
-
createPythonLambdaLayer(id: string, scope: common.CommonConstruct, entry: string): pylambda.PythonLayerVersion;
|
|
44
|
-
/**
|
|
45
|
-
* @summary Method to create a lambda function (python)
|
|
46
|
-
* @param {string} id scoped id of the resource
|
|
47
|
-
* @param {common.CommonConstruct} scope scope in which this resource is defined
|
|
48
|
-
* @param {types.LambdaProps} props
|
|
49
|
-
* @param {iam.Role | iam.CfnRole} role
|
|
50
|
-
* @param {lambda.ILayerVersion[]} layers
|
|
51
|
-
* @param {string} entry path to lambda source
|
|
52
|
-
* @param {string?} index
|
|
53
|
-
* @param {string?} handler
|
|
54
|
-
* @param {Map<string, string>?} environment
|
|
55
|
-
* @param {ec2.IVpc?} vpc
|
|
56
|
-
* @param {ec2.ISecurityGroup[]?} securityGroups
|
|
57
|
-
* @param {efs.IAccessPoint?} accessPoint
|
|
58
|
-
* @param {string?} mountPath
|
|
59
|
-
* @param {ec2.SubnetSelection?} vpcSubnets
|
|
60
|
-
*/
|
|
61
|
-
createPythonLambdaFunction(id: string, scope: common.CommonConstruct, props: types.LambdaProps, role: iam.Role | iam.CfnRole, layers: lambda.ILayerVersion[], entry: string, index?: string, handler?: string, environment?: any, vpc?: ec2.IVpc, securityGroups?: ec2.ISecurityGroup[], accessPoint?: efs.IAccessPoint, mountPath?: string, vpcSubnets?: ec2.SubnetSelection): pylambda.PythonFunction;
|
|
62
36
|
/**
|
|
63
37
|
* @summary Method to create a lambda function (nodejs)
|
|
64
38
|
* @param {string} id scoped id of the resource
|
|
@@ -24,7 +24,6 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|
|
24
24
|
};
|
|
25
25
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
26
|
exports.LambdaManager = void 0;
|
|
27
|
-
const pylambda = __importStar(require("@aws-cdk/aws-lambda-python-alpha"));
|
|
28
27
|
const cdk = __importStar(require("aws-cdk-lib"));
|
|
29
28
|
const iam = __importStar(require("aws-cdk-lib/aws-iam"));
|
|
30
29
|
const lambda = __importStar(require("aws-cdk-lib/aws-lambda"));
|
|
@@ -67,72 +66,6 @@ class LambdaManager {
|
|
|
67
66
|
utils.createCfnOutput(`${id}-lambdaLayerArn`, scope, lambdaLayer.layerVersionArn);
|
|
68
67
|
return lambdaLayer;
|
|
69
68
|
}
|
|
70
|
-
/**
|
|
71
|
-
* @summary Method to create a lambda layer (python)
|
|
72
|
-
* @param {string} id scoped id of the resource
|
|
73
|
-
* @param {common.CommonConstruct} scope scope in which this resource is defined
|
|
74
|
-
* @param {string} entry path to layer source
|
|
75
|
-
*/
|
|
76
|
-
createPythonLambdaLayer(id, scope, entry) {
|
|
77
|
-
const lambdaLayer = new pylambda.PythonLayerVersion(scope, `${id}`, {
|
|
78
|
-
compatibleRuntimes: [lambda.Runtime.PYTHON_3_8],
|
|
79
|
-
description: `${id}`,
|
|
80
|
-
entry: entry,
|
|
81
|
-
layerVersionName: `${id}-${scope.props.stage}`,
|
|
82
|
-
});
|
|
83
|
-
utils.createCfnOutput(`${id}-lambdaLayerArn`, scope, lambdaLayer.layerVersionArn);
|
|
84
|
-
return lambdaLayer;
|
|
85
|
-
}
|
|
86
|
-
/**
|
|
87
|
-
* @summary Method to create a lambda function (python)
|
|
88
|
-
* @param {string} id scoped id of the resource
|
|
89
|
-
* @param {common.CommonConstruct} scope scope in which this resource is defined
|
|
90
|
-
* @param {types.LambdaProps} props
|
|
91
|
-
* @param {iam.Role | iam.CfnRole} role
|
|
92
|
-
* @param {lambda.ILayerVersion[]} layers
|
|
93
|
-
* @param {string} entry path to lambda source
|
|
94
|
-
* @param {string?} index
|
|
95
|
-
* @param {string?} handler
|
|
96
|
-
* @param {Map<string, string>?} environment
|
|
97
|
-
* @param {ec2.IVpc?} vpc
|
|
98
|
-
* @param {ec2.ISecurityGroup[]?} securityGroups
|
|
99
|
-
* @param {efs.IAccessPoint?} accessPoint
|
|
100
|
-
* @param {string?} mountPath
|
|
101
|
-
* @param {ec2.SubnetSelection?} vpcSubnets
|
|
102
|
-
*/
|
|
103
|
-
createPythonLambdaFunction(id, scope, props, role, layers, entry, index, handler, environment, vpc, securityGroups, accessPoint, mountPath, vpcSubnets) {
|
|
104
|
-
if (!props)
|
|
105
|
-
throw `Lambda props undefined`;
|
|
106
|
-
const functionName = `${props.functionName}-${scope.props.stage}`;
|
|
107
|
-
const lambdaFunction = new pylambda.PythonFunction(scope, `${id}`, {
|
|
108
|
-
...props,
|
|
109
|
-
...{
|
|
110
|
-
allowPublicSubnet: !!vpc,
|
|
111
|
-
functionName: functionName,
|
|
112
|
-
index: index,
|
|
113
|
-
handler: handler,
|
|
114
|
-
runtime: lambda.Runtime.PYTHON_3_8,
|
|
115
|
-
entry: entry,
|
|
116
|
-
environment: {
|
|
117
|
-
REGION: scope.props.region,
|
|
118
|
-
...environment,
|
|
119
|
-
},
|
|
120
|
-
filesystem: accessPoint
|
|
121
|
-
? lambda.FileSystem.fromEfsAccessPoint(accessPoint, mountPath || '/mnt/msg')
|
|
122
|
-
: undefined,
|
|
123
|
-
layers: layers,
|
|
124
|
-
reservedConcurrentExecutions: props.reservedConcurrentExecutions,
|
|
125
|
-
role: role instanceof iam.Role ? role : undefined,
|
|
126
|
-
securityGroups: securityGroups,
|
|
127
|
-
timeout: props.timeoutInSecs ? cdk.Duration.seconds(props.timeoutInSecs) : cdk.Duration.minutes(1),
|
|
128
|
-
vpc: vpc,
|
|
129
|
-
vpcSubnets: vpcSubnets,
|
|
130
|
-
},
|
|
131
|
-
});
|
|
132
|
-
utils.createCfnOutput(`${id}-lambdaArn`, scope, lambdaFunction.functionArn);
|
|
133
|
-
utils.createCfnOutput(`${id}-lambdaName`, scope, lambdaFunction.functionName);
|
|
134
|
-
return lambdaFunction;
|
|
135
|
-
}
|
|
136
69
|
/**
|
|
137
70
|
* @summary Method to create a lambda function (nodejs)
|
|
138
71
|
* @param {string} id scoped id of the resource
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@gradientedge/cdk-utils",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "5.0.0",
|
|
4
4
|
"description": "Utilities for AWS CDK provisioning",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"engines": {
|
|
@@ -45,54 +45,53 @@
|
|
|
45
45
|
}
|
|
46
46
|
},
|
|
47
47
|
"dependencies": {
|
|
48
|
-
"@
|
|
49
|
-
"@types/
|
|
50
|
-
"@types/node": "^17.0.23",
|
|
48
|
+
"@types/lodash": "^4.14.182",
|
|
49
|
+
"@types/node": "^17.0.31",
|
|
51
50
|
"app-root-path": "^3.0.0",
|
|
52
|
-
"aws-cdk-lib": "^2.
|
|
53
|
-
"aws-sdk": "^2.
|
|
54
|
-
"constructs": "^10.0.
|
|
51
|
+
"aws-cdk-lib": "^2.22.0",
|
|
52
|
+
"aws-sdk": "^2.1126.0",
|
|
53
|
+
"constructs": "^10.0.130",
|
|
55
54
|
"lodash": "^4.17.21",
|
|
56
|
-
"moment": "^2.29.
|
|
57
|
-
"nconf": "^0.
|
|
55
|
+
"moment": "^2.29.3",
|
|
56
|
+
"nconf": "^0.12.0",
|
|
58
57
|
"pluralize": "^8.0.0",
|
|
59
58
|
"ts-node": "^10.7.0"
|
|
60
59
|
},
|
|
61
60
|
"devDependencies": {
|
|
62
61
|
"@babel/plugin-proposal-class-properties": "^7.16.7",
|
|
63
|
-
"@types/jest": "^27.
|
|
64
|
-
"@typescript-eslint/eslint-plugin": "^5.
|
|
65
|
-
"@typescript-eslint/parser": "^5.
|
|
62
|
+
"@types/jest": "^27.5.0",
|
|
63
|
+
"@typescript-eslint/eslint-plugin": "^5.22.0",
|
|
64
|
+
"@typescript-eslint/parser": "^5.22.0",
|
|
66
65
|
"aws-cdk": "*",
|
|
67
66
|
"babel-eslint": "^10.1.0",
|
|
68
67
|
"better-docs": "^2.7.2",
|
|
69
68
|
"codecov": "^3.8.3",
|
|
70
69
|
"commitizen": "^4.2.4",
|
|
71
70
|
"dotenv": "^16.0.0",
|
|
72
|
-
"eslint": "^8.
|
|
71
|
+
"eslint": "^8.14.0",
|
|
73
72
|
"eslint-config-prettier": "^8.5.0",
|
|
74
|
-
"eslint-plugin-import": "^2.
|
|
73
|
+
"eslint-plugin-import": "^2.26.0",
|
|
75
74
|
"husky": "^7.0.4",
|
|
76
|
-
"jest": "^
|
|
75
|
+
"jest": "^28.0.3",
|
|
77
76
|
"jest-extended": "^2.0.0",
|
|
78
|
-
"jest-junit": "^13.
|
|
77
|
+
"jest-junit": "^13.2.0",
|
|
79
78
|
"jsdoc": "^3.6.10",
|
|
80
79
|
"jsdoc-babel": "^0.5.0",
|
|
81
80
|
"jsdoc-mermaid": "^1.0.0",
|
|
82
81
|
"lerna": "^4.0.0",
|
|
83
|
-
"prettier": "^2.6.
|
|
82
|
+
"prettier": "^2.6.2",
|
|
84
83
|
"prettier-plugin-organize-imports": "^2.3.4",
|
|
85
84
|
"rimraf": "^3.0.2",
|
|
86
85
|
"semantic-release": "^19.0.2",
|
|
87
|
-
"ts-jest": "^
|
|
86
|
+
"ts-jest": "^28.0.0",
|
|
88
87
|
"ts-node": "^10.7.0",
|
|
89
|
-
"typescript": "4.6.
|
|
88
|
+
"typescript": "4.6.4"
|
|
90
89
|
},
|
|
91
90
|
"optionalDependencies": {
|
|
92
|
-
"@babel/core": "^7.17.
|
|
91
|
+
"@babel/core": "^7.17.10",
|
|
93
92
|
"prop-types": "^15.8.1",
|
|
94
|
-
"react": "^18.
|
|
95
|
-
"react-dom": "^18.
|
|
93
|
+
"react": "^18.1.0",
|
|
94
|
+
"react-dom": "^18.1.0"
|
|
96
95
|
},
|
|
97
96
|
"config": {
|
|
98
97
|
"commitizen": {
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import * as pylambda from '@aws-cdk/aws-lambda-python-alpha'
|
|
2
1
|
import * as cdk from 'aws-cdk-lib'
|
|
3
2
|
import * as ec2 from 'aws-cdk-lib/aws-ec2'
|
|
4
3
|
import * as efs from 'aws-cdk-lib/aws-efs'
|
|
@@ -49,94 +48,6 @@ export class LambdaManager {
|
|
|
49
48
|
return lambdaLayer
|
|
50
49
|
}
|
|
51
50
|
|
|
52
|
-
/**
|
|
53
|
-
* @summary Method to create a lambda layer (python)
|
|
54
|
-
* @param {string} id scoped id of the resource
|
|
55
|
-
* @param {common.CommonConstruct} scope scope in which this resource is defined
|
|
56
|
-
* @param {string} entry path to layer source
|
|
57
|
-
*/
|
|
58
|
-
public createPythonLambdaLayer(id: string, scope: common.CommonConstruct, entry: string) {
|
|
59
|
-
const lambdaLayer = new pylambda.PythonLayerVersion(scope, `${id}`, {
|
|
60
|
-
compatibleRuntimes: [lambda.Runtime.PYTHON_3_8],
|
|
61
|
-
description: `${id}`,
|
|
62
|
-
entry: entry,
|
|
63
|
-
layerVersionName: `${id}-${scope.props.stage}`,
|
|
64
|
-
})
|
|
65
|
-
|
|
66
|
-
utils.createCfnOutput(`${id}-lambdaLayerArn`, scope, lambdaLayer.layerVersionArn)
|
|
67
|
-
|
|
68
|
-
return lambdaLayer
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
/**
|
|
72
|
-
* @summary Method to create a lambda function (python)
|
|
73
|
-
* @param {string} id scoped id of the resource
|
|
74
|
-
* @param {common.CommonConstruct} scope scope in which this resource is defined
|
|
75
|
-
* @param {types.LambdaProps} props
|
|
76
|
-
* @param {iam.Role | iam.CfnRole} role
|
|
77
|
-
* @param {lambda.ILayerVersion[]} layers
|
|
78
|
-
* @param {string} entry path to lambda source
|
|
79
|
-
* @param {string?} index
|
|
80
|
-
* @param {string?} handler
|
|
81
|
-
* @param {Map<string, string>?} environment
|
|
82
|
-
* @param {ec2.IVpc?} vpc
|
|
83
|
-
* @param {ec2.ISecurityGroup[]?} securityGroups
|
|
84
|
-
* @param {efs.IAccessPoint?} accessPoint
|
|
85
|
-
* @param {string?} mountPath
|
|
86
|
-
* @param {ec2.SubnetSelection?} vpcSubnets
|
|
87
|
-
*/
|
|
88
|
-
|
|
89
|
-
public createPythonLambdaFunction(
|
|
90
|
-
id: string,
|
|
91
|
-
scope: common.CommonConstruct,
|
|
92
|
-
props: types.LambdaProps,
|
|
93
|
-
role: iam.Role | iam.CfnRole,
|
|
94
|
-
layers: lambda.ILayerVersion[],
|
|
95
|
-
entry: string,
|
|
96
|
-
index?: string,
|
|
97
|
-
handler?: string,
|
|
98
|
-
environment?: any,
|
|
99
|
-
vpc?: ec2.IVpc,
|
|
100
|
-
securityGroups?: ec2.ISecurityGroup[],
|
|
101
|
-
accessPoint?: efs.IAccessPoint,
|
|
102
|
-
mountPath?: string,
|
|
103
|
-
vpcSubnets?: ec2.SubnetSelection
|
|
104
|
-
) {
|
|
105
|
-
if (!props) throw `Lambda props undefined`
|
|
106
|
-
|
|
107
|
-
const functionName = `${props.functionName}-${scope.props.stage}`
|
|
108
|
-
const lambdaFunction = new pylambda.PythonFunction(scope, `${id}`, {
|
|
109
|
-
...props,
|
|
110
|
-
...{
|
|
111
|
-
allowPublicSubnet: !!vpc,
|
|
112
|
-
functionName: functionName,
|
|
113
|
-
index: index,
|
|
114
|
-
handler: handler,
|
|
115
|
-
runtime: lambda.Runtime.PYTHON_3_8,
|
|
116
|
-
entry: entry,
|
|
117
|
-
environment: {
|
|
118
|
-
REGION: scope.props.region,
|
|
119
|
-
...environment,
|
|
120
|
-
},
|
|
121
|
-
filesystem: accessPoint
|
|
122
|
-
? lambda.FileSystem.fromEfsAccessPoint(accessPoint, mountPath || '/mnt/msg')
|
|
123
|
-
: undefined,
|
|
124
|
-
layers: layers,
|
|
125
|
-
reservedConcurrentExecutions: props.reservedConcurrentExecutions,
|
|
126
|
-
role: role instanceof iam.Role ? role : undefined,
|
|
127
|
-
securityGroups: securityGroups,
|
|
128
|
-
timeout: props.timeoutInSecs ? cdk.Duration.seconds(props.timeoutInSecs) : cdk.Duration.minutes(1),
|
|
129
|
-
vpc: vpc,
|
|
130
|
-
vpcSubnets: vpcSubnets,
|
|
131
|
-
},
|
|
132
|
-
})
|
|
133
|
-
|
|
134
|
-
utils.createCfnOutput(`${id}-lambdaArn`, scope, lambdaFunction.functionArn)
|
|
135
|
-
utils.createCfnOutput(`${id}-lambdaName`, scope, lambdaFunction.functionName)
|
|
136
|
-
|
|
137
|
-
return lambdaFunction
|
|
138
|
-
}
|
|
139
|
-
|
|
140
51
|
/**
|
|
141
52
|
* @summary Method to create a lambda function (nodejs)
|
|
142
53
|
* @param {string} id scoped id of the resource
|