sst 2.11.8 → 2.11.10
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/cli/commands/build.js
CHANGED
|
@@ -6,8 +6,10 @@ export const build = (program) => program.command("build", "Build your app", (ya
|
|
|
6
6
|
const { Stacks } = await import("../../stacks/index.js");
|
|
7
7
|
const { Colors } = await import("../colors.js");
|
|
8
8
|
const path = await import("path");
|
|
9
|
+
const project = useProject();
|
|
10
|
+
const [_metafile, sstConfig] = await Stacks.load(project.paths.config);
|
|
9
11
|
const result = await Stacks.synth({
|
|
10
|
-
fn:
|
|
12
|
+
fn: sstConfig.stacks,
|
|
11
13
|
buildDir: args.to,
|
|
12
14
|
mode: "deploy",
|
|
13
15
|
});
|
package/constructs/EventBus.d.ts
CHANGED
|
@@ -426,6 +426,7 @@ export declare class EventBus extends Construct implements SSTConstruct {
|
|
|
426
426
|
getFunctionBinding(): FunctionBindingProps;
|
|
427
427
|
private retrierQueue;
|
|
428
428
|
private retrierFn;
|
|
429
|
+
private retrierMap;
|
|
429
430
|
private getRetrier;
|
|
430
431
|
private createEventBus;
|
|
431
432
|
private addRule;
|
package/constructs/EventBus.js
CHANGED
|
@@ -8,7 +8,9 @@ import { getFunctionRef, isCDKConstruct } from "./Construct.js";
|
|
|
8
8
|
import { Function as Fn, } from "./Function.js";
|
|
9
9
|
import { SqsEventSource } from "aws-cdk-lib/aws-lambda-event-sources";
|
|
10
10
|
import { SqsDestination } from "aws-cdk-lib/aws-lambda-destinations";
|
|
11
|
+
import url from "url";
|
|
11
12
|
import path from "path";
|
|
13
|
+
const __dirname = path.dirname(url.fileURLToPath(import.meta.url));
|
|
12
14
|
/////////////////////
|
|
13
15
|
// Construct
|
|
14
16
|
/////////////////////
|
|
@@ -231,12 +233,17 @@ export class EventBus extends Construct {
|
|
|
231
233
|
}
|
|
232
234
|
retrierQueue;
|
|
233
235
|
retrierFn;
|
|
236
|
+
retrierMap = {};
|
|
234
237
|
getRetrier() {
|
|
238
|
+
const app = this.node.root;
|
|
235
239
|
if (this.retrierFn && this.retrierQueue) {
|
|
236
240
|
return { fn: this.retrierFn, queue: this.retrierQueue };
|
|
237
241
|
}
|
|
238
|
-
this.retrierQueue = new sqs.Queue(this, `RetrierQueue
|
|
242
|
+
this.retrierQueue = new sqs.Queue(this, `RetrierQueue`, {
|
|
243
|
+
queueName: app.logicalPrefixedName(this.node.id + "Retrier"),
|
|
244
|
+
});
|
|
239
245
|
this.retrierFn = new lambda.Function(this, `RetrierFunction`, {
|
|
246
|
+
functionName: app.logicalPrefixedName(this.node.id + "Retrier"),
|
|
240
247
|
runtime: lambda.Runtime.NODEJS_14_X,
|
|
241
248
|
handler: "index.handler",
|
|
242
249
|
code: lambda.Code.fromAsset(path.join(__dirname, "../support/event-bus-retrier")),
|
|
@@ -350,7 +357,20 @@ export class EventBus extends Construct {
|
|
|
350
357
|
const count = this.subs.get(type) || 0 + 1;
|
|
351
358
|
this.subs.set(type, count);
|
|
352
359
|
const name = `${type.replaceAll(/[^a-zA-Z_]/g, "_")}_${count}`;
|
|
353
|
-
const
|
|
360
|
+
const retries = props?.retries || this.props.defaults?.retries;
|
|
361
|
+
const fn = (() => {
|
|
362
|
+
if (retries) {
|
|
363
|
+
const retrier = this.getRetrier();
|
|
364
|
+
const fn = Fn.fromDefinition(this, name, target, {
|
|
365
|
+
onFailure: new SqsDestination(retrier.queue),
|
|
366
|
+
});
|
|
367
|
+
this.retrierMap[fn.functionArn] = retries;
|
|
368
|
+
retrier.fn.addEnvironment(`RETRIES`, JSON.stringify(this.retrierMap));
|
|
369
|
+
fn.grantInvoke(retrier.fn);
|
|
370
|
+
return fn;
|
|
371
|
+
}
|
|
372
|
+
return Fn.fromDefinition(this, name, target);
|
|
373
|
+
})();
|
|
354
374
|
this.addRule(this, name + "_rule", {
|
|
355
375
|
pattern: {
|
|
356
376
|
detailType: [type],
|
|
@@ -374,7 +394,8 @@ export class EventBus extends Construct {
|
|
|
374
394
|
target = target;
|
|
375
395
|
targetProps = target.cdk?.target;
|
|
376
396
|
functionDefinition = target.function;
|
|
377
|
-
|
|
397
|
+
if (target.retries)
|
|
398
|
+
retries = target.retries;
|
|
378
399
|
}
|
|
379
400
|
else {
|
|
380
401
|
target = target;
|
|
@@ -385,15 +406,6 @@ export class EventBus extends Construct {
|
|
|
385
406
|
this.targetsData[ruleKey][targetName] = fn;
|
|
386
407
|
// Create target
|
|
387
408
|
eventsRule.addTarget(new LambdaFunctionTarget(fn, targetProps));
|
|
388
|
-
// Configure retrier
|
|
389
|
-
if (retries) {
|
|
390
|
-
const retrier = this.getRetrier();
|
|
391
|
-
retrier.fn.addEnvironment(`RETRIER_${retrier.fn.functionName}`, retries.toString());
|
|
392
|
-
fn.grantInvoke(retrier.fn);
|
|
393
|
-
fn.configureAsyncInvoke({
|
|
394
|
-
onFailure: new SqsDestination(retrier.queue),
|
|
395
|
-
});
|
|
396
|
-
}
|
|
397
409
|
// Attach existing permissions
|
|
398
410
|
this.permissionsAttachedForAllTargets.forEach((permissions) => fn.attachPermissions(permissions));
|
|
399
411
|
fn.bind(this.bindingForAllTargets);
|
package/package.json
CHANGED
package/sst.mjs
CHANGED
|
@@ -7501,8 +7501,10 @@ var build = (program2) => program2.command(
|
|
|
7501
7501
|
const { Stacks } = await Promise.resolve().then(() => (init_stacks(), stacks_exports));
|
|
7502
7502
|
const { Colors: Colors2 } = await Promise.resolve().then(() => (init_colors(), colors_exports));
|
|
7503
7503
|
const path20 = await import("path");
|
|
7504
|
+
const project = useProject2();
|
|
7505
|
+
const [_metafile, sstConfig] = await Stacks.load(project.paths.config);
|
|
7504
7506
|
const result = await Stacks.synth({
|
|
7505
|
-
fn:
|
|
7507
|
+
fn: sstConfig.stacks,
|
|
7506
7508
|
buildDir: args.to,
|
|
7507
7509
|
mode: "deploy"
|
|
7508
7510
|
});
|