@awsless/awsless 0.0.70 → 0.0.72
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.js +107 -82
- package/dist/features/upload-bucket-asset.js +9322 -15647
- package/dist/index.d.ts +185 -3
- package/package.json +4 -4
package/dist/bin.js
CHANGED
|
@@ -281,8 +281,79 @@ var Role = class extends Resource {
|
|
|
281
281
|
}
|
|
282
282
|
};
|
|
283
283
|
|
|
284
|
-
// src/formation/resource/
|
|
284
|
+
// src/formation/resource/events/rule.ts
|
|
285
|
+
var Rule = class extends Resource {
|
|
286
|
+
constructor(logicalId, props) {
|
|
287
|
+
super("AWS::Events::Rule", logicalId);
|
|
288
|
+
this.props = props;
|
|
289
|
+
this.name = formatName(this.props.name || logicalId);
|
|
290
|
+
}
|
|
291
|
+
name;
|
|
292
|
+
get id() {
|
|
293
|
+
return ref(this.logicalId);
|
|
294
|
+
}
|
|
295
|
+
get arn() {
|
|
296
|
+
return getAtt(this.logicalId, "Arn");
|
|
297
|
+
}
|
|
298
|
+
properties() {
|
|
299
|
+
return {
|
|
300
|
+
Name: this.name,
|
|
301
|
+
...this.attr("State", "ENABLED"),
|
|
302
|
+
...this.attr("Description", this.props.description),
|
|
303
|
+
...this.attr("ScheduleExpression", this.props.schedule),
|
|
304
|
+
...this.attr("RoleArn", this.props.roleArn),
|
|
305
|
+
...this.attr("EventBusName", this.props.eventBusName),
|
|
306
|
+
...this.attr("EventPattern", this.props.eventPattern),
|
|
307
|
+
Targets: this.props.targets.map((target) => ({
|
|
308
|
+
Arn: target.arn,
|
|
309
|
+
Id: target.id,
|
|
310
|
+
...this.attr("Input", target.input && JSON.stringify(target.input))
|
|
311
|
+
}))
|
|
312
|
+
};
|
|
313
|
+
}
|
|
314
|
+
};
|
|
315
|
+
|
|
316
|
+
// src/formation/resource/lambda/permission.ts
|
|
285
317
|
import { constantCase } from "change-case";
|
|
318
|
+
var Permission = class extends Resource {
|
|
319
|
+
constructor(logicalId, props) {
|
|
320
|
+
super("AWS::Lambda::Permission", logicalId);
|
|
321
|
+
this.props = props;
|
|
322
|
+
}
|
|
323
|
+
properties() {
|
|
324
|
+
return {
|
|
325
|
+
FunctionName: this.props.functionArn,
|
|
326
|
+
Action: this.props.action || "lambda:InvokeFunction",
|
|
327
|
+
Principal: this.props.principal,
|
|
328
|
+
...this.attr("FunctionUrlAuthType", this.props.urlAuthType && constantCase(this.props.urlAuthType)),
|
|
329
|
+
...this.attr("SourceArn", this.props.sourceArn)
|
|
330
|
+
};
|
|
331
|
+
}
|
|
332
|
+
};
|
|
333
|
+
|
|
334
|
+
// src/formation/resource/lambda/event-source/events.ts
|
|
335
|
+
var EventsEventSource = class extends Group {
|
|
336
|
+
constructor(id, lambda, props) {
|
|
337
|
+
const rule = new Rule(id, {
|
|
338
|
+
schedule: props.schedule,
|
|
339
|
+
targets: [{
|
|
340
|
+
id,
|
|
341
|
+
arn: lambda.arn,
|
|
342
|
+
input: props.payload
|
|
343
|
+
}]
|
|
344
|
+
});
|
|
345
|
+
const permission = new Permission(id, {
|
|
346
|
+
action: "lambda:InvokeFunction",
|
|
347
|
+
principal: "events.amazonaws.com",
|
|
348
|
+
functionArn: lambda.arn,
|
|
349
|
+
sourceArn: rule.arn
|
|
350
|
+
});
|
|
351
|
+
super([rule, permission]);
|
|
352
|
+
}
|
|
353
|
+
};
|
|
354
|
+
|
|
355
|
+
// src/formation/resource/lambda/url.ts
|
|
356
|
+
import { constantCase as constantCase2 } from "change-case";
|
|
286
357
|
var Url = class extends Resource {
|
|
287
358
|
constructor(logicalId, props) {
|
|
288
359
|
super("AWS::Lambda::Url", logicalId);
|
|
@@ -293,8 +364,8 @@ var Url = class extends Resource {
|
|
|
293
364
|
}
|
|
294
365
|
properties() {
|
|
295
366
|
return {
|
|
296
|
-
AuthType:
|
|
297
|
-
InvokeMode:
|
|
367
|
+
AuthType: constantCase2(this.props.authType ?? "none"),
|
|
368
|
+
InvokeMode: constantCase2(this.props.invokeMode ?? "buffered"),
|
|
298
369
|
TargetFunctionArn: this.props.target,
|
|
299
370
|
...this.attr("Qualifier", this.props.qualifier),
|
|
300
371
|
Cors: {
|
|
@@ -351,6 +422,17 @@ var Function = class extends Resource {
|
|
|
351
422
|
});
|
|
352
423
|
return this;
|
|
353
424
|
}
|
|
425
|
+
warmUp(concurrency) {
|
|
426
|
+
const source = new EventsEventSource(this._logicalId, this, {
|
|
427
|
+
schedule: "rate(5 minutes)",
|
|
428
|
+
payload: {
|
|
429
|
+
warmer: true,
|
|
430
|
+
concurrency
|
|
431
|
+
}
|
|
432
|
+
});
|
|
433
|
+
this.addChild(source);
|
|
434
|
+
return this;
|
|
435
|
+
}
|
|
354
436
|
addUrl(props = {}) {
|
|
355
437
|
return new Url(this._logicalId, {
|
|
356
438
|
...props,
|
|
@@ -1122,7 +1204,7 @@ import { relative as relative2 } from "path";
|
|
|
1122
1204
|
// src/util/type-gen.ts
|
|
1123
1205
|
import { mkdir, writeFile } from "fs/promises";
|
|
1124
1206
|
import { join as join3, relative } from "path";
|
|
1125
|
-
import { camelCase, constantCase as
|
|
1207
|
+
import { camelCase, constantCase as constantCase3 } from "change-case";
|
|
1126
1208
|
var generateResourceTypes = async (config) => {
|
|
1127
1209
|
const plugins = [
|
|
1128
1210
|
...defaultPlugins,
|
|
@@ -1168,7 +1250,7 @@ var TypeGen = class {
|
|
|
1168
1250
|
}
|
|
1169
1251
|
addConst(name, type) {
|
|
1170
1252
|
if (type) {
|
|
1171
|
-
this.types.set(
|
|
1253
|
+
this.types.set(constantCase3(name), type);
|
|
1172
1254
|
}
|
|
1173
1255
|
return this;
|
|
1174
1256
|
}
|
|
@@ -1219,7 +1301,7 @@ var TypeObject = class {
|
|
|
1219
1301
|
}
|
|
1220
1302
|
addConst(name, type) {
|
|
1221
1303
|
if (type) {
|
|
1222
|
-
this.types.set(
|
|
1304
|
+
this.types.set(constantCase3(name), type);
|
|
1223
1305
|
}
|
|
1224
1306
|
return this;
|
|
1225
1307
|
}
|
|
@@ -1252,6 +1334,7 @@ var LogSchema = z6.union([
|
|
|
1252
1334
|
z6.boolean(),
|
|
1253
1335
|
DurationSchema.refine(durationMin(Duration.days(1)), "Minimum log retention is 1 day")
|
|
1254
1336
|
]);
|
|
1337
|
+
var WarmSchema = z6.number().int().min(1).max(10);
|
|
1255
1338
|
var FunctionSchema = z6.union([
|
|
1256
1339
|
LocalFileSchema,
|
|
1257
1340
|
z6.object({
|
|
@@ -1265,6 +1348,11 @@ var FunctionSchema = z6.union([
|
|
|
1265
1348
|
* @default true
|
|
1266
1349
|
*/
|
|
1267
1350
|
minify: z6.boolean().optional(),
|
|
1351
|
+
/** Specify how many functions you want to warm up each 5 minutes.
|
|
1352
|
+
* You can specify a number from 0 to 10.
|
|
1353
|
+
* @default 0
|
|
1354
|
+
*/
|
|
1355
|
+
warm: WarmSchema.optional(),
|
|
1268
1356
|
/** Put the function inside your global VPC.
|
|
1269
1357
|
* @default false
|
|
1270
1358
|
*/
|
|
@@ -1334,6 +1422,11 @@ var schema = z6.object({
|
|
|
1334
1422
|
* @default true
|
|
1335
1423
|
*/
|
|
1336
1424
|
minify: z6.boolean().default(true),
|
|
1425
|
+
/** Specify how many functions you want to warm up each 5 minutes.
|
|
1426
|
+
* You can specify a number from 0 to 10.
|
|
1427
|
+
* @default 0
|
|
1428
|
+
*/
|
|
1429
|
+
warm: WarmSchema.default(0),
|
|
1337
1430
|
/** Put the function inside your global VPC.
|
|
1338
1431
|
* @default false
|
|
1339
1432
|
*/
|
|
@@ -1469,6 +1562,9 @@ var toLambdaFunction = (ctx, id, fileOrProps) => {
|
|
|
1469
1562
|
if (props.log) {
|
|
1470
1563
|
lambda.enableLogs(props.log instanceof Duration ? props.log : void 0);
|
|
1471
1564
|
}
|
|
1565
|
+
if (props.warm) {
|
|
1566
|
+
lambda.warmUp(props.warm);
|
|
1567
|
+
}
|
|
1472
1568
|
if (props.vpc) {
|
|
1473
1569
|
lambda.setVpc({
|
|
1474
1570
|
securityGroupIds: [
|
|
@@ -1495,77 +1591,6 @@ var toLambdaFunction = (ctx, id, fileOrProps) => {
|
|
|
1495
1591
|
return lambda;
|
|
1496
1592
|
};
|
|
1497
1593
|
|
|
1498
|
-
// src/formation/resource/events/rule.ts
|
|
1499
|
-
var Rule = class extends Resource {
|
|
1500
|
-
constructor(logicalId, props) {
|
|
1501
|
-
super("AWS::Events::Rule", logicalId);
|
|
1502
|
-
this.props = props;
|
|
1503
|
-
this.name = formatName(this.props.name || logicalId);
|
|
1504
|
-
}
|
|
1505
|
-
name;
|
|
1506
|
-
get id() {
|
|
1507
|
-
return ref(this.logicalId);
|
|
1508
|
-
}
|
|
1509
|
-
get arn() {
|
|
1510
|
-
return getAtt(this.logicalId, "Arn");
|
|
1511
|
-
}
|
|
1512
|
-
properties() {
|
|
1513
|
-
return {
|
|
1514
|
-
Name: this.name,
|
|
1515
|
-
...this.attr("State", "ENABLED"),
|
|
1516
|
-
...this.attr("Description", this.props.description),
|
|
1517
|
-
...this.attr("ScheduleExpression", this.props.schedule),
|
|
1518
|
-
...this.attr("RoleArn", this.props.roleArn),
|
|
1519
|
-
...this.attr("EventBusName", this.props.eventBusName),
|
|
1520
|
-
...this.attr("EventPattern", this.props.eventPattern),
|
|
1521
|
-
Targets: this.props.targets.map((target) => ({
|
|
1522
|
-
Arn: target.arn,
|
|
1523
|
-
Id: target.id,
|
|
1524
|
-
...this.attr("Input", target.input && JSON.stringify(target.input))
|
|
1525
|
-
}))
|
|
1526
|
-
};
|
|
1527
|
-
}
|
|
1528
|
-
};
|
|
1529
|
-
|
|
1530
|
-
// src/formation/resource/lambda/permission.ts
|
|
1531
|
-
import { constantCase as constantCase3 } from "change-case";
|
|
1532
|
-
var Permission2 = class extends Resource {
|
|
1533
|
-
constructor(logicalId, props) {
|
|
1534
|
-
super("AWS::Lambda::Permission", logicalId);
|
|
1535
|
-
this.props = props;
|
|
1536
|
-
}
|
|
1537
|
-
properties() {
|
|
1538
|
-
return {
|
|
1539
|
-
FunctionName: this.props.functionArn,
|
|
1540
|
-
Action: this.props.action || "lambda:InvokeFunction",
|
|
1541
|
-
Principal: this.props.principal,
|
|
1542
|
-
...this.attr("FunctionUrlAuthType", this.props.urlAuthType && constantCase3(this.props.urlAuthType)),
|
|
1543
|
-
...this.attr("SourceArn", this.props.sourceArn)
|
|
1544
|
-
};
|
|
1545
|
-
}
|
|
1546
|
-
};
|
|
1547
|
-
|
|
1548
|
-
// src/formation/resource/lambda/event-source/events.ts
|
|
1549
|
-
var EventsEventSource = class extends Group {
|
|
1550
|
-
constructor(id, lambda, props) {
|
|
1551
|
-
const rule = new Rule(id, {
|
|
1552
|
-
schedule: props.schedule,
|
|
1553
|
-
targets: [{
|
|
1554
|
-
id,
|
|
1555
|
-
arn: lambda.arn,
|
|
1556
|
-
input: props.payload
|
|
1557
|
-
}]
|
|
1558
|
-
});
|
|
1559
|
-
const permission = new Permission2(id, {
|
|
1560
|
-
action: "lambda:InvokeFunction",
|
|
1561
|
-
principal: "events.amazonaws.com",
|
|
1562
|
-
functionArn: lambda.arn,
|
|
1563
|
-
sourceArn: rule.arn
|
|
1564
|
-
});
|
|
1565
|
-
super([rule, permission]);
|
|
1566
|
-
}
|
|
1567
|
-
};
|
|
1568
|
-
|
|
1569
1594
|
// src/plugins/cron/index.ts
|
|
1570
1595
|
var cronPlugin = definePlugin({
|
|
1571
1596
|
name: "cron",
|
|
@@ -2357,7 +2382,7 @@ var SnsEventSource = class extends Group {
|
|
|
2357
2382
|
protocol: "lambda",
|
|
2358
2383
|
endpoint: lambda.arn
|
|
2359
2384
|
});
|
|
2360
|
-
const permission = new
|
|
2385
|
+
const permission = new Permission(id, {
|
|
2361
2386
|
action: "lambda:InvokeFunction",
|
|
2362
2387
|
principal: "sns.amazonaws.com",
|
|
2363
2388
|
functionArn: lambda.arn,
|
|
@@ -2522,7 +2547,7 @@ var IotEventSource = class extends Group {
|
|
|
2522
2547
|
sqlVersion: props.sqlVersion,
|
|
2523
2548
|
actions: [{ lambda: { functionArn: lambda.arn } }]
|
|
2524
2549
|
});
|
|
2525
|
-
const permission = new
|
|
2550
|
+
const permission = new Permission(id, {
|
|
2526
2551
|
action: "lambda:InvokeFunction",
|
|
2527
2552
|
principal: "iot.amazonaws.com",
|
|
2528
2553
|
functionArn: lambda.arn,
|
|
@@ -3792,7 +3817,7 @@ var TargetGroup = class extends Resource {
|
|
|
3792
3817
|
var ElbEventSource = class extends Group {
|
|
3793
3818
|
constructor(id, lambda, props) {
|
|
3794
3819
|
const name = formatName(id);
|
|
3795
|
-
const permission = new
|
|
3820
|
+
const permission = new Permission(id, {
|
|
3796
3821
|
action: "lambda:InvokeFunction",
|
|
3797
3822
|
principal: "elasticloadbalancing.amazonaws.com",
|
|
3798
3823
|
functionArn: lambda.arn,
|
|
@@ -4265,7 +4290,7 @@ var Route2 = class extends Resource {
|
|
|
4265
4290
|
var ApiGatewayV2EventSource = class extends Group {
|
|
4266
4291
|
constructor(id, lambda, props) {
|
|
4267
4292
|
const name = formatName(id);
|
|
4268
|
-
const permission = new
|
|
4293
|
+
const permission = new Permission(id, {
|
|
4269
4294
|
action: "lambda:InvokeFunction",
|
|
4270
4295
|
principal: "apigateway.amazonaws.com",
|
|
4271
4296
|
functionArn: lambda.arn
|
|
@@ -5153,7 +5178,7 @@ var sitePlugin = definePlugin({
|
|
|
5153
5178
|
let bucket;
|
|
5154
5179
|
if (props.ssr) {
|
|
5155
5180
|
const lambda = toLambdaFunction(ctx, `site-${id}`, props.ssr);
|
|
5156
|
-
const permissions = new
|
|
5181
|
+
const permissions = new Permission(`site-${id}`, {
|
|
5157
5182
|
principal: "*",
|
|
5158
5183
|
// principal: 'cloudfront.amazonaws.com',
|
|
5159
5184
|
action: "lambda:InvokeFunctionUrl",
|