ag-common 0.0.166 → 0.0.167
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.
|
@@ -52,6 +52,8 @@ const setupLambda = ({ lambdaConfig, pathV, verb, seenPermissions, authorizers,
|
|
|
52
52
|
const writeTables = (0, array_1.distinctBy)([...(((_c = def === null || def === void 0 ? void 0 : def.dynamo) === null || _c === void 0 ? void 0 : _c.writes) || []), ...(((_d = lp === null || lp === void 0 ? void 0 : lp.dynamo) === null || _d === void 0 ? void 0 : _d.writes) || [])], (s) => s.shortName);
|
|
53
53
|
const policies = [...(def.policies || []), ...((lp === null || lp === void 0 ? void 0 : lp.policies) || [])].filter(array_1.notEmpty);
|
|
54
54
|
const layers = [...(def.layers || []), ...((lp === null || lp === void 0 ? void 0 : lp.layers) || [])].filter(array_1.notEmpty);
|
|
55
|
+
const memory = (lp === null || lp === void 0 ? void 0 : lp.memory) || (def === null || def === void 0 ? void 0 : def.memory) || 128;
|
|
56
|
+
const timeout = aws_cdk_lib_1.Duration.seconds((lp === null || lp === void 0 ? void 0 : lp.timeoutS) || (def === null || def === void 0 ? void 0 : def.timeoutS) || 30);
|
|
55
57
|
let authorizerName = lp === null || lp === void 0 ? void 0 : lp.authorizerName;
|
|
56
58
|
if (authorizerName === undefined) {
|
|
57
59
|
authorizerName = def.authorizerName;
|
|
@@ -75,6 +77,8 @@ const setupLambda = ({ lambdaConfig, pathV, verb, seenPermissions, authorizers,
|
|
|
75
77
|
policies,
|
|
76
78
|
layers,
|
|
77
79
|
authorizer,
|
|
80
|
+
memory,
|
|
81
|
+
timeout,
|
|
78
82
|
};
|
|
79
83
|
};
|
|
80
84
|
const addApiPaths = (api, pathList, apiRoots) => {
|
|
@@ -108,7 +112,7 @@ const openApiImpl = (p) => {
|
|
|
108
112
|
paths.forEach(({ fullPath, verbs, pathList }) => {
|
|
109
113
|
const apiPath = addApiPaths(api, pathList, apiRoots);
|
|
110
114
|
verbs.forEach((verb) => {
|
|
111
|
-
const
|
|
115
|
+
const lc = setupLambda({
|
|
112
116
|
lambdaConfig,
|
|
113
117
|
pathV: fullPath,
|
|
114
118
|
verb,
|
|
@@ -121,9 +125,9 @@ const openApiImpl = (p) => {
|
|
|
121
125
|
functionName: lambdaName,
|
|
122
126
|
runtime: aws_cdk_lib_1.aws_lambda.Runtime.NODEJS_14_X,
|
|
123
127
|
handler: 'handler',
|
|
124
|
-
environment,
|
|
125
|
-
memorySize:
|
|
126
|
-
timeout:
|
|
128
|
+
environment: lc.environment,
|
|
129
|
+
memorySize: lc.memory,
|
|
130
|
+
timeout: lc.timeout,
|
|
127
131
|
description: '(cdk)',
|
|
128
132
|
entry: entry,
|
|
129
133
|
bundling: {
|
|
@@ -131,13 +135,13 @@ const openApiImpl = (p) => {
|
|
|
131
135
|
},
|
|
132
136
|
reservedConcurrentExecutions: 5,
|
|
133
137
|
logRetention: aws_cdk_lib_1.aws_logs.RetentionDays.FIVE_DAYS,
|
|
134
|
-
layers,
|
|
138
|
+
layers: lc.layers,
|
|
135
139
|
});
|
|
136
|
-
readTables.forEach((t) => t.table.grantReadData(lambdaV));
|
|
137
|
-
writeTables.forEach((t) => t.table.grantReadWriteData(lambdaV));
|
|
138
|
-
policies.forEach((p1) => lambdaV.addToRolePolicy(p1));
|
|
140
|
+
lc.readTables.forEach((t) => t.table.grantReadData(lambdaV));
|
|
141
|
+
lc.writeTables.forEach((t) => t.table.grantReadWriteData(lambdaV));
|
|
142
|
+
lc.policies.forEach((p1) => lambdaV.addToRolePolicy(p1));
|
|
139
143
|
//
|
|
140
|
-
apiPath.addMethod(verb.toUpperCase(), new aws_cdk_lib_1.aws_apigateway.LambdaIntegration(lambdaV, {}), { authorizer });
|
|
144
|
+
apiPath.addMethod(verb.toUpperCase(), new aws_cdk_lib_1.aws_apigateway.LambdaIntegration(lambdaV, {}), { authorizer: lc.authorizer });
|
|
141
145
|
});
|
|
142
146
|
});
|
|
143
147
|
Object.keys(lambdaConfig).forEach((k) => {
|
|
@@ -29,6 +29,14 @@ export interface ILambdaConfig {
|
|
|
29
29
|
* use the name of the lambda authorizer passed in in the openApiImpl config
|
|
30
30
|
*/
|
|
31
31
|
authorizerName?: string;
|
|
32
|
+
/**
|
|
33
|
+
* timeout in seconds. defaults to 30
|
|
34
|
+
*/
|
|
35
|
+
timeoutS?: number;
|
|
36
|
+
/**
|
|
37
|
+
* lambda memory. defaults to 128
|
|
38
|
+
*/
|
|
39
|
+
memory?: number;
|
|
32
40
|
}
|
|
33
41
|
/**
|
|
34
42
|
* 'default' will be applied to all functions
|