@emarketeer/ts-microservice-commons 10.3.0 → 10.5.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/dist/cdk/cjs/index.js
CHANGED
|
@@ -10,13 +10,13 @@ var constructs = require('constructs');
|
|
|
10
10
|
var awsSsm = require('aws-cdk-lib/aws-ssm');
|
|
11
11
|
var path = require('path');
|
|
12
12
|
var fs = require('fs');
|
|
13
|
+
var crypto = require('crypto');
|
|
13
14
|
var child_process = require('child_process');
|
|
14
15
|
var awsDynamodb = require('aws-cdk-lib/aws-dynamodb');
|
|
15
16
|
var awsApigateway = require('aws-cdk-lib/aws-apigateway');
|
|
16
17
|
var awsApigatewayv2 = require('aws-cdk-lib/aws-apigatewayv2');
|
|
17
18
|
var awsApigatewayv2Integrations = require('aws-cdk-lib/aws-apigatewayv2-integrations');
|
|
18
19
|
var awsCertificatemanager = require('aws-cdk-lib/aws-certificatemanager');
|
|
19
|
-
var crypto = require('crypto');
|
|
20
20
|
var awsSqs = require('aws-cdk-lib/aws-sqs');
|
|
21
21
|
var awsSns = require('aws-cdk-lib/aws-sns');
|
|
22
22
|
var awsSnsSubscriptions = require('aws-cdk-lib/aws-sns-subscriptions');
|
|
@@ -518,7 +518,7 @@ function getHandlerBundlerPath() {
|
|
|
518
518
|
const cwd = process.cwd();
|
|
519
519
|
const candidates = [
|
|
520
520
|
path__namespace.join(cwd, 'node_modules', PACKAGE_NAME, HANDLER_BUNDLER_RELATIVE_PATH),
|
|
521
|
-
path__namespace.join(cwd, HANDLER_BUNDLER_RELATIVE_PATH)
|
|
521
|
+
path__namespace.join(cwd, HANDLER_BUNDLER_RELATIVE_PATH),
|
|
522
522
|
];
|
|
523
523
|
for (const candidate of candidates) {
|
|
524
524
|
if (fs__namespace.existsSync(candidate)) {
|
|
@@ -536,8 +536,13 @@ function getHandlerBundlerPath() {
|
|
|
536
536
|
* - Otherwise bundles `entryFile` via the project handler bundler at synth
|
|
537
537
|
* time, with overrides applied on top of the defaults.
|
|
538
538
|
*
|
|
539
|
-
*
|
|
540
|
-
*
|
|
539
|
+
* An explicit `assetHash` is derived per call from the entry path, bundling
|
|
540
|
+
* overrides, and a synth-time timestamp. The entry path is required so that
|
|
541
|
+
* multiple handlers under the same source directory (the common
|
|
542
|
+
* `src/handlers/` layout) don't collapse into one asset — without it, CDK
|
|
543
|
+
* would run `tryBundle` once and silently reuse the same code for every
|
|
544
|
+
* lambda. The timestamp forces a fresh asset on every synth so each deploy
|
|
545
|
+
* uploads a clean rebuild rather than reusing a cached upload.
|
|
541
546
|
*/
|
|
542
547
|
function resolveLambdaCode(options) {
|
|
543
548
|
if (options.codePath) {
|
|
@@ -552,8 +557,15 @@ function resolveLambdaCode(options) {
|
|
|
552
557
|
}
|
|
553
558
|
const overrides = options.bundling;
|
|
554
559
|
const bundlerPath = getHandlerBundlerPath();
|
|
560
|
+
const handlerName = path__namespace.basename(entry, path__namespace.extname(entry));
|
|
561
|
+
const hash = crypto.createHash('sha256')
|
|
562
|
+
.update(entry)
|
|
563
|
+
.update(JSON.stringify(overrides ?? {}))
|
|
564
|
+
.update(String(Date.now()))
|
|
565
|
+
.digest('hex');
|
|
566
|
+
const assetHash = `${handlerName}-${hash}`;
|
|
555
567
|
return awsLambda.Code.fromAsset(path__namespace.dirname(entry), {
|
|
556
|
-
|
|
568
|
+
assetHash,
|
|
557
569
|
bundling: {
|
|
558
570
|
// CDK requires `image` even when local bundling succeeds. We never use
|
|
559
571
|
// the Docker fallback — `tryBundle` always returns true.
|
|
@@ -563,12 +575,12 @@ function resolveLambdaCode(options) {
|
|
|
563
575
|
const stdin = JSON.stringify({ entry, outDir: outputDir, overrides });
|
|
564
576
|
child_process.execFileSync('node', [bundlerPath], {
|
|
565
577
|
input: stdin,
|
|
566
|
-
stdio: ['pipe', 'inherit', 'inherit']
|
|
578
|
+
stdio: ['pipe', 'inherit', 'inherit'],
|
|
567
579
|
});
|
|
568
580
|
return true;
|
|
569
|
-
}
|
|
570
|
-
}
|
|
571
|
-
}
|
|
581
|
+
},
|
|
582
|
+
},
|
|
583
|
+
},
|
|
572
584
|
});
|
|
573
585
|
}
|
|
574
586
|
|