@awsless/awsless 0.0.17 → 0.0.19
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/bin.cjs +117 -42
- package/dist/bin.js +117 -42
- package/dist/index.cjs +5 -0
- package/dist/index.d.ts +609 -315
- package/dist/index.js +4 -0
- package/package.json +1 -4
package/dist/bin.cjs
CHANGED
|
@@ -371,6 +371,7 @@ var Function = class extends Resource {
|
|
|
371
371
|
Timeout: this.props.timeout?.toSeconds() ?? 10,
|
|
372
372
|
Architectures: [this.props.architecture ?? "arm64"],
|
|
373
373
|
Role: this.role.arn,
|
|
374
|
+
...this.attr("ReservedConcurrentExecutions", this.props.reserved),
|
|
374
375
|
...this.props.code.toCodeJson(),
|
|
375
376
|
EphemeralStorage: {
|
|
376
377
|
Size: this.props.ephemeralStorageSize?.toMegaBytes() ?? 512
|
|
@@ -947,6 +948,7 @@ var hasOnFailure = (config) => {
|
|
|
947
948
|
var MemorySizeSchema = SizeSchema.refine(sizeMin(Size.megaBytes(128)), "Minimum memory size is 128 MB").refine(sizeMax(Size.gigaBytes(10)), "Minimum memory size is 10 GB");
|
|
948
949
|
var TimeoutSchema = DurationSchema.refine(durationMin(Duration.seconds(10)), "Minimum timeout duration is 10 seconds").refine(durationMax(Duration.minutes(15)), "Maximum timeout duration is 15 minutes");
|
|
949
950
|
var EphemeralStorageSizeSchema = SizeSchema.refine(sizeMin(Size.megaBytes(512)), "Minimum ephemeral storage size is 512 MB").refine(sizeMax(Size.gigaBytes(10)), "Minimum ephemeral storage size is 10 GB");
|
|
951
|
+
var ReservedConcurrentExecutionsSchema = import_zod6.z.number().int().min(0);
|
|
950
952
|
var EnvironmentSchema = import_zod6.z.record(import_zod6.z.string(), import_zod6.z.string()).optional();
|
|
951
953
|
var ArchitectureSchema = import_zod6.z.enum(["x86_64", "arm64"]);
|
|
952
954
|
var RetryAttemptsSchema = import_zod6.z.number().int().min(0).max(2);
|
|
@@ -989,6 +991,10 @@ var FunctionSchema = import_zod6.z.union([
|
|
|
989
991
|
* @default 2
|
|
990
992
|
*/
|
|
991
993
|
retryAttempts: RetryAttemptsSchema.optional(),
|
|
994
|
+
/** The number of simultaneous executions to reserve for the function.
|
|
995
|
+
* You can specify a number from 0.
|
|
996
|
+
*/
|
|
997
|
+
reserved: ReservedConcurrentExecutionsSchema.optional(),
|
|
992
998
|
/** Environment variable key-value pairs.
|
|
993
999
|
* @example
|
|
994
1000
|
* {
|
|
@@ -1034,6 +1040,10 @@ var schema = import_zod6.z.object({
|
|
|
1034
1040
|
* @default 2
|
|
1035
1041
|
*/
|
|
1036
1042
|
retryAttempts: RetryAttemptsSchema.default(2),
|
|
1043
|
+
/** The number of simultaneous executions to reserve for the function.
|
|
1044
|
+
* You can specify a number from 0.
|
|
1045
|
+
*/
|
|
1046
|
+
reserved: ReservedConcurrentExecutionsSchema.optional(),
|
|
1037
1047
|
/** Environment variable key-value pairs.
|
|
1038
1048
|
* @example
|
|
1039
1049
|
* {
|
|
@@ -1074,6 +1084,12 @@ var functionPlugin = definePlugin({
|
|
|
1074
1084
|
retryAttempts: props.retryAttempts,
|
|
1075
1085
|
onFailure: getGlobalOnFailure(ctx)
|
|
1076
1086
|
}).dependsOn(lambda);
|
|
1087
|
+
if (hasOnFailure(ctx.config)) {
|
|
1088
|
+
lambda.addPermissions({
|
|
1089
|
+
actions: ["sqs:SendMessage"],
|
|
1090
|
+
resources: [getGlobalOnFailure(ctx)]
|
|
1091
|
+
});
|
|
1092
|
+
}
|
|
1077
1093
|
stack.add(invoke, lambda);
|
|
1078
1094
|
}
|
|
1079
1095
|
}
|
|
@@ -1168,7 +1184,7 @@ var cronPlugin = definePlugin({
|
|
|
1168
1184
|
name: "cron",
|
|
1169
1185
|
schema: import_zod7.z.object({
|
|
1170
1186
|
stacks: import_zod7.z.object({
|
|
1171
|
-
/** Define the crons in your stack
|
|
1187
|
+
/** Define the crons in your stack.
|
|
1172
1188
|
* @example
|
|
1173
1189
|
* {
|
|
1174
1190
|
* crons: {
|
|
@@ -1180,7 +1196,7 @@ var cronPlugin = definePlugin({
|
|
|
1180
1196
|
* }
|
|
1181
1197
|
* */
|
|
1182
1198
|
crons: import_zod7.z.record(ResourceIdSchema, import_zod7.z.object({
|
|
1183
|
-
/** The consuming lambda function properties */
|
|
1199
|
+
/** The consuming lambda function properties. */
|
|
1184
1200
|
consumer: FunctionSchema,
|
|
1185
1201
|
/** The scheduling expression.
|
|
1186
1202
|
* @example 'cron(0 20 * * ? *)'
|
|
@@ -1247,7 +1263,8 @@ var Queue = class extends Resource {
|
|
|
1247
1263
|
VisibilityTimeout: this.props.visibilityTimeout?.toSeconds() ?? 30,
|
|
1248
1264
|
...this.props.deadLetterArn ? {
|
|
1249
1265
|
RedrivePolicy: {
|
|
1250
|
-
deadLetterTargetArn: this.props.deadLetterArn
|
|
1266
|
+
deadLetterTargetArn: this.props.deadLetterArn,
|
|
1267
|
+
maxReceiveCount: this.props.maxReceiveCount ?? 100
|
|
1251
1268
|
}
|
|
1252
1269
|
} : {}
|
|
1253
1270
|
};
|
|
@@ -1303,8 +1320,7 @@ var SqsEventSource = class extends Group {
|
|
|
1303
1320
|
sourceArn: props.queueArn,
|
|
1304
1321
|
batchSize: props.batchSize ?? 10,
|
|
1305
1322
|
maxBatchingWindow: props.maxBatchingWindow,
|
|
1306
|
-
maxConcurrency: props.maxConcurrency
|
|
1307
|
-
onFailure: props.onFailure
|
|
1323
|
+
maxConcurrency: props.maxConcurrency
|
|
1308
1324
|
});
|
|
1309
1325
|
lambda.addPermissions({
|
|
1310
1326
|
actions: [
|
|
@@ -1319,6 +1335,14 @@ var SqsEventSource = class extends Group {
|
|
|
1319
1335
|
};
|
|
1320
1336
|
|
|
1321
1337
|
// src/plugins/queue.ts
|
|
1338
|
+
var RetentionPeriodSchema = DurationSchema.refine(durationMin(Duration.minutes(1)), "Minimum retention period is 1 minute").refine(durationMax(Duration.days(14)), "Maximum retention period is 14 days");
|
|
1339
|
+
var VisibilityTimeoutSchema = DurationSchema.refine(durationMax(Duration.hours(12)), "Maximum visibility timeout is 12 hours");
|
|
1340
|
+
var DeliveryDelaySchema = DurationSchema.refine(durationMax(Duration.minutes(15)), "Maximum delivery delay is 15 minutes");
|
|
1341
|
+
var ReceiveMessageWaitTimeSchema = DurationSchema.refine(durationMin(Duration.seconds(1)), "Minimum receive message wait time is 1 second").refine(durationMax(Duration.seconds(20)), "Maximum receive message wait time is 20 seconds");
|
|
1342
|
+
var MaxMessageSizeSchema = SizeSchema.refine(sizeMin(Size.kiloBytes(1)), "Minimum max message size is 1 KB").refine(sizeMax(Size.kiloBytes(256)), "Maximum max message size is 256 KB");
|
|
1343
|
+
var BatchSizeSchema = import_zod8.z.number().int().min(1, "Minimum batch size is 1").max(1e4, "Maximum batch size is 10000");
|
|
1344
|
+
var MaxConcurrencySchema = import_zod8.z.number().int().min(2, "Minimum max concurrency is 2").max(1e3, "Maximum max concurrency is 1000");
|
|
1345
|
+
var MaxBatchingWindow = DurationSchema.refine(durationMax(Duration.minutes(5)), "Maximum max batching window is 5 minutes");
|
|
1322
1346
|
var queuePlugin = definePlugin({
|
|
1323
1347
|
name: "queue",
|
|
1324
1348
|
schema: import_zod8.z.object({
|
|
@@ -1326,29 +1350,40 @@ var queuePlugin = definePlugin({
|
|
|
1326
1350
|
/** Define the defaults properties for all queue's in your app. */
|
|
1327
1351
|
queue: import_zod8.z.object({
|
|
1328
1352
|
/** The number of seconds that Amazon SQS retains a message.
|
|
1329
|
-
* You can specify a duration
|
|
1353
|
+
* You can specify a duration from 1 minute to 14 days.
|
|
1330
1354
|
* @default '7 days' */
|
|
1331
|
-
retentionPeriod:
|
|
1355
|
+
retentionPeriod: RetentionPeriodSchema.default("7 days"),
|
|
1332
1356
|
/** The length of time during which a message will be unavailable after a message is delivered from the queue.
|
|
1333
1357
|
* This blocks other components from receiving the same message and gives the initial component time to process and delete the message from the queue.
|
|
1334
|
-
* You can specify a duration
|
|
1358
|
+
* You can specify a duration from 0 to 12 hours.
|
|
1335
1359
|
* @default '30 seconds' */
|
|
1336
|
-
visibilityTimeout:
|
|
1360
|
+
visibilityTimeout: VisibilityTimeoutSchema.default("30 seconds"),
|
|
1337
1361
|
/** The time in seconds for which the delivery of all messages in the queue is delayed.
|
|
1338
|
-
* You can specify a duration
|
|
1362
|
+
* You can specify a duration from 0 to 15 minutes.
|
|
1339
1363
|
* @default '0 seconds' */
|
|
1340
|
-
deliveryDelay:
|
|
1364
|
+
deliveryDelay: DeliveryDelaySchema.default("0 seconds"),
|
|
1341
1365
|
/** Specifies the duration, in seconds,
|
|
1342
1366
|
* that the ReceiveMessage action call waits until a message is in the queue in order to include it in the response,
|
|
1343
1367
|
* rather than returning an empty response if a message isn't yet available.
|
|
1344
|
-
* You can specify
|
|
1345
|
-
*
|
|
1346
|
-
|
|
1347
|
-
receiveMessageWaitTime: DurationSchema.default("0 seconds"),
|
|
1368
|
+
* You can specify a duration from 1 to 20 seconds.
|
|
1369
|
+
* Short polling is used as the default. */
|
|
1370
|
+
receiveMessageWaitTime: ReceiveMessageWaitTimeSchema.optional(),
|
|
1348
1371
|
/** The limit of how many bytes that a message can contain before Amazon SQS rejects it.
|
|
1349
|
-
* You can specify an size
|
|
1372
|
+
* You can specify an size from 1 KB to 256 KB.
|
|
1350
1373
|
* @default '256 KB' */
|
|
1351
|
-
maxMessageSize:
|
|
1374
|
+
maxMessageSize: MaxMessageSizeSchema.default("256 KB"),
|
|
1375
|
+
/** The maximum number of records in each batch that Lambda pulls from your queue and sends to your function.
|
|
1376
|
+
* Lambda passes all of the records in the batch to the function in a single call, up to the payload limit for synchronous invocation (6 MB).
|
|
1377
|
+
* You can specify an integer from 1 to 10000.
|
|
1378
|
+
* @default 10 */
|
|
1379
|
+
batchSize: BatchSizeSchema.default(10),
|
|
1380
|
+
/** Limits the number of concurrent instances that the queue worker can invoke.
|
|
1381
|
+
* You can specify an integer from 2 to 1000. */
|
|
1382
|
+
maxConcurrency: MaxConcurrencySchema.optional(),
|
|
1383
|
+
/** The maximum amount of time, that Lambda spends gathering records before invoking the function.
|
|
1384
|
+
* You can specify an duration from 0 seconds to 5 minutes.
|
|
1385
|
+
* @default '0 seconds' */
|
|
1386
|
+
maxBatchingWindow: MaxBatchingWindow.optional()
|
|
1352
1387
|
}).default({})
|
|
1353
1388
|
}).default({}),
|
|
1354
1389
|
stacks: import_zod8.z.object({
|
|
@@ -1370,26 +1405,38 @@ var queuePlugin = definePlugin({
|
|
|
1370
1405
|
/** The number of seconds that Amazon SQS retains a message.
|
|
1371
1406
|
* You can specify a duration value from 1 minute to 14 days.
|
|
1372
1407
|
* @default '7 days' */
|
|
1373
|
-
retentionPeriod:
|
|
1408
|
+
retentionPeriod: RetentionPeriodSchema.optional(),
|
|
1374
1409
|
/** The length of time during which a message will be unavailable after a message is delivered from the queue.
|
|
1375
1410
|
* This blocks other components from receiving the same message and gives the initial component time to process and delete the message from the queue.
|
|
1376
1411
|
* You can specify a duration value from 0 to 12 hours.
|
|
1377
1412
|
* @default '30 seconds' */
|
|
1378
|
-
visibilityTimeout:
|
|
1413
|
+
visibilityTimeout: VisibilityTimeoutSchema.optional(),
|
|
1379
1414
|
/** The time in seconds for which the delivery of all messages in the queue is delayed.
|
|
1380
1415
|
* You can specify a duration value from 0 to 15 minutes.
|
|
1381
1416
|
* @default '0 seconds' */
|
|
1382
|
-
deliveryDelay:
|
|
1417
|
+
deliveryDelay: DeliveryDelaySchema.optional(),
|
|
1383
1418
|
/** Specifies the duration, in seconds,
|
|
1384
1419
|
* that the ReceiveMessage action call waits until a message is in the queue in order to include it in the response,
|
|
1385
1420
|
* rather than returning an empty response if a message isn't yet available.
|
|
1386
1421
|
* You can specify a duration value from 1 to 20 seconds.
|
|
1387
|
-
*
|
|
1388
|
-
receiveMessageWaitTime:
|
|
1422
|
+
* Short polling is used as the default. */
|
|
1423
|
+
receiveMessageWaitTime: ReceiveMessageWaitTimeSchema.optional(),
|
|
1389
1424
|
/** The limit of how many bytes that a message can contain before Amazon SQS rejects it.
|
|
1390
1425
|
* You can specify an size value from 1 KB to 256 KB.
|
|
1391
1426
|
* @default '256 KB' */
|
|
1392
|
-
maxMessageSize:
|
|
1427
|
+
maxMessageSize: MaxMessageSizeSchema.optional(),
|
|
1428
|
+
/** The maximum number of records in each batch that Lambda pulls from your queue and sends to your function.
|
|
1429
|
+
* Lambda passes all of the records in the batch to the function in a single call, up to the payload limit for synchronous invocation (6 MB).
|
|
1430
|
+
* You can specify an integer from 1 to 10000.
|
|
1431
|
+
* @default 10 */
|
|
1432
|
+
batchSize: BatchSizeSchema.optional(),
|
|
1433
|
+
/** Limits the number of concurrent instances that the queue worker can invoke.
|
|
1434
|
+
* You can specify an integer from 2 to 1000. */
|
|
1435
|
+
maxConcurrency: MaxConcurrencySchema.optional(),
|
|
1436
|
+
/** The maximum amount of time, that Lambda spends gathering records before invoking the function.
|
|
1437
|
+
* You can specify an duration from 0 seconds to 5 minutes.
|
|
1438
|
+
* @default '0 seconds' */
|
|
1439
|
+
maxBatchingWindow: MaxBatchingWindow.optional()
|
|
1393
1440
|
})
|
|
1394
1441
|
])
|
|
1395
1442
|
).optional()
|
|
@@ -1401,12 +1448,15 @@ var queuePlugin = definePlugin({
|
|
|
1401
1448
|
const props = typeof functionOrProps === "string" ? { ...config.defaults.queue, consumer: functionOrProps } : { ...config.defaults.queue, ...functionOrProps };
|
|
1402
1449
|
const queue2 = new Queue(id, {
|
|
1403
1450
|
name: `${config.name}-${stack.name}-${id}`,
|
|
1451
|
+
deadLetterArn: getGlobalOnFailure(ctx),
|
|
1404
1452
|
...props
|
|
1405
1453
|
});
|
|
1406
1454
|
const lambda = toLambdaFunction(ctx, `queue-${id}`, props.consumer);
|
|
1407
1455
|
const source = new SqsEventSource(id, lambda, {
|
|
1408
1456
|
queueArn: queue2.arn,
|
|
1409
|
-
|
|
1457
|
+
batchSize: props.batchSize,
|
|
1458
|
+
maxConcurrency: props.maxConcurrency,
|
|
1459
|
+
maxBatchingWindow: props.maxBatchingWindow
|
|
1410
1460
|
});
|
|
1411
1461
|
stack.add(queue2, lambda, source);
|
|
1412
1462
|
bind((lambda2) => {
|
|
@@ -1462,6 +1512,26 @@ var Table = class extends Resource {
|
|
|
1462
1512
|
resources: [this.arn]
|
|
1463
1513
|
};
|
|
1464
1514
|
}
|
|
1515
|
+
attributeDefinitions() {
|
|
1516
|
+
const fields = this.props.fields || {};
|
|
1517
|
+
const attributes = new Set([
|
|
1518
|
+
this.props.hash,
|
|
1519
|
+
this.props.sort,
|
|
1520
|
+
...Object.values(this.props.indexes || {}).map((index) => [
|
|
1521
|
+
index.hash,
|
|
1522
|
+
index.sort
|
|
1523
|
+
])
|
|
1524
|
+
].flat().filter(Boolean));
|
|
1525
|
+
const types = {
|
|
1526
|
+
string: "S",
|
|
1527
|
+
number: "N",
|
|
1528
|
+
binary: "B"
|
|
1529
|
+
};
|
|
1530
|
+
return [...attributes].map((name) => ({
|
|
1531
|
+
AttributeName: name,
|
|
1532
|
+
AttributeType: types[fields[name] || "string"]
|
|
1533
|
+
}));
|
|
1534
|
+
}
|
|
1465
1535
|
properties() {
|
|
1466
1536
|
return {
|
|
1467
1537
|
TableName: this.name,
|
|
@@ -1474,10 +1544,7 @@ var Table = class extends Resource {
|
|
|
1474
1544
|
{ KeyType: "HASH", AttributeName: this.props.hash },
|
|
1475
1545
|
...this.props.sort ? [{ KeyType: "RANGE", AttributeName: this.props.sort }] : []
|
|
1476
1546
|
],
|
|
1477
|
-
AttributeDefinitions:
|
|
1478
|
-
AttributeName: name,
|
|
1479
|
-
AttributeType: type[0].toUpperCase()
|
|
1480
|
-
})),
|
|
1547
|
+
AttributeDefinitions: this.attributeDefinitions(),
|
|
1481
1548
|
...this.props.stream ? {
|
|
1482
1549
|
StreamSpecification: {
|
|
1483
1550
|
StreamViewType: (0, import_change_case4.constantCase)(this.props.stream)
|
|
@@ -1562,6 +1629,7 @@ var tablePlugin = definePlugin({
|
|
|
1562
1629
|
/** Specifies the name of the range / sort key that makes up the primary key for the table. */
|
|
1563
1630
|
sort: KeySchema.optional(),
|
|
1564
1631
|
/** A list of attributes that describe the key schema for the table and indexes.
|
|
1632
|
+
* If no attribute field is defined we default to 'string'.
|
|
1565
1633
|
* @example
|
|
1566
1634
|
* {
|
|
1567
1635
|
* fields: {
|
|
@@ -1569,7 +1637,10 @@ var tablePlugin = definePlugin({
|
|
|
1569
1637
|
* }
|
|
1570
1638
|
* }
|
|
1571
1639
|
*/
|
|
1572
|
-
fields: import_zod9.z.record(
|
|
1640
|
+
fields: import_zod9.z.record(
|
|
1641
|
+
import_zod9.z.string(),
|
|
1642
|
+
import_zod9.z.enum(["string", "number", "binary"])
|
|
1643
|
+
).optional(),
|
|
1573
1644
|
/** The table class of the table.
|
|
1574
1645
|
* @default 'standard'
|
|
1575
1646
|
*/
|
|
@@ -1618,18 +1689,22 @@ var tablePlugin = definePlugin({
|
|
|
1618
1689
|
*/
|
|
1619
1690
|
projection: import_zod9.z.enum(["all", "keys-only"]).default("all")
|
|
1620
1691
|
})).optional()
|
|
1621
|
-
})
|
|
1622
|
-
|
|
1623
|
-
|
|
1624
|
-
|
|
1625
|
-
|
|
1626
|
-
|
|
1627
|
-
|
|
1628
|
-
|
|
1629
|
-
|
|
1630
|
-
|
|
1631
|
-
|
|
1632
|
-
|
|
1692
|
+
})
|
|
1693
|
+
// .refine(props => {
|
|
1694
|
+
// return (
|
|
1695
|
+
// // Check the hash key
|
|
1696
|
+
// props.fields.hasOwnProperty(props.hash) &&
|
|
1697
|
+
// // Check the sort key
|
|
1698
|
+
// (!props.sort || props.fields.hasOwnProperty(props.sort)) &&
|
|
1699
|
+
// // Check all indexes
|
|
1700
|
+
// !Object.values(props.indexes || {}).map(index => (
|
|
1701
|
+
// // Check the index hash key
|
|
1702
|
+
// props.fields.hasOwnProperty(index.hash) &&
|
|
1703
|
+
// // Check the index sort key
|
|
1704
|
+
// (!index.sort || props.fields.hasOwnProperty(index.sort))
|
|
1705
|
+
// )).includes(false)
|
|
1706
|
+
// )
|
|
1707
|
+
// }, 'Hash & Sort keys must be defined inside the table fields')
|
|
1633
1708
|
).optional()
|
|
1634
1709
|
}).array()
|
|
1635
1710
|
}),
|
|
@@ -2630,7 +2705,7 @@ var domainPlugin = definePlugin({
|
|
|
2630
2705
|
name: DomainNameSchema.optional(),
|
|
2631
2706
|
/** The DNS record type. */
|
|
2632
2707
|
type: import_zod15.z.enum(["A", "AAAA", "CAA", "CNAME", "DS", "MX", "NAPTR", "NS", "PTR", "SOA", "SPF", "SRV", "TXT"]),
|
|
2633
|
-
/** The resource record cache time to live (TTL) */
|
|
2708
|
+
/** The resource record cache time to live (TTL). */
|
|
2634
2709
|
ttl: DurationSchema,
|
|
2635
2710
|
/** One or more values that correspond with the value that you specified for the Type property. */
|
|
2636
2711
|
records: import_zod15.z.string().array()
|
package/dist/bin.js
CHANGED
|
@@ -351,6 +351,7 @@ var Function = class extends Resource {
|
|
|
351
351
|
Timeout: this.props.timeout?.toSeconds() ?? 10,
|
|
352
352
|
Architectures: [this.props.architecture ?? "arm64"],
|
|
353
353
|
Role: this.role.arn,
|
|
354
|
+
...this.attr("ReservedConcurrentExecutions", this.props.reserved),
|
|
354
355
|
...this.props.code.toCodeJson(),
|
|
355
356
|
EphemeralStorage: {
|
|
356
357
|
Size: this.props.ephemeralStorageSize?.toMegaBytes() ?? 512
|
|
@@ -924,6 +925,7 @@ var hasOnFailure = (config) => {
|
|
|
924
925
|
var MemorySizeSchema = SizeSchema.refine(sizeMin(Size.megaBytes(128)), "Minimum memory size is 128 MB").refine(sizeMax(Size.gigaBytes(10)), "Minimum memory size is 10 GB");
|
|
925
926
|
var TimeoutSchema = DurationSchema.refine(durationMin(Duration.seconds(10)), "Minimum timeout duration is 10 seconds").refine(durationMax(Duration.minutes(15)), "Maximum timeout duration is 15 minutes");
|
|
926
927
|
var EphemeralStorageSizeSchema = SizeSchema.refine(sizeMin(Size.megaBytes(512)), "Minimum ephemeral storage size is 512 MB").refine(sizeMax(Size.gigaBytes(10)), "Minimum ephemeral storage size is 10 GB");
|
|
928
|
+
var ReservedConcurrentExecutionsSchema = z6.number().int().min(0);
|
|
927
929
|
var EnvironmentSchema = z6.record(z6.string(), z6.string()).optional();
|
|
928
930
|
var ArchitectureSchema = z6.enum(["x86_64", "arm64"]);
|
|
929
931
|
var RetryAttemptsSchema = z6.number().int().min(0).max(2);
|
|
@@ -966,6 +968,10 @@ var FunctionSchema = z6.union([
|
|
|
966
968
|
* @default 2
|
|
967
969
|
*/
|
|
968
970
|
retryAttempts: RetryAttemptsSchema.optional(),
|
|
971
|
+
/** The number of simultaneous executions to reserve for the function.
|
|
972
|
+
* You can specify a number from 0.
|
|
973
|
+
*/
|
|
974
|
+
reserved: ReservedConcurrentExecutionsSchema.optional(),
|
|
969
975
|
/** Environment variable key-value pairs.
|
|
970
976
|
* @example
|
|
971
977
|
* {
|
|
@@ -1011,6 +1017,10 @@ var schema = z6.object({
|
|
|
1011
1017
|
* @default 2
|
|
1012
1018
|
*/
|
|
1013
1019
|
retryAttempts: RetryAttemptsSchema.default(2),
|
|
1020
|
+
/** The number of simultaneous executions to reserve for the function.
|
|
1021
|
+
* You can specify a number from 0.
|
|
1022
|
+
*/
|
|
1023
|
+
reserved: ReservedConcurrentExecutionsSchema.optional(),
|
|
1014
1024
|
/** Environment variable key-value pairs.
|
|
1015
1025
|
* @example
|
|
1016
1026
|
* {
|
|
@@ -1051,6 +1061,12 @@ var functionPlugin = definePlugin({
|
|
|
1051
1061
|
retryAttempts: props.retryAttempts,
|
|
1052
1062
|
onFailure: getGlobalOnFailure(ctx)
|
|
1053
1063
|
}).dependsOn(lambda);
|
|
1064
|
+
if (hasOnFailure(ctx.config)) {
|
|
1065
|
+
lambda.addPermissions({
|
|
1066
|
+
actions: ["sqs:SendMessage"],
|
|
1067
|
+
resources: [getGlobalOnFailure(ctx)]
|
|
1068
|
+
});
|
|
1069
|
+
}
|
|
1054
1070
|
stack.add(invoke, lambda);
|
|
1055
1071
|
}
|
|
1056
1072
|
}
|
|
@@ -1145,7 +1161,7 @@ var cronPlugin = definePlugin({
|
|
|
1145
1161
|
name: "cron",
|
|
1146
1162
|
schema: z7.object({
|
|
1147
1163
|
stacks: z7.object({
|
|
1148
|
-
/** Define the crons in your stack
|
|
1164
|
+
/** Define the crons in your stack.
|
|
1149
1165
|
* @example
|
|
1150
1166
|
* {
|
|
1151
1167
|
* crons: {
|
|
@@ -1157,7 +1173,7 @@ var cronPlugin = definePlugin({
|
|
|
1157
1173
|
* }
|
|
1158
1174
|
* */
|
|
1159
1175
|
crons: z7.record(ResourceIdSchema, z7.object({
|
|
1160
|
-
/** The consuming lambda function properties */
|
|
1176
|
+
/** The consuming lambda function properties. */
|
|
1161
1177
|
consumer: FunctionSchema,
|
|
1162
1178
|
/** The scheduling expression.
|
|
1163
1179
|
* @example 'cron(0 20 * * ? *)'
|
|
@@ -1224,7 +1240,8 @@ var Queue = class extends Resource {
|
|
|
1224
1240
|
VisibilityTimeout: this.props.visibilityTimeout?.toSeconds() ?? 30,
|
|
1225
1241
|
...this.props.deadLetterArn ? {
|
|
1226
1242
|
RedrivePolicy: {
|
|
1227
|
-
deadLetterTargetArn: this.props.deadLetterArn
|
|
1243
|
+
deadLetterTargetArn: this.props.deadLetterArn,
|
|
1244
|
+
maxReceiveCount: this.props.maxReceiveCount ?? 100
|
|
1228
1245
|
}
|
|
1229
1246
|
} : {}
|
|
1230
1247
|
};
|
|
@@ -1280,8 +1297,7 @@ var SqsEventSource = class extends Group {
|
|
|
1280
1297
|
sourceArn: props.queueArn,
|
|
1281
1298
|
batchSize: props.batchSize ?? 10,
|
|
1282
1299
|
maxBatchingWindow: props.maxBatchingWindow,
|
|
1283
|
-
maxConcurrency: props.maxConcurrency
|
|
1284
|
-
onFailure: props.onFailure
|
|
1300
|
+
maxConcurrency: props.maxConcurrency
|
|
1285
1301
|
});
|
|
1286
1302
|
lambda.addPermissions({
|
|
1287
1303
|
actions: [
|
|
@@ -1296,6 +1312,14 @@ var SqsEventSource = class extends Group {
|
|
|
1296
1312
|
};
|
|
1297
1313
|
|
|
1298
1314
|
// src/plugins/queue.ts
|
|
1315
|
+
var RetentionPeriodSchema = DurationSchema.refine(durationMin(Duration.minutes(1)), "Minimum retention period is 1 minute").refine(durationMax(Duration.days(14)), "Maximum retention period is 14 days");
|
|
1316
|
+
var VisibilityTimeoutSchema = DurationSchema.refine(durationMax(Duration.hours(12)), "Maximum visibility timeout is 12 hours");
|
|
1317
|
+
var DeliveryDelaySchema = DurationSchema.refine(durationMax(Duration.minutes(15)), "Maximum delivery delay is 15 minutes");
|
|
1318
|
+
var ReceiveMessageWaitTimeSchema = DurationSchema.refine(durationMin(Duration.seconds(1)), "Minimum receive message wait time is 1 second").refine(durationMax(Duration.seconds(20)), "Maximum receive message wait time is 20 seconds");
|
|
1319
|
+
var MaxMessageSizeSchema = SizeSchema.refine(sizeMin(Size.kiloBytes(1)), "Minimum max message size is 1 KB").refine(sizeMax(Size.kiloBytes(256)), "Maximum max message size is 256 KB");
|
|
1320
|
+
var BatchSizeSchema = z8.number().int().min(1, "Minimum batch size is 1").max(1e4, "Maximum batch size is 10000");
|
|
1321
|
+
var MaxConcurrencySchema = z8.number().int().min(2, "Minimum max concurrency is 2").max(1e3, "Maximum max concurrency is 1000");
|
|
1322
|
+
var MaxBatchingWindow = DurationSchema.refine(durationMax(Duration.minutes(5)), "Maximum max batching window is 5 minutes");
|
|
1299
1323
|
var queuePlugin = definePlugin({
|
|
1300
1324
|
name: "queue",
|
|
1301
1325
|
schema: z8.object({
|
|
@@ -1303,29 +1327,40 @@ var queuePlugin = definePlugin({
|
|
|
1303
1327
|
/** Define the defaults properties for all queue's in your app. */
|
|
1304
1328
|
queue: z8.object({
|
|
1305
1329
|
/** The number of seconds that Amazon SQS retains a message.
|
|
1306
|
-
* You can specify a duration
|
|
1330
|
+
* You can specify a duration from 1 minute to 14 days.
|
|
1307
1331
|
* @default '7 days' */
|
|
1308
|
-
retentionPeriod:
|
|
1332
|
+
retentionPeriod: RetentionPeriodSchema.default("7 days"),
|
|
1309
1333
|
/** The length of time during which a message will be unavailable after a message is delivered from the queue.
|
|
1310
1334
|
* This blocks other components from receiving the same message and gives the initial component time to process and delete the message from the queue.
|
|
1311
|
-
* You can specify a duration
|
|
1335
|
+
* You can specify a duration from 0 to 12 hours.
|
|
1312
1336
|
* @default '30 seconds' */
|
|
1313
|
-
visibilityTimeout:
|
|
1337
|
+
visibilityTimeout: VisibilityTimeoutSchema.default("30 seconds"),
|
|
1314
1338
|
/** The time in seconds for which the delivery of all messages in the queue is delayed.
|
|
1315
|
-
* You can specify a duration
|
|
1339
|
+
* You can specify a duration from 0 to 15 minutes.
|
|
1316
1340
|
* @default '0 seconds' */
|
|
1317
|
-
deliveryDelay:
|
|
1341
|
+
deliveryDelay: DeliveryDelaySchema.default("0 seconds"),
|
|
1318
1342
|
/** Specifies the duration, in seconds,
|
|
1319
1343
|
* that the ReceiveMessage action call waits until a message is in the queue in order to include it in the response,
|
|
1320
1344
|
* rather than returning an empty response if a message isn't yet available.
|
|
1321
|
-
* You can specify
|
|
1322
|
-
*
|
|
1323
|
-
|
|
1324
|
-
receiveMessageWaitTime: DurationSchema.default("0 seconds"),
|
|
1345
|
+
* You can specify a duration from 1 to 20 seconds.
|
|
1346
|
+
* Short polling is used as the default. */
|
|
1347
|
+
receiveMessageWaitTime: ReceiveMessageWaitTimeSchema.optional(),
|
|
1325
1348
|
/** The limit of how many bytes that a message can contain before Amazon SQS rejects it.
|
|
1326
|
-
* You can specify an size
|
|
1349
|
+
* You can specify an size from 1 KB to 256 KB.
|
|
1327
1350
|
* @default '256 KB' */
|
|
1328
|
-
maxMessageSize:
|
|
1351
|
+
maxMessageSize: MaxMessageSizeSchema.default("256 KB"),
|
|
1352
|
+
/** The maximum number of records in each batch that Lambda pulls from your queue and sends to your function.
|
|
1353
|
+
* Lambda passes all of the records in the batch to the function in a single call, up to the payload limit for synchronous invocation (6 MB).
|
|
1354
|
+
* You can specify an integer from 1 to 10000.
|
|
1355
|
+
* @default 10 */
|
|
1356
|
+
batchSize: BatchSizeSchema.default(10),
|
|
1357
|
+
/** Limits the number of concurrent instances that the queue worker can invoke.
|
|
1358
|
+
* You can specify an integer from 2 to 1000. */
|
|
1359
|
+
maxConcurrency: MaxConcurrencySchema.optional(),
|
|
1360
|
+
/** The maximum amount of time, that Lambda spends gathering records before invoking the function.
|
|
1361
|
+
* You can specify an duration from 0 seconds to 5 minutes.
|
|
1362
|
+
* @default '0 seconds' */
|
|
1363
|
+
maxBatchingWindow: MaxBatchingWindow.optional()
|
|
1329
1364
|
}).default({})
|
|
1330
1365
|
}).default({}),
|
|
1331
1366
|
stacks: z8.object({
|
|
@@ -1347,26 +1382,38 @@ var queuePlugin = definePlugin({
|
|
|
1347
1382
|
/** The number of seconds that Amazon SQS retains a message.
|
|
1348
1383
|
* You can specify a duration value from 1 minute to 14 days.
|
|
1349
1384
|
* @default '7 days' */
|
|
1350
|
-
retentionPeriod:
|
|
1385
|
+
retentionPeriod: RetentionPeriodSchema.optional(),
|
|
1351
1386
|
/** The length of time during which a message will be unavailable after a message is delivered from the queue.
|
|
1352
1387
|
* This blocks other components from receiving the same message and gives the initial component time to process and delete the message from the queue.
|
|
1353
1388
|
* You can specify a duration value from 0 to 12 hours.
|
|
1354
1389
|
* @default '30 seconds' */
|
|
1355
|
-
visibilityTimeout:
|
|
1390
|
+
visibilityTimeout: VisibilityTimeoutSchema.optional(),
|
|
1356
1391
|
/** The time in seconds for which the delivery of all messages in the queue is delayed.
|
|
1357
1392
|
* You can specify a duration value from 0 to 15 minutes.
|
|
1358
1393
|
* @default '0 seconds' */
|
|
1359
|
-
deliveryDelay:
|
|
1394
|
+
deliveryDelay: DeliveryDelaySchema.optional(),
|
|
1360
1395
|
/** Specifies the duration, in seconds,
|
|
1361
1396
|
* that the ReceiveMessage action call waits until a message is in the queue in order to include it in the response,
|
|
1362
1397
|
* rather than returning an empty response if a message isn't yet available.
|
|
1363
1398
|
* You can specify a duration value from 1 to 20 seconds.
|
|
1364
|
-
*
|
|
1365
|
-
receiveMessageWaitTime:
|
|
1399
|
+
* Short polling is used as the default. */
|
|
1400
|
+
receiveMessageWaitTime: ReceiveMessageWaitTimeSchema.optional(),
|
|
1366
1401
|
/** The limit of how many bytes that a message can contain before Amazon SQS rejects it.
|
|
1367
1402
|
* You can specify an size value from 1 KB to 256 KB.
|
|
1368
1403
|
* @default '256 KB' */
|
|
1369
|
-
maxMessageSize:
|
|
1404
|
+
maxMessageSize: MaxMessageSizeSchema.optional(),
|
|
1405
|
+
/** The maximum number of records in each batch that Lambda pulls from your queue and sends to your function.
|
|
1406
|
+
* Lambda passes all of the records in the batch to the function in a single call, up to the payload limit for synchronous invocation (6 MB).
|
|
1407
|
+
* You can specify an integer from 1 to 10000.
|
|
1408
|
+
* @default 10 */
|
|
1409
|
+
batchSize: BatchSizeSchema.optional(),
|
|
1410
|
+
/** Limits the number of concurrent instances that the queue worker can invoke.
|
|
1411
|
+
* You can specify an integer from 2 to 1000. */
|
|
1412
|
+
maxConcurrency: MaxConcurrencySchema.optional(),
|
|
1413
|
+
/** The maximum amount of time, that Lambda spends gathering records before invoking the function.
|
|
1414
|
+
* You can specify an duration from 0 seconds to 5 minutes.
|
|
1415
|
+
* @default '0 seconds' */
|
|
1416
|
+
maxBatchingWindow: MaxBatchingWindow.optional()
|
|
1370
1417
|
})
|
|
1371
1418
|
])
|
|
1372
1419
|
).optional()
|
|
@@ -1378,12 +1425,15 @@ var queuePlugin = definePlugin({
|
|
|
1378
1425
|
const props = typeof functionOrProps === "string" ? { ...config.defaults.queue, consumer: functionOrProps } : { ...config.defaults.queue, ...functionOrProps };
|
|
1379
1426
|
const queue2 = new Queue(id, {
|
|
1380
1427
|
name: `${config.name}-${stack.name}-${id}`,
|
|
1428
|
+
deadLetterArn: getGlobalOnFailure(ctx),
|
|
1381
1429
|
...props
|
|
1382
1430
|
});
|
|
1383
1431
|
const lambda = toLambdaFunction(ctx, `queue-${id}`, props.consumer);
|
|
1384
1432
|
const source = new SqsEventSource(id, lambda, {
|
|
1385
1433
|
queueArn: queue2.arn,
|
|
1386
|
-
|
|
1434
|
+
batchSize: props.batchSize,
|
|
1435
|
+
maxConcurrency: props.maxConcurrency,
|
|
1436
|
+
maxBatchingWindow: props.maxBatchingWindow
|
|
1387
1437
|
});
|
|
1388
1438
|
stack.add(queue2, lambda, source);
|
|
1389
1439
|
bind((lambda2) => {
|
|
@@ -1439,6 +1489,26 @@ var Table = class extends Resource {
|
|
|
1439
1489
|
resources: [this.arn]
|
|
1440
1490
|
};
|
|
1441
1491
|
}
|
|
1492
|
+
attributeDefinitions() {
|
|
1493
|
+
const fields = this.props.fields || {};
|
|
1494
|
+
const attributes = new Set([
|
|
1495
|
+
this.props.hash,
|
|
1496
|
+
this.props.sort,
|
|
1497
|
+
...Object.values(this.props.indexes || {}).map((index) => [
|
|
1498
|
+
index.hash,
|
|
1499
|
+
index.sort
|
|
1500
|
+
])
|
|
1501
|
+
].flat().filter(Boolean));
|
|
1502
|
+
const types = {
|
|
1503
|
+
string: "S",
|
|
1504
|
+
number: "N",
|
|
1505
|
+
binary: "B"
|
|
1506
|
+
};
|
|
1507
|
+
return [...attributes].map((name) => ({
|
|
1508
|
+
AttributeName: name,
|
|
1509
|
+
AttributeType: types[fields[name] || "string"]
|
|
1510
|
+
}));
|
|
1511
|
+
}
|
|
1442
1512
|
properties() {
|
|
1443
1513
|
return {
|
|
1444
1514
|
TableName: this.name,
|
|
@@ -1451,10 +1521,7 @@ var Table = class extends Resource {
|
|
|
1451
1521
|
{ KeyType: "HASH", AttributeName: this.props.hash },
|
|
1452
1522
|
...this.props.sort ? [{ KeyType: "RANGE", AttributeName: this.props.sort }] : []
|
|
1453
1523
|
],
|
|
1454
|
-
AttributeDefinitions:
|
|
1455
|
-
AttributeName: name,
|
|
1456
|
-
AttributeType: type[0].toUpperCase()
|
|
1457
|
-
})),
|
|
1524
|
+
AttributeDefinitions: this.attributeDefinitions(),
|
|
1458
1525
|
...this.props.stream ? {
|
|
1459
1526
|
StreamSpecification: {
|
|
1460
1527
|
StreamViewType: constantCase2(this.props.stream)
|
|
@@ -1539,6 +1606,7 @@ var tablePlugin = definePlugin({
|
|
|
1539
1606
|
/** Specifies the name of the range / sort key that makes up the primary key for the table. */
|
|
1540
1607
|
sort: KeySchema.optional(),
|
|
1541
1608
|
/** A list of attributes that describe the key schema for the table and indexes.
|
|
1609
|
+
* If no attribute field is defined we default to 'string'.
|
|
1542
1610
|
* @example
|
|
1543
1611
|
* {
|
|
1544
1612
|
* fields: {
|
|
@@ -1546,7 +1614,10 @@ var tablePlugin = definePlugin({
|
|
|
1546
1614
|
* }
|
|
1547
1615
|
* }
|
|
1548
1616
|
*/
|
|
1549
|
-
fields: z9.record(
|
|
1617
|
+
fields: z9.record(
|
|
1618
|
+
z9.string(),
|
|
1619
|
+
z9.enum(["string", "number", "binary"])
|
|
1620
|
+
).optional(),
|
|
1550
1621
|
/** The table class of the table.
|
|
1551
1622
|
* @default 'standard'
|
|
1552
1623
|
*/
|
|
@@ -1595,18 +1666,22 @@ var tablePlugin = definePlugin({
|
|
|
1595
1666
|
*/
|
|
1596
1667
|
projection: z9.enum(["all", "keys-only"]).default("all")
|
|
1597
1668
|
})).optional()
|
|
1598
|
-
})
|
|
1599
|
-
|
|
1600
|
-
|
|
1601
|
-
|
|
1602
|
-
|
|
1603
|
-
|
|
1604
|
-
|
|
1605
|
-
|
|
1606
|
-
|
|
1607
|
-
|
|
1608
|
-
|
|
1609
|
-
|
|
1669
|
+
})
|
|
1670
|
+
// .refine(props => {
|
|
1671
|
+
// return (
|
|
1672
|
+
// // Check the hash key
|
|
1673
|
+
// props.fields.hasOwnProperty(props.hash) &&
|
|
1674
|
+
// // Check the sort key
|
|
1675
|
+
// (!props.sort || props.fields.hasOwnProperty(props.sort)) &&
|
|
1676
|
+
// // Check all indexes
|
|
1677
|
+
// !Object.values(props.indexes || {}).map(index => (
|
|
1678
|
+
// // Check the index hash key
|
|
1679
|
+
// props.fields.hasOwnProperty(index.hash) &&
|
|
1680
|
+
// // Check the index sort key
|
|
1681
|
+
// (!index.sort || props.fields.hasOwnProperty(index.sort))
|
|
1682
|
+
// )).includes(false)
|
|
1683
|
+
// )
|
|
1684
|
+
// }, 'Hash & Sort keys must be defined inside the table fields')
|
|
1610
1685
|
).optional()
|
|
1611
1686
|
}).array()
|
|
1612
1687
|
}),
|
|
@@ -2607,7 +2682,7 @@ var domainPlugin = definePlugin({
|
|
|
2607
2682
|
name: DomainNameSchema.optional(),
|
|
2608
2683
|
/** The DNS record type. */
|
|
2609
2684
|
type: z15.enum(["A", "AAAA", "CAA", "CNAME", "DS", "MX", "NAPTR", "NS", "PTR", "SOA", "SPF", "SRV", "TXT"]),
|
|
2610
|
-
/** The resource record cache time to live (TTL) */
|
|
2685
|
+
/** The resource record cache time to live (TTL). */
|
|
2611
2686
|
ttl: DurationSchema,
|
|
2612
2687
|
/** One or more values that correspond with the value that you specified for the Type property. */
|
|
2613
2688
|
records: z15.string().array()
|