@goldstack/utils-aws-lambda 0.1.31 → 0.1.32
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/dist/src/buildFunctions.d.ts +9 -0
- package/dist/src/buildFunctions.d.ts.map +1 -0
- package/dist/src/buildFunctions.js +59 -0
- package/dist/src/buildFunctions.js.map +1 -0
- package/dist/src/deployFunction.d.ts +10 -0
- package/dist/src/deployFunction.d.ts.map +1 -0
- package/dist/src/deployFunction.js +52 -0
- package/dist/src/deployFunction.js.map +1 -0
- package/dist/src/deployFunctions.d.ts +11 -0
- package/dist/src/deployFunctions.d.ts.map +1 -0
- package/dist/src/deployFunctions.js +30 -0
- package/dist/src/deployFunctions.js.map +1 -0
- package/dist/src/generate/collectLambdasFromFiles.d.ts +1 -12
- package/dist/src/generate/collectLambdasFromFiles.d.ts.map +1 -1
- package/dist/src/generate/collectLambdasFromFiles.js +8 -12
- package/dist/src/generate/collectLambdasFromFiles.js.map +1 -1
- package/dist/src/generate/generateFunctionName.d.ts +1 -1
- package/dist/src/generate/generateFunctionName.d.ts.map +1 -1
- package/dist/src/generateLambdaConfig.d.ts +5 -0
- package/dist/src/generateLambdaConfig.d.ts.map +1 -0
- package/dist/src/generateLambdaConfig.js +28 -0
- package/dist/src/generateLambdaConfig.js.map +1 -0
- package/dist/src/types/LambdaConfig.d.ts +13 -0
- package/dist/src/types/LambdaConfig.d.ts.map +1 -0
- package/dist/src/types/LambdaConfig.js +9 -0
- package/dist/src/types/LambdaConfig.js.map +1 -0
- package/dist/src/types/LambdaDeploymentConfiguration.d.ts +44 -0
- package/dist/src/types/LambdaDeploymentConfiguration.d.ts.map +1 -0
- package/dist/src/types/LambdaDeploymentConfiguration.js +3 -0
- package/dist/src/types/LambdaDeploymentConfiguration.js.map +1 -0
- package/dist/src/utilsAwsLambda.d.ts +10 -11
- package/dist/src/utilsAwsLambda.d.ts.map +1 -1
- package/dist/src/utilsAwsLambda.js +14 -50
- package/dist/src/utilsAwsLambda.js.map +1 -1
- package/package.json +12 -7
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { LambdaConfig } from './types/LambdaConfig';
|
|
2
|
+
export declare const getOutDirForLambda: (config: LambdaConfig) => string;
|
|
3
|
+
export declare const getOutFileForLambda: (config: LambdaConfig) => string;
|
|
4
|
+
export declare const buildFunctions: ({ routesDir, configs, lambdaNamePrefix, }: {
|
|
5
|
+
routesDir: string;
|
|
6
|
+
configs: LambdaConfig[];
|
|
7
|
+
lambdaNamePrefix?: string | undefined;
|
|
8
|
+
}) => Promise<void>;
|
|
9
|
+
//# sourceMappingURL=buildFunctions.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"buildFunctions.d.ts","sourceRoot":"","sources":["../../src/buildFunctions.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AAUpD,eAAO,MAAM,kBAAkB,WAAY,YAAY,KAAG,MAQzD,CAAC;AAEF,eAAO,MAAM,mBAAmB,WAAY,YAAY,KAAG,MAE1D,CAAC;AAEF,eAAO,MAAM,cAAc;eAKd,MAAM;aACR,YAAY,EAAE;;MAErB,QAAQ,IAAI,CA2Cf,CAAC"}
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.buildFunctions = exports.getOutFileForLambda = exports.getOutDirForLambda = void 0;
|
|
4
|
+
const esbuild_1 = require("esbuild");
|
|
5
|
+
const esbuild_plugin_pnp_1 = require("@yarnpkg/esbuild-plugin-pnp");
|
|
6
|
+
const generateFunctionName_1 = require("./generate/generateFunctionName");
|
|
7
|
+
const utils_sh_1 = require("@goldstack/utils-sh");
|
|
8
|
+
const getOutDirForLambda = (config) => {
|
|
9
|
+
if (config.path === '$default') {
|
|
10
|
+
return `./distLambda/${config.path}`;
|
|
11
|
+
}
|
|
12
|
+
if (config.path.endsWith('/')) {
|
|
13
|
+
return `./distLambda${config.path}index`;
|
|
14
|
+
}
|
|
15
|
+
return `./distLambda${config.path}`;
|
|
16
|
+
};
|
|
17
|
+
exports.getOutDirForLambda = getOutDirForLambda;
|
|
18
|
+
const getOutFileForLambda = (config) => {
|
|
19
|
+
return `${(0, exports.getOutDirForLambda)(config)}/lambda.js`;
|
|
20
|
+
};
|
|
21
|
+
exports.getOutFileForLambda = getOutFileForLambda;
|
|
22
|
+
const buildFunctions = async ({ routesDir, configs, lambdaNamePrefix, }) => {
|
|
23
|
+
const esbuildConfig = (0, utils_sh_1.readToType)('./esbuild.config.json');
|
|
24
|
+
await (0, utils_sh_1.rmSafe)('./distLambda');
|
|
25
|
+
(0, utils_sh_1.mkdir)('-p', './distLambda/zips');
|
|
26
|
+
for await (const config of configs) {
|
|
27
|
+
(0, utils_sh_1.mkdir)('-p', (0, exports.getOutDirForLambda)(config));
|
|
28
|
+
const esbuildLocalPath = (0, utils_sh_1.changeExtension)(`${routesDir}/${config.relativeFilePath}`, '.esbuild.config.json');
|
|
29
|
+
const functionName = (0, generateFunctionName_1.generateFunctionName)(lambdaNamePrefix, config);
|
|
30
|
+
const localEsbuildConfig = (0, utils_sh_1.readToType)(esbuildLocalPath);
|
|
31
|
+
const res = await (0, esbuild_1.build)({
|
|
32
|
+
plugins: [(0, esbuild_plugin_pnp_1.pnpPlugin)()],
|
|
33
|
+
bundle: true,
|
|
34
|
+
entryPoints: [`${routesDir}/${config.relativeFilePath}`],
|
|
35
|
+
external: [
|
|
36
|
+
'aws-sdk', // included in Lambda runtime environment
|
|
37
|
+
],
|
|
38
|
+
minify: true,
|
|
39
|
+
platform: 'node',
|
|
40
|
+
format: 'cjs',
|
|
41
|
+
target: 'node16.0',
|
|
42
|
+
treeShaking: true,
|
|
43
|
+
define: {
|
|
44
|
+
'process.env.NODE_ENV': '"production"',
|
|
45
|
+
},
|
|
46
|
+
sourcemap: true,
|
|
47
|
+
outfile: (0, exports.getOutFileForLambda)(config),
|
|
48
|
+
metafile: true,
|
|
49
|
+
...esbuildConfig,
|
|
50
|
+
...localEsbuildConfig,
|
|
51
|
+
});
|
|
52
|
+
if (!res.metafile) {
|
|
53
|
+
throw new Error(`Metafile for ${functionName} not defined.`);
|
|
54
|
+
}
|
|
55
|
+
(0, utils_sh_1.write)(JSON.stringify(res.metafile), `./distLambda/zips/${functionName}.meta.json`);
|
|
56
|
+
}
|
|
57
|
+
};
|
|
58
|
+
exports.buildFunctions = buildFunctions;
|
|
59
|
+
//# sourceMappingURL=buildFunctions.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"buildFunctions.js","sourceRoot":"","sources":["../../src/buildFunctions.ts"],"names":[],"mappings":";;;AAAA,qCAA8C;AAC9C,oEAAwD;AAExD,0EAAuE;AACvE,kDAM6B;AAEtB,MAAM,kBAAkB,GAAG,CAAC,MAAoB,EAAU,EAAE;IACjE,IAAI,MAAM,CAAC,IAAI,KAAK,UAAU,EAAE;QAC9B,OAAO,gBAAgB,MAAM,CAAC,IAAI,EAAE,CAAC;KACtC;IACD,IAAI,MAAM,CAAC,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,EAAE;QAC7B,OAAO,eAAe,MAAM,CAAC,IAAI,OAAO,CAAC;KAC1C;IACD,OAAO,eAAe,MAAM,CAAC,IAAI,EAAE,CAAC;AACtC,CAAC,CAAC;AARW,QAAA,kBAAkB,sBAQ7B;AAEK,MAAM,mBAAmB,GAAG,CAAC,MAAoB,EAAU,EAAE;IAClE,OAAO,GAAG,IAAA,0BAAkB,EAAC,MAAM,CAAC,YAAY,CAAC;AACnD,CAAC,CAAC;AAFW,QAAA,mBAAmB,uBAE9B;AAEK,MAAM,cAAc,GAAG,KAAK,EAAE,EACnC,SAAS,EACT,OAAO,EACP,gBAAgB,GAKjB,EAAiB,EAAE;IAClB,MAAM,aAAa,GAAG,IAAA,qBAAU,EAAe,uBAAuB,CAAC,CAAC;IAExE,MAAM,IAAA,iBAAM,EAA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C5B,qBAAqB,YAAY,YAAY,CAC9C,CAAC;KACH;AACH,CAAC,CAAC;AAnDW,QAAA,cAAc,kBAmDzB"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import AWS from 'aws-sdk';
|
|
2
|
+
export interface DeployFunctionParams {
|
|
3
|
+
lambdaPackageDir: string;
|
|
4
|
+
targetArchiveName?: string;
|
|
5
|
+
awsCredentials: AWS.Credentials;
|
|
6
|
+
region: string;
|
|
7
|
+
functionName: string;
|
|
8
|
+
}
|
|
9
|
+
export declare const deployFunction: (params: DeployFunctionParams) => Promise<any>;
|
|
10
|
+
//# sourceMappingURL=deployFunction.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"deployFunction.d.ts","sourceRoot":"","sources":["../../src/deployFunction.ts"],"names":[],"mappings":"AAGA,OAAO,GAAG,MAAM,SAAS,CAAC;AAE1B,MAAM,WAAW,oBAAoB;IACnC,gBAAgB,EAAE,MAAM,CAAC;IACzB,iBAAiB,CAAC,EAAE,MAAM,CAAC;IAC3B,cAAc,EAAE,GAAG,CAAC,WAAW,CAAC;IAChC,MAAM,EAAE,MAAM,CAAC;IACf,YAAY,EAAE,MAAM,CAAC;CACtB;AAED,eAAO,MAAM,cAAc,WACjB,oBAAoB,KAC3B,QAAQ,GAAG,CAmDb,CAAC"}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.deployFunction = void 0;
|
|
4
|
+
const utils_aws_cli_1 = require("@goldstack/utils-aws-cli");
|
|
5
|
+
const utils_sh_1 = require("@goldstack/utils-sh");
|
|
6
|
+
const deployFunction = async (params) => {
|
|
7
|
+
const targetArchive = params.targetArchiveName || `lambda-${new Date().getTime()}.zip`;
|
|
8
|
+
await (0, utils_sh_1.rmSafe)(targetArchive);
|
|
9
|
+
await (0, utils_sh_1.zip)({
|
|
10
|
+
directory: params.lambdaPackageDir,
|
|
11
|
+
target: targetArchive,
|
|
12
|
+
mode: 511,
|
|
13
|
+
});
|
|
14
|
+
let fixedTargetArchive = targetArchive;
|
|
15
|
+
const isWin = process.platform === 'win32';
|
|
16
|
+
if (!isWin) {
|
|
17
|
+
fixedTargetArchive = fixedTargetArchive.replace(/\$/g, '\\$');
|
|
18
|
+
}
|
|
19
|
+
const deployResult = await (0, utils_aws_cli_1.awsCli)({
|
|
20
|
+
credentials: params.awsCredentials,
|
|
21
|
+
region: params.region,
|
|
22
|
+
options: {
|
|
23
|
+
silent: true,
|
|
24
|
+
},
|
|
25
|
+
command: `lambda update-function-code --function-name ${params.functionName} --zip-file fileb://${fixedTargetArchive}`,
|
|
26
|
+
});
|
|
27
|
+
if (!params.targetArchiveName) {
|
|
28
|
+
await (0, utils_sh_1.rmSafe)(targetArchive);
|
|
29
|
+
}
|
|
30
|
+
// wait until lambda becomes active
|
|
31
|
+
let counter = 0;
|
|
32
|
+
let state = '';
|
|
33
|
+
while (counter < 20 && state !== 'Active') {
|
|
34
|
+
const res = await (0, utils_aws_cli_1.awsCli)({
|
|
35
|
+
credentials: params.awsCredentials,
|
|
36
|
+
region: params.region,
|
|
37
|
+
options: {
|
|
38
|
+
silent: true,
|
|
39
|
+
},
|
|
40
|
+
command: `lambda get-function --function-name ${params.functionName}`,
|
|
41
|
+
});
|
|
42
|
+
const data = JSON.parse(res);
|
|
43
|
+
state = data.Configuration.State;
|
|
44
|
+
counter++;
|
|
45
|
+
}
|
|
46
|
+
if (counter >= 20) {
|
|
47
|
+
throw new Error(`Function was still in state '${state}' after deployment`);
|
|
48
|
+
}
|
|
49
|
+
return JSON.parse(deployResult);
|
|
50
|
+
};
|
|
51
|
+
exports.deployFunction = deployFunction;
|
|
52
|
+
//# sourceMappingURL=deployFunction.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"deployFunction.js","sourceRoot":"","sources":["../../src/deployFunction.ts"],"names":[],"mappings":";;;AAAA,4DAAkD;AA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aACb;YACD,OAAO,EAAE,uCAAuC,MAAM,CAAC,YAAY,EAAE;SACtE,CAAC,CAAC;QACH,MAAM,IAAI,GAAG,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;QAC7B,KAAK,GAAG,IAAI,CAAC,aAAa,CAAC,KAAK,CAAC;QACjC,OAAO,EAAE,CAAC;KACX;IACD,IAAI,OAAO,IAAI,EAAE,EAAE;QACjB,MAAM,IAAI,KAAK,CAAC,gCAAgC,KAAK,oBAAoB,CAAC,CAAC;KAC5E;IACD,OAAO,IAAI,CAAC,KAAK,CAAC,YAAY,CAAC,CAAC;AAClC,CAAC,CAAC;AArDW,QAAA,cAAc,kBAqDzB"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { AWSDeployment } from '@goldstack/infra-aws';
|
|
2
|
+
import type { LambdaApiDeploymentConfiguration } from './types/LambdaDeploymentConfiguration';
|
|
3
|
+
import type { LambdaConfig } from './types/LambdaConfig';
|
|
4
|
+
export interface DeployFunctionsParams {
|
|
5
|
+
routesPath: string;
|
|
6
|
+
configuration: LambdaApiDeploymentConfiguration;
|
|
7
|
+
deployment: AWSDeployment;
|
|
8
|
+
config: LambdaConfig[];
|
|
9
|
+
}
|
|
10
|
+
export declare const deployFunctions: (params: DeployFunctionsParams) => Promise<void>;
|
|
11
|
+
//# sourceMappingURL=deployFunctions.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"deployFunctions.d.ts","sourceRoot":"","sources":["../../src/deployFunctions.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AAC1D,OAAO,KAAK,EAAE,gCAAgC,EAAE,MAAM,uCAAuC,CAAC;AAG9F,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AAQzD,MAAM,WAAW,qBAAqB;IACpC,UAAU,EAAE,MAAM,CAAC;IACnB,aAAa,EAAE,gCAAgC,CAAC;IAChD,UAAU,EAAE,aAAa,CAAC;IAC1B,MAAM,EAAE,YAAY,EAAE,CAAC;CACxB;AAED,eAAO,MAAM,eAAe,WAClB,qBAAqB,KAC5B,QAAQ,IAAI,CAsBd,CAAC"}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.deployFunctions = void 0;
|
|
4
|
+
const infra_aws_1 = require("@goldstack/infra-aws");
|
|
5
|
+
const deployFunction_1 = require("./deployFunction");
|
|
6
|
+
const generateFunctionName_1 = require("./generate/generateFunctionName");
|
|
7
|
+
const collectLambdasFromFiles_1 = require("./generate/collectLambdasFromFiles");
|
|
8
|
+
const utils_sh_1 = require("@goldstack/utils-sh");
|
|
9
|
+
const buildFunctions_1 = require("./buildFunctions");
|
|
10
|
+
const deployFunctions = async (params) => {
|
|
11
|
+
const lambdaConfig = (0, collectLambdasFromFiles_1.readLambdaConfig)(params.routesPath);
|
|
12
|
+
const operations = lambdaConfig.map(async (config) => {
|
|
13
|
+
const functionName = (0, generateFunctionName_1.generateFunctionName)(params.configuration.lambdaNamePrefix, config);
|
|
14
|
+
console.log(`[${functionName}]: Starting deployment`);
|
|
15
|
+
const functionDir = (0, buildFunctions_1.getOutDirForLambda)(config);
|
|
16
|
+
(0, utils_sh_1.mkdir)('-p', functionDir);
|
|
17
|
+
const targetArchive = `./distLambda/zips/${functionName}.zip`;
|
|
18
|
+
await (0, deployFunction_1.deployFunction)({
|
|
19
|
+
targetArchiveName: targetArchive,
|
|
20
|
+
lambdaPackageDir: functionDir,
|
|
21
|
+
awsCredentials: await (0, infra_aws_1.getAWSUser)(params.deployment.awsUser),
|
|
22
|
+
region: params.deployment.awsRegion,
|
|
23
|
+
functionName,
|
|
24
|
+
});
|
|
25
|
+
console.log(`[${functionName}]: Deployment completed`);
|
|
26
|
+
});
|
|
27
|
+
await Promise.all(operations);
|
|
28
|
+
};
|
|
29
|
+
exports.deployFunctions = deployFunctions;
|
|
30
|
+
//# sourceMappingURL=deployFunctions.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"deployFunctions.js","sourceRoot":"","sources":["../../src/deployFunctions.ts"],"names":[],"mappings":";;;AAEA,oDAAkD;AAClD,qDAAkD;AAElD,0EAAuE;AAEvE,gFAAsE;AAEtE,kDAA4C;AAC5C,qDAAsD;AAS/C,MAAM,eAAe,GAAG,KAAK,EAClC,MAA6B,EACd,EAAE;IACjB,MAAM,YAAY,GAAG,IAAA,0CAAgB,EAAC,MAAM,CAAC,UAAU,CAAC,CAAC;IAEzD,MAAM,UAAU,GAAG,YAAY,CAAC,GAAG,CAAC,KAAK,EAAE,MAAM,EAAE,EAAE;QACnD,MAAM,YAAY,GAAG,IAAA,2CAAoB,EACvC,MAAM,CAAC,aAAa,CAAC,gBAAgB,EACrC,MAAM,CACP,CAAC;QACF,OAAO,CAAC,GAAG,CAAC,IAAI,YAAY,wBAAwB,CAAC,CAAC;QACtD,MAAM,WAAW,GAAG,IAAA,mCAAkB,EAAC,MAAM,CAAC,CAAC;QAC/C,IAAA,gBAAK,EAAC,IAAI,EAAE,WAAW,CAAC,CAAC;QACzB,MAAM,aAAa,GAAG,qBAAqB,YAAY,MAAM,CAAC;QAC9D,MAAM,IAAA,+BAAc,EAAC;YACnB,iBAAiB,EAAE,aAAa;YAChC,gBAAgB,EAAE,WAAW;YAC7B,cAAc,EAAE,MAAM,IAAA,sBAAU,EAAC,MAAM,CAAC,UAAU,CAAC,OAAO,CAAC;YAC3D,MAAM,EAAE,MAAM,CAAC,UAAU,CAAC,SAAS;YACnC,YAAY;SACb,CAAC,CAAC;QACH,OAAO,CAAC,GAAG,CAAC,IAAI,YAAY,yBAAyB,CAAC,CAAC;IACzD,CAAC,CAAC,CAAC;IACH,MAAM,OAAO,CAAC,GAAG,CAAC,UAAU,CAAC,CAAC;AAChC,CAAC,CAAC;AAxBW,QAAA,eAAe,mBAwB1B"}
|
|
@@ -1,14 +1,3 @@
|
|
|
1
|
-
|
|
2
|
-
DIR = "DIR",
|
|
3
|
-
FUNCTION = "FUNCTION"
|
|
4
|
-
}
|
|
5
|
-
export interface LambdaConfig {
|
|
6
|
-
name: string;
|
|
7
|
-
type: RouteType;
|
|
8
|
-
absoluteFilePath: string;
|
|
9
|
-
relativeFilePath: string;
|
|
10
|
-
path: string;
|
|
11
|
-
route: string;
|
|
12
|
-
}
|
|
1
|
+
import type { LambdaConfig } from '../types/LambdaConfig';
|
|
13
2
|
export declare function readLambdaConfig(dir: string): LambdaConfig[];
|
|
14
3
|
//# sourceMappingURL=collectLambdasFromFiles.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"collectLambdasFromFiles.d.ts","sourceRoot":"","sources":["../../../src/generate/collectLambdasFromFiles.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"collectLambdasFromFiles.d.ts","sourceRoot":"","sources":["../../../src/generate/collectLambdasFromFiles.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,uBAAuB,CAAC;AAW1D,wBAAgB,gBAAgB,CAAC,GAAG,EAAE,MAAM,GAAG,YAAY,EAAE,CAU5D"}
|
|
@@ -3,20 +3,16 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.readLambdaConfig =
|
|
6
|
+
exports.readLambdaConfig = void 0;
|
|
7
7
|
const fs_1 = __importDefault(require("fs"));
|
|
8
8
|
const path_1 = require("path");
|
|
9
|
-
|
|
10
|
-
(function (RouteType) {
|
|
11
|
-
RouteType["DIR"] = "DIR";
|
|
12
|
-
RouteType["FUNCTION"] = "FUNCTION";
|
|
13
|
-
})(RouteType = exports.RouteType || (exports.RouteType = {}));
|
|
9
|
+
const LambdaConfig_1 = require("../types/LambdaConfig");
|
|
14
10
|
function readLambdaConfig(dir) {
|
|
15
11
|
const result = readLambdaConfigImpl(dir, dir);
|
|
16
12
|
if (!result.children) {
|
|
17
13
|
throw new Error('Invalid directory ' + dir);
|
|
18
14
|
}
|
|
19
|
-
return flattenConfig(result.children).filter((e) => e.type === RouteType.FUNCTION);
|
|
15
|
+
return flattenConfig(result.children).filter((e) => e.type === LambdaConfig_1.RouteType.FUNCTION);
|
|
20
16
|
}
|
|
21
17
|
exports.readLambdaConfig = readLambdaConfig;
|
|
22
18
|
function flattenConfig(config) {
|
|
@@ -31,8 +27,8 @@ function flattenConfig(config) {
|
|
|
31
27
|
}
|
|
32
28
|
return arr;
|
|
33
29
|
}
|
|
34
|
-
function posixPath(
|
|
35
|
-
return
|
|
30
|
+
function posixPath(pathString) {
|
|
31
|
+
return pathString.split(path_1.sep).join(path_1.posix.sep);
|
|
36
32
|
}
|
|
37
33
|
function removeExtension(path) {
|
|
38
34
|
return path.replace(/\.[^/.]+$/, '');
|
|
@@ -44,7 +40,7 @@ function makePath(configRoot, dir) {
|
|
|
44
40
|
}
|
|
45
41
|
if (path.indexOf('$index') !== -1) {
|
|
46
42
|
let newPath = path.replace('$index', '');
|
|
47
|
-
// API Gateway does not accept routes like /
|
|
43
|
+
// API Gateway does not accept routes like /my_route/
|
|
48
44
|
newPath = newPath.slice(0, newPath.length - 1);
|
|
49
45
|
return `/${newPath}`;
|
|
50
46
|
}
|
|
@@ -65,7 +61,7 @@ function readLambdaConfigImpl(configRoot, dir) {
|
|
|
65
61
|
const rootRoute = makeRoute(configRoot, dir);
|
|
66
62
|
const configItem = {
|
|
67
63
|
name: root,
|
|
68
|
-
type: RouteType.DIR,
|
|
64
|
+
type: LambdaConfig_1.RouteType.DIR,
|
|
69
65
|
absoluteFilePath: dir,
|
|
70
66
|
path: makePath(configRoot, dir),
|
|
71
67
|
relativeFilePath: (0, path_1.relative)(configRoot, dir),
|
|
@@ -86,7 +82,7 @@ function readLambdaConfigImpl(configRoot, dir) {
|
|
|
86
82
|
const route = makeRoute(configRoot, fullPath);
|
|
87
83
|
configItem.children[name] = {
|
|
88
84
|
name: removeExtension(name),
|
|
89
|
-
type: RouteType.FUNCTION,
|
|
85
|
+
type: LambdaConfig_1.RouteType.FUNCTION,
|
|
90
86
|
path: makePath(configRoot, fullPath),
|
|
91
87
|
absoluteFilePath: fullPath,
|
|
92
88
|
relativeFilePath: (0, path_1.relative)(configRoot, fullPath),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"collectLambdasFromFiles.js","sourceRoot":"","sources":["../../../src/generate/collectLambdasFromFiles.ts"],"names":[],"mappings":";;;;;;AAAA,4CAAgC;AAChC,+BAAqD;AAErD,
|
|
1
|
+
{"version":3,"file":"collectLambdasFromFiles.js","sourceRoot":"","sources":["../../../src/generate/collectLambdasFromFiles.ts"],"names":[],"mappings":";;;;;;AAAA,4CAAgC;AAChC,+BAAqD;AAErD,wDAAkD;AAUlD,SAAgB,gBAAgB,CAAC,GAAW;IAC1C,MAAM,MAAM,GAAG,oBAAoB,CAAC,GAAG,EAAE,GAAG,CAAC,CAAC;IAE9C,IAAI,CAAC,MAAM,CAAC,QAAQ,EAAE;QACpB,MAAM,IAAI,KAAK,CAAC,oBAAoB,GAAG,GAAG,CAAC,CAAC;KAC7C;IAED,OAAO,aAAa,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC,MAAM,CAC1C,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,KAAK,wBAAS,CAAC,QAAQ,CACrC,CAAC;AACJ,CAAC;AAVD,4CAUC;AAED,SAAS,aAAa,CAAC,MAAuB;IAC5C,MAAM,GAAG,GAAmB,EAAE,CAAC;IAC/B,KAAK,MAAM,KAAK,IAAI,MAAM,CAAC,OAAO,CAAC,MAAM,CAAC,EAAE;QAC1C,MAAM,MAAM,GAAG,EAAE,GAAG,KAAK,CAAC,CAAC,CAAC,EAAE,CAAC;QAC/B,MAAM,CAAC,QAAQ,GAAG,S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,CAAC,IAAI,CAAC,GAAG;gBAC1B,IAAI,EAAE,eAAe,CAAC,IAAI,CAAC;gBAC3B,IAAI,EAAE,wBAAS,CAAC,QAAQ;gBACxB,IAAI,EAAE,QAAQ,CAAC,UAAU,EAAE,QAAQ,CAAC;gBACpC,gBAAgB,EAAE,QAAQ;gBAC1B,gBAAgB,EAAE,IAAA,eAAQ,EAAC,UAAU,EAAE,QAAQ,CAAC;gBAChD,KAAK,EAAE,KAAK;aACb,CAAC;SACH;aAAM;YACL,SAAS;SACV;KACF;IACD,SAAS,CAAC,SAAS,EAAE,CAAC;IAEtB,OAAO,UAAU,CAAC;AACpB,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"generateFunctionName.d.ts","sourceRoot":"","sources":["../../../src/generate/generateFunctionName.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"generateFunctionName.d.ts","sourceRoot":"","sources":["../../../src/generate/generateFunctionName.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAC;AAgB5D;;GAEG;AACH,eAAO,MAAM,oBAAoB,WACvB,MAAM,GAAG,SAAS,UAClB,YAAY,KACnB,MAsCF,CAAC"}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { LambdaConfig } from '@goldstack/utils-aws-lambda';
|
|
2
|
+
import { LambdaRoutesConfig, LambdaApiDeploymentConfiguration } from './types/LambdaDeploymentConfiguration';
|
|
3
|
+
export declare const generateLambdaConfig: (configuration: LambdaApiDeploymentConfiguration, config: LambdaConfig[]) => LambdaRoutesConfig;
|
|
4
|
+
export declare const validateDeployment: (config: LambdaRoutesConfig) => boolean;
|
|
5
|
+
//# sourceMappingURL=generateLambdaConfig.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"generateLambdaConfig.d.ts","sourceRoot":"","sources":["../../src/generateLambdaConfig.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,YAAY,EAEb,MAAM,6BAA6B,CAAC;AACrC,OAAO,EACL,kBAAkB,EAClB,gCAAgC,EACjC,MAAM,uCAAuC,CAAC;AAE/C,eAAO,MAAM,oBAAoB,kBAChB,gCAAgC,UACvC,YAAY,EAAE,KACrB,kBAYF,CAAC;AAEF,eAAO,MAAM,kBAAkB,WAAY,kBAAkB,KAAG,OAO/D,CAAC"}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.validateDeployment = exports.generateLambdaConfig = void 0;
|
|
4
|
+
const utils_aws_lambda_1 = require("@goldstack/utils-aws-lambda");
|
|
5
|
+
const generateLambdaConfig = (configuration, config) => {
|
|
6
|
+
return config.reduce((last, curr) => {
|
|
7
|
+
let id = curr.route;
|
|
8
|
+
if (id === '$default') {
|
|
9
|
+
id = 'default';
|
|
10
|
+
}
|
|
11
|
+
last[`${id}`] = {
|
|
12
|
+
function_name: (0, utils_aws_lambda_1.generateFunctionName)(configuration.lambdaNamePrefix, curr),
|
|
13
|
+
route: curr.route,
|
|
14
|
+
};
|
|
15
|
+
return last;
|
|
16
|
+
}, {});
|
|
17
|
+
};
|
|
18
|
+
exports.generateLambdaConfig = generateLambdaConfig;
|
|
19
|
+
const validateDeployment = (config) => {
|
|
20
|
+
let valid = true;
|
|
21
|
+
for (const e of Object.entries(config)) {
|
|
22
|
+
valid = valid && e[0].length > 0;
|
|
23
|
+
valid = valid && !!e[1].function_name && e[1].function_name.length > 0;
|
|
24
|
+
}
|
|
25
|
+
return valid;
|
|
26
|
+
};
|
|
27
|
+
exports.validateDeployment = validateDeployment;
|
|
28
|
+
//# sourceMappingURL=generateLambdaConfig.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"generateLambdaConfig.js","sourceRoot":"","sources":["../../src/generateLambdaConfig.ts"],"names":[],"mappings":";;;AAAA,kEAGqC;AAM9B,MAAM,oBAAoB,GAAG,CAClC,aAA+C,EAC/C,MAAsB,EACF,EAAE;IACtB,OAAO,MAAM,CAAC,MAAM,CAAC,CAAC,IAAI,EAAE,IAAI,EAAE,EAAE;QAClC,IAAI,EAAE,GAAG,IAAI,CAAC,KAAK,CAAC;QACpB,IAAI,EAAE,KAAK,UAAU,EAAE;YACrB,EAAE,GAAG,SAAS,CAAC;SAChB;QACD,IAAI,CAAC,GAAG,EAAE,EAAE,CAAC,GAAG;YACd,aAAa,EAAE,IAAA,uCAAoB,EAAC,aAAa,CAAC,gBAAgB,EAAE,IAAI,CAAC;YACzE,KAAK,EAAE,IAAI,CAAC,KAAK;SAClB,CAAC;QACF,OAAO,IAAI,CAAC;IACd,CAAC,EAAE,EAAE,CAAC,CAAC;AACT,CAAC,CAAC;AAfW,QAAA,oBAAoB,wBAe/B;AAEK,MAAM,kBAAkB,GAAG,CAAC,MAA0B,EAAW,EAAE;IACxE,IAAI,KAAK,GAAG,IAAI,CAAC;IACjB,KAAK,MAAM,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,MAAM,CAAC,EAAE;QACtC,KAAK,GAAG,KAAK,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,MAAM,GAAG,CAAC,CAAC;QACjC,KAAK,GAAG,KAAK,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,aAAa,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,aAAa,CAAC,MAAM,GAAG,CAAC,CAAC;KACxE;IACD,OAAO,KAAK,CAAC;AACf,CAAC,CAAC;AAPW,QAAA,kBAAkB,sBAO7B"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
export declare enum RouteType {
|
|
2
|
+
DIR = "DIR",
|
|
3
|
+
FUNCTION = "FUNCTION"
|
|
4
|
+
}
|
|
5
|
+
export interface LambdaConfig {
|
|
6
|
+
name: string;
|
|
7
|
+
type: RouteType;
|
|
8
|
+
absoluteFilePath: string;
|
|
9
|
+
relativeFilePath: string;
|
|
10
|
+
path: string;
|
|
11
|
+
route: string;
|
|
12
|
+
}
|
|
13
|
+
//# sourceMappingURL=LambdaConfig.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"LambdaConfig.d.ts","sourceRoot":"","sources":["../../../src/types/LambdaConfig.ts"],"names":[],"mappings":"AAAA,oBAAY,SAAS;IACnB,GAAG,QAAQ;IACX,QAAQ,aAAa;CACtB;AACD,MAAM,WAAW,YAAY;IAC3B,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,SAAS,CAAC;IAChB,gBAAgB,EAAE,MAAM,CAAC;IACzB,gBAAgB,EAAE,MAAM,CAAC;IACzB,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,MAAM,CAAC;CACf"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.RouteType = void 0;
|
|
4
|
+
var RouteType;
|
|
5
|
+
(function (RouteType) {
|
|
6
|
+
RouteType["DIR"] = "DIR";
|
|
7
|
+
RouteType["FUNCTION"] = "FUNCTION";
|
|
8
|
+
})(RouteType = exports.RouteType || (exports.RouteType = {}));
|
|
9
|
+
//# sourceMappingURL=LambdaConfig.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"LambdaConfig.js","sourceRoot":"","sources":["../../../src/types/LambdaConfig.ts"],"names":[],"mappings":";;;AAAA,IAAY,SAGX;AAHD,WAAY,SAAS;IACnB,wBAAW,CAAA;IACX,kCAAqB,CAAA;AACvB,CAAC,EAHW,SAAS,GAAT,iBAAS,KAAT,iBAAS,QAGpB"}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The prefix to be used for names of the generated lambdas for the API endpoints.
|
|
3
|
+
*
|
|
4
|
+
* @title Lambda Name Prefix
|
|
5
|
+
* @pattern ^[A-Za-z0-9-_]*$
|
|
6
|
+
*/
|
|
7
|
+
declare type LambdaNamePrefix = string;
|
|
8
|
+
/**
|
|
9
|
+
* The domain name that the API should be deployed to (e.g. api.mysite.com)
|
|
10
|
+
*
|
|
11
|
+
* @title API Domain
|
|
12
|
+
* @pattern ^[^\s]*
|
|
13
|
+
*/
|
|
14
|
+
export declare type APIDomain = string;
|
|
15
|
+
/**
|
|
16
|
+
* The domain name of the Route 53 hosted zone that the domain for this API should be added to.
|
|
17
|
+
*
|
|
18
|
+
* @title Hosted Zone Domain
|
|
19
|
+
* @pattern ^[^\s]*
|
|
20
|
+
*/
|
|
21
|
+
export declare type HostedZoneDomain = string;
|
|
22
|
+
/**
|
|
23
|
+
* Optional URL for an UI that should be allowed to access this server.
|
|
24
|
+
*
|
|
25
|
+
* @title CORS Header
|
|
26
|
+
* @pattern ^[^\s]*
|
|
27
|
+
*/
|
|
28
|
+
export declare type CorsHeader = string;
|
|
29
|
+
export interface LambdaRouteConfig {
|
|
30
|
+
function_name: string;
|
|
31
|
+
route: string;
|
|
32
|
+
}
|
|
33
|
+
export declare type LambdaRoutesConfig = {
|
|
34
|
+
[key: string]: LambdaRouteConfig;
|
|
35
|
+
};
|
|
36
|
+
export interface LambdaApiDeploymentConfiguration {
|
|
37
|
+
lambdaNamePrefix?: LambdaNamePrefix;
|
|
38
|
+
apiDomain: APIDomain;
|
|
39
|
+
hostedZoneDomain: HostedZoneDomain;
|
|
40
|
+
cors?: CorsHeader;
|
|
41
|
+
lambdas: LambdaRoutesConfig;
|
|
42
|
+
}
|
|
43
|
+
export {};
|
|
44
|
+
//# sourceMappingURL=LambdaDeploymentConfiguration.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"LambdaDeploymentConfiguration.d.ts","sourceRoot":"","sources":["../../../src/types/LambdaDeploymentConfiguration.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,aAAK,gBAAgB,GAAG,MAAM,CAAC;AAE/B;;;;;GAKG;AACH,oBAAY,SAAS,GAAG,MAAM,CAAC;AAE/B;;;;;GAKG;AACH,oBAAY,gBAAgB,GAAG,MAAM,CAAC;AAEtC;;;;;GAKG;AACH,oBAAY,UAAU,GAAG,MAAM,CAAC;AAEhC,MAAM,WAAW,iBAAiB;IAChC,aAAa,EAAE,MAAM,CAAC;IACtB,KAAK,EAAE,MAAM,CAAC;CACf;AAED,oBAAY,kBAAkB,GAAG;IAC/B,CAAC,GAAG,EAAE,MAAM,GAAG,iBAAiB,CAAC;CAClC,CAAC;AAEF,MAAM,WAAW,gCAAgC;IAC/C,gBAAgB,CAAC,EAAE,gBAAgB,CAAC;IACpC,SAAS,EAAE,SAAS,CAAC;IACrB,gBAAgB,EAAE,gBAAgB,CAAC;IACnC,IAAI,CAAC,EAAE,UAAU,CAAC;IAClB,OAAO,EAAE,kBAAkB,CAAC;CAC7B"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"LambdaDeploymentConfiguration.js","sourceRoot":"","sources":["../../../src/types/LambdaDeploymentConfiguration.ts"],"names":[],"mappings":""}
|
|
@@ -1,13 +1,12 @@
|
|
|
1
|
-
export { readLambdaConfig
|
|
1
|
+
export { readLambdaConfig } from './generate/collectLambdasFromFiles';
|
|
2
2
|
export { generateFunctionName } from './generate/generateFunctionName';
|
|
3
|
-
export type { LambdaConfig } from './
|
|
4
|
-
|
|
5
|
-
export
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
}
|
|
12
|
-
export declare const deployFunction: (params: DeployFunctionParams) => Promise<any>;
|
|
3
|
+
export type { LambdaConfig } from './types/LambdaConfig';
|
|
4
|
+
export { RouteType } from './types/LambdaConfig';
|
|
5
|
+
export type { LambdaApiDeploymentConfiguration, APIDomain, CorsHeader, HostedZoneDomain, } from './types/LambdaDeploymentConfiguration';
|
|
6
|
+
export type { DeployFunctionParams } from './deployFunction';
|
|
7
|
+
export { deployFunction } from './deployFunction';
|
|
8
|
+
export type { DeployFunctionsParams } from './deployFunctions';
|
|
9
|
+
export { deployFunctions } from './deployFunctions';
|
|
10
|
+
export { buildFunctions, getOutDirForLambda, getOutFileForLambda, } from './buildFunctions';
|
|
11
|
+
export { generateLambdaConfig, validateDeployment, } from './generateLambdaConfig';
|
|
13
12
|
//# sourceMappingURL=utilsAwsLambda.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utilsAwsLambda.d.ts","sourceRoot":"","sources":["../../src/utilsAwsLambda.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"utilsAwsLambda.d.ts","sourceRoot":"","sources":["../../src/utilsAwsLambda.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,oCAAoC,CAAC;AAEtE,OAAO,EAAE,oBAAoB,EAAE,MAAM,iCAAiC,CAAC;AAEvE,YAAY,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AACzD,OAAO,EAAE,SAAS,EAAE,MAAM,sBAAsB,CAAC;AAEjD,YAAY,EACV,gCAAgC,EAChC,SAAS,EACT,UAAU,EACV,gBAAgB,GACjB,MAAM,uCAAuC,CAAC;AAE/C,YAAY,EAAE,oBAAoB,EAAE,MAAM,kBAAkB,CAAC;AAC7D,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAElD,YAAY,EAAE,qBAAqB,EAAE,MAAM,mBAAmB,CAAC;AAC/D,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AAEpD,OAAO,EACL,cAAc,EACd,kBAAkB,EAClB,mBAAmB,GACpB,MAAM,kBAAkB,CAAC;AAE1B,OAAO,EACL,oBAAoB,EACpB,kBAAkB,GACnB,MAAM,wBAAwB,CAAC"}
|
|
@@ -1,57 +1,21 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
4
|
-
const utils_aws_cli_1 = require("@goldstack/utils-aws-cli");
|
|
5
|
-
const utils_sh_1 = require("@goldstack/utils-sh");
|
|
3
|
+
exports.validateDeployment = exports.generateLambdaConfig = exports.getOutFileForLambda = exports.getOutDirForLambda = exports.buildFunctions = exports.deployFunctions = exports.deployFunction = exports.RouteType = exports.generateFunctionName = exports.readLambdaConfig = void 0;
|
|
6
4
|
var collectLambdasFromFiles_1 = require("./generate/collectLambdasFromFiles");
|
|
7
5
|
Object.defineProperty(exports, "readLambdaConfig", { enumerable: true, get: function () { return collectLambdasFromFiles_1.readLambdaConfig; } });
|
|
8
|
-
Object.defineProperty(exports, "RouteType", { enumerable: true, get: function () { return collectLambdasFromFiles_1.RouteType; } });
|
|
9
6
|
var generateFunctionName_1 = require("./generate/generateFunctionName");
|
|
10
7
|
Object.defineProperty(exports, "generateFunctionName", { enumerable: true, get: function () { return generateFunctionName_1.generateFunctionName; } });
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
const deployResult = await (0, utils_aws_cli_1.awsCli)({
|
|
25
|
-
credentials: params.awsCredentials,
|
|
26
|
-
region: params.region,
|
|
27
|
-
options: {
|
|
28
|
-
silent: true,
|
|
29
|
-
},
|
|
30
|
-
command: `lambda update-function-code --function-name ${params.functionName} --zip-file fileb://${fixedTargetArchive}`,
|
|
31
|
-
});
|
|
32
|
-
if (!params.targetArchiveName) {
|
|
33
|
-
await (0, utils_sh_1.rmSafe)(targetArchive);
|
|
34
|
-
}
|
|
35
|
-
// wait until lambda becomes active
|
|
36
|
-
let counter = 0;
|
|
37
|
-
let state = '';
|
|
38
|
-
while (counter < 20 && state !== 'Active') {
|
|
39
|
-
const res = await (0, utils_aws_cli_1.awsCli)({
|
|
40
|
-
credentials: params.awsCredentials,
|
|
41
|
-
region: params.region,
|
|
42
|
-
options: {
|
|
43
|
-
silent: true,
|
|
44
|
-
},
|
|
45
|
-
command: `lambda get-function --function-name ${params.functionName}`,
|
|
46
|
-
});
|
|
47
|
-
const data = JSON.parse(res);
|
|
48
|
-
state = data.Configuration.State;
|
|
49
|
-
counter++;
|
|
50
|
-
}
|
|
51
|
-
if (counter >= 20) {
|
|
52
|
-
throw new Error(`Function was still in state '${state}' after deployment`);
|
|
53
|
-
}
|
|
54
|
-
return JSON.parse(deployResult);
|
|
55
|
-
};
|
|
56
|
-
exports.deployFunction = deployFunction;
|
|
8
|
+
var LambdaConfig_1 = require("./types/LambdaConfig");
|
|
9
|
+
Object.defineProperty(exports, "RouteType", { enumerable: true, get: function () { return LambdaConfig_1.RouteType; } });
|
|
10
|
+
var deployFunction_1 = require("./deployFunction");
|
|
11
|
+
Object.defineProperty(exports, "deployFunction", { enumerable: true, get: function () { return deployFunction_1.deployFunction; } });
|
|
12
|
+
var deployFunctions_1 = require("./deployFunctions");
|
|
13
|
+
Object.defineProperty(exports, "deployFunctions", { enumerable: true, get: function () { return deployFunctions_1.deployFunctions; } });
|
|
14
|
+
var buildFunctions_1 = require("./buildFunctions");
|
|
15
|
+
Object.defineProperty(exports, "buildFunctions", { enumerable: true, get: function () { return buildFunctions_1.buildFunctions; } });
|
|
16
|
+
Object.defineProperty(exports, "getOutDirForLambda", { enumerable: true, get: function () { return buildFunctions_1.getOutDirForLambda; } });
|
|
17
|
+
Object.defineProperty(exports, "getOutFileForLambda", { enumerable: true, get: function () { return buildFunctions_1.getOutFileForLambda; } });
|
|
18
|
+
var generateLambdaConfig_1 = require("./generateLambdaConfig");
|
|
19
|
+
Object.defineProperty(exports, "generateLambdaConfig", { enumerable: true, get: function () { return generateLambdaConfig_1.generateLambdaConfig; } });
|
|
20
|
+
Object.defineProperty(exports, "validateDeployment", { enumerable: true, get: function () { return generateLambdaConfig_1.validateDeployment; } });
|
|
57
21
|
//# sourceMappingURL=utilsAwsLambda.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utilsAwsLambda.js","sourceRoot":"","sources":["../../src/utilsAwsLambda.ts"],"names":[],"mappings":";;;AAAA,
|
|
1
|
+
{"version":3,"file":"utilsAwsLambda.js","sourceRoot":"","sources":["../../src/utilsAwsLambda.ts"],"names":[],"mappings":";;;AAAA,8EAAsE;AAA7D,2HAAA,gBAAgB,OAAA;AAEzB,wEAAuE;AAA9D,4HAAA,oBAAoB,OAAA;AAG7B,qDAAiD;AAAxC,yGAAA,SAAS,OAAA;AAUlB,mDAAkD;AAAzC,gHAAA,cAAc,OAAA;AAGvB,qDAAoD;AAA3C,kHAAA,eAAe,OAAA;AAExB,mDAI0B;AAHxB,gHAAA,cAAc,OAAA;AACd,oHAAA,kBAAkB,OAAA;AAClB,qHAAA,mBAAmB,OAAA;AAGrB,+DAGgC;AAF9B,4HAAA,oBAAoB,OAAA;AACpB,0HAAA,kBAAkB,OAAA"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@goldstack/utils-aws-lambda",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.32",
|
|
4
4
|
"description": "Utilities for deploying AWS Lambda functions",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"goldstack",
|
|
@@ -42,19 +42,24 @@
|
|
|
42
42
|
"version:apply:force": "yarn version $@ && yarn version apply"
|
|
43
43
|
},
|
|
44
44
|
"dependencies": {
|
|
45
|
-
"@goldstack/
|
|
46
|
-
"@goldstack/utils-
|
|
47
|
-
"@goldstack/utils-
|
|
48
|
-
"
|
|
45
|
+
"@goldstack/infra-aws": "0.3.47",
|
|
46
|
+
"@goldstack/utils-aws-cli": "0.3.57",
|
|
47
|
+
"@goldstack/utils-log": "0.2.16",
|
|
48
|
+
"@goldstack/utils-sh": "0.4.33",
|
|
49
|
+
"@yarnpkg/esbuild-plugin-pnp": "^3.0.0-rc.11",
|
|
50
|
+
"archiver": "^5.3.1",
|
|
51
|
+
"aws-sdk": "2.1055.0",
|
|
52
|
+
"esbuild": "^0.14.48"
|
|
49
53
|
},
|
|
50
54
|
"devDependencies": {
|
|
51
|
-
"@goldstack/utils-git": "0.1.
|
|
55
|
+
"@goldstack/utils-git": "0.1.36",
|
|
56
|
+
"@types/aws-lambda": "^8.10.88",
|
|
52
57
|
"@types/jest": "^27.5.1",
|
|
53
58
|
"@types/node": "^17.0.33",
|
|
54
59
|
"jest": "^28.1.0",
|
|
55
60
|
"rimraf": "^3.0.2",
|
|
56
61
|
"ts-jest": "^28.0.2",
|
|
57
|
-
"typescript": "^4.
|
|
62
|
+
"typescript": "^4.7.4"
|
|
58
63
|
},
|
|
59
64
|
"publishConfig": {
|
|
60
65
|
"main": "dist/src/utilsAwsLambda.js"
|