sst 2.0.30 → 2.0.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/bootstrap.js +3 -1
- package/constructs/EventBus.d.ts +16 -4
- package/constructs/EventBus.js +29 -5
- package/package.json +1 -1
- package/sst.mjs +1 -1
package/bootstrap.js
CHANGED
|
@@ -105,7 +105,9 @@ export async function bootstrapSST(tags) {
|
|
|
105
105
|
const fn = new Function(stack, "MetadataHandler", {
|
|
106
106
|
code: Code.fromAsset(path.resolve(__dirname, "support/bootstrap-metadata-function")),
|
|
107
107
|
handler: "index.handler",
|
|
108
|
-
runtime:
|
|
108
|
+
runtime: app.region?.startsWith("us-gov-")
|
|
109
|
+
? Runtime.NODEJS_16_X
|
|
110
|
+
: Runtime.NODEJS_18_X,
|
|
109
111
|
environment: {
|
|
110
112
|
BUCKET_NAME: bucket.bucketName,
|
|
111
113
|
},
|
package/constructs/EventBus.d.ts
CHANGED
|
@@ -152,7 +152,7 @@ export interface EventBusRuleProps {
|
|
|
152
152
|
* },
|
|
153
153
|
* },
|
|
154
154
|
* targets: {
|
|
155
|
-
* myTarget1: "
|
|
155
|
+
* myTarget1: "src/lambda.handler",
|
|
156
156
|
* },
|
|
157
157
|
* },
|
|
158
158
|
* },
|
|
@@ -262,6 +262,15 @@ export declare class EventBus extends Construct implements SSTConstruct {
|
|
|
262
262
|
* The name of the internally created `EventBus` instance.
|
|
263
263
|
*/
|
|
264
264
|
get eventBusName(): string;
|
|
265
|
+
/**
|
|
266
|
+
* Get a rule
|
|
267
|
+
*
|
|
268
|
+
* @example
|
|
269
|
+
* ```js
|
|
270
|
+
* bus.getRule("myRule");
|
|
271
|
+
* ```
|
|
272
|
+
*/
|
|
273
|
+
getRule(key: string): events.Rule | undefined;
|
|
265
274
|
/**
|
|
266
275
|
* Add rules after the EventBus has been created.
|
|
267
276
|
*
|
|
@@ -280,14 +289,17 @@ export declare class EventBus extends Construct implements SSTConstruct {
|
|
|
280
289
|
*/
|
|
281
290
|
addRules(scope: Construct, rules: Record<string, EventBusRuleProps>): void;
|
|
282
291
|
/**
|
|
283
|
-
*
|
|
292
|
+
* Add targets to existing rules.
|
|
284
293
|
*
|
|
285
294
|
* @example
|
|
286
295
|
* ```js
|
|
287
|
-
* bus.
|
|
296
|
+
* bus.addRules(stack, "myRule", {
|
|
297
|
+
* myTarget1: "src/function1.handler"
|
|
298
|
+
* myTarget2: "src/function2.handler"
|
|
299
|
+
* });
|
|
288
300
|
* ```
|
|
289
301
|
*/
|
|
290
|
-
|
|
302
|
+
addTargets(scope: Construct, ruleKey: string, targets: Record<string, FunctionInlineDefinition | EventBusFunctionTargetProps | Queue | EventBusQueueTargetProps>): void;
|
|
291
303
|
/**
|
|
292
304
|
* Binds the given list of resources to all event targets in this EventBus.
|
|
293
305
|
*
|
package/constructs/EventBus.js
CHANGED
|
@@ -56,6 +56,17 @@ export class EventBus extends Construct {
|
|
|
56
56
|
get eventBusName() {
|
|
57
57
|
return this.cdk.eventBus.eventBusName;
|
|
58
58
|
}
|
|
59
|
+
/**
|
|
60
|
+
* Get a rule
|
|
61
|
+
*
|
|
62
|
+
* @example
|
|
63
|
+
* ```js
|
|
64
|
+
* bus.getRule("myRule");
|
|
65
|
+
* ```
|
|
66
|
+
*/
|
|
67
|
+
getRule(key) {
|
|
68
|
+
return this.rulesData[key];
|
|
69
|
+
}
|
|
59
70
|
/**
|
|
60
71
|
* Add rules after the EventBus has been created.
|
|
61
72
|
*
|
|
@@ -76,15 +87,24 @@ export class EventBus extends Construct {
|
|
|
76
87
|
Object.entries(rules).forEach(([ruleKey, rule]) => this.addRule(scope, ruleKey, rule));
|
|
77
88
|
}
|
|
78
89
|
/**
|
|
79
|
-
*
|
|
90
|
+
* Add targets to existing rules.
|
|
80
91
|
*
|
|
81
92
|
* @example
|
|
82
93
|
* ```js
|
|
83
|
-
* bus.
|
|
94
|
+
* bus.addRules(stack, "myRule", {
|
|
95
|
+
* myTarget1: "src/function1.handler"
|
|
96
|
+
* myTarget2: "src/function2.handler"
|
|
97
|
+
* });
|
|
84
98
|
* ```
|
|
85
99
|
*/
|
|
86
|
-
|
|
87
|
-
|
|
100
|
+
addTargets(scope, ruleKey, targets) {
|
|
101
|
+
// Get rule
|
|
102
|
+
const eventsRule = this.getRule(ruleKey);
|
|
103
|
+
if (!eventsRule) {
|
|
104
|
+
throw new Error(`Cannot find the rule "${ruleKey}" in the "${this.node.id}" EventBus.`);
|
|
105
|
+
}
|
|
106
|
+
// Add targets
|
|
107
|
+
Object.entries(targets).forEach(([targetName, target]) => this.addTarget(scope, ruleKey, eventsRule, targetName, target));
|
|
88
108
|
}
|
|
89
109
|
/**
|
|
90
110
|
* Binds the given list of resources to all event targets in this EventBus.
|
|
@@ -246,10 +266,14 @@ export class EventBus extends Construct {
|
|
|
246
266
|
});
|
|
247
267
|
this.rulesData[ruleKey] = eventsRule;
|
|
248
268
|
// Create Targets
|
|
249
|
-
|
|
269
|
+
this.addTargets(scope, ruleKey, rule.targets || {});
|
|
250
270
|
}
|
|
251
271
|
addTarget(scope, ruleKey, eventsRule, targetName, target) {
|
|
252
272
|
this.targetsData[ruleKey] = this.targetsData[ruleKey] || {};
|
|
273
|
+
// Validate rule not redefined
|
|
274
|
+
if (this.targetsData[ruleKey][targetName]) {
|
|
275
|
+
throw new Error(`A target with name "${targetName}" already exists in rule "${ruleKey}"`);
|
|
276
|
+
}
|
|
253
277
|
if (target instanceof Queue || target.queue) {
|
|
254
278
|
target = target;
|
|
255
279
|
this.addQueueTarget(scope, ruleKey, eventsRule, targetName, target);
|
package/package.json
CHANGED
package/sst.mjs
CHANGED
|
@@ -2710,7 +2710,7 @@ async function bootstrapSST(tags) {
|
|
|
2710
2710
|
path8.resolve(__dirname, "support/bootstrap-metadata-function")
|
|
2711
2711
|
),
|
|
2712
2712
|
handler: "index.handler",
|
|
2713
|
-
runtime: Runtime.NODEJS_18_X,
|
|
2713
|
+
runtime: app.region?.startsWith("us-gov-") ? Runtime.NODEJS_16_X : Runtime.NODEJS_18_X,
|
|
2714
2714
|
environment: {
|
|
2715
2715
|
BUCKET_NAME: bucket.bucketName
|
|
2716
2716
|
},
|