@awsless/awsless 0.0.367 → 0.0.368
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/app.json +1 -1
- package/dist/bin.js +225 -116
- package/dist/build-json-schema.js +21 -2
- package/dist/prebuild/rpc/HASH +1 -1
- package/dist/prebuild/rpc/bundle.zip +0 -0
- package/dist/stack.json +1 -1
- package/package.json +12 -12
package/dist/bin.js
CHANGED
|
@@ -596,9 +596,9 @@ var require_Alias = __commonJS({
|
|
|
596
596
|
var anchors = require_anchors();
|
|
597
597
|
var visit = require_visit();
|
|
598
598
|
var identity = require_identity();
|
|
599
|
-
var
|
|
599
|
+
var Node25 = require_Node();
|
|
600
600
|
var toJS = require_toJS();
|
|
601
|
-
var Alias = class extends
|
|
601
|
+
var Alias = class extends Node25.NodeBase {
|
|
602
602
|
constructor(source) {
|
|
603
603
|
super(identity.ALIAS);
|
|
604
604
|
this.source = source;
|
|
@@ -696,10 +696,10 @@ var require_Scalar = __commonJS({
|
|
|
696
696
|
"../../node_modules/.pnpm/yaml@2.5.0/node_modules/yaml/dist/nodes/Scalar.js"(exports) {
|
|
697
697
|
"use strict";
|
|
698
698
|
var identity = require_identity();
|
|
699
|
-
var
|
|
699
|
+
var Node25 = require_Node();
|
|
700
700
|
var toJS = require_toJS();
|
|
701
701
|
var isScalarValue = (value) => !value || typeof value !== "function" && typeof value !== "object";
|
|
702
|
-
var Scalar = class extends
|
|
702
|
+
var Scalar = class extends Node25.NodeBase {
|
|
703
703
|
constructor(value) {
|
|
704
704
|
super(identity.SCALAR);
|
|
705
705
|
this.value = value;
|
|
@@ -803,7 +803,7 @@ var require_Collection = __commonJS({
|
|
|
803
803
|
"use strict";
|
|
804
804
|
var createNode = require_createNode();
|
|
805
805
|
var identity = require_identity();
|
|
806
|
-
var
|
|
806
|
+
var Node25 = require_Node();
|
|
807
807
|
function collectionFromPath(schema, path, value) {
|
|
808
808
|
let v = value;
|
|
809
809
|
for (let i = path.length - 1; i >= 0; --i) {
|
|
@@ -827,7 +827,7 @@ var require_Collection = __commonJS({
|
|
|
827
827
|
});
|
|
828
828
|
}
|
|
829
829
|
var isEmptyPath = (path) => path == null || typeof path === "object" && !!path[Symbol.iterator]().next().done;
|
|
830
|
-
var Collection = class extends
|
|
830
|
+
var Collection = class extends Node25.NodeBase {
|
|
831
831
|
constructor(type, schema) {
|
|
832
832
|
super(type);
|
|
833
833
|
Object.defineProperty(this, "schema", {
|
|
@@ -7680,10 +7680,22 @@ var LogRetentionSchema = DurationSchema.refine(
|
|
|
7680
7680
|
},
|
|
7681
7681
|
`Invalid log retention. Valid days are: ${validLogRetentionDays.map((days7) => `${days7}`).join(", ")}`
|
|
7682
7682
|
).describe("The log retention duration.");
|
|
7683
|
+
var LogSubscriptionSchema = z5.union([
|
|
7684
|
+
LocalFileSchema.transform((file) => ({
|
|
7685
|
+
file
|
|
7686
|
+
})),
|
|
7687
|
+
z5.object({
|
|
7688
|
+
subscriber: LocalFileSchema,
|
|
7689
|
+
filter: z5.string().optional()
|
|
7690
|
+
})
|
|
7691
|
+
]).describe(
|
|
7692
|
+
"Log Subscription allow you to subscribe to a real-time stream of log events and have them delivered to a specific destination"
|
|
7693
|
+
);
|
|
7683
7694
|
var LogSchema = z5.union([
|
|
7684
7695
|
z5.boolean().transform((enabled) => ({ retention: enabled ? days(7) : days(0) })),
|
|
7685
7696
|
LogRetentionSchema.transform((retention) => ({ retention })),
|
|
7686
7697
|
z5.object({
|
|
7698
|
+
subscription: LogSubscriptionSchema.optional(),
|
|
7687
7699
|
retention: LogRetentionSchema.optional(),
|
|
7688
7700
|
format: z5.enum(["text", "json"]).describe(
|
|
7689
7701
|
`The format in which Lambda sends your function's application and system logs to CloudWatch. Select between plain text and structured JSON.`
|
|
@@ -7981,6 +7993,11 @@ var InstancesSchema = z12.record(
|
|
|
7981
7993
|
})
|
|
7982
7994
|
).optional().describe("Define the instances in your stack.");
|
|
7983
7995
|
|
|
7996
|
+
// src/feature/log-subscription/schema.ts
|
|
7997
|
+
var LogSubscriptionSchema2 = FunctionSchema.optional().describe(
|
|
7998
|
+
"Log Subscription allow you to subscribe to a real-time stream of log events and have them delivered to a specific destination."
|
|
7999
|
+
);
|
|
8000
|
+
|
|
7984
8001
|
// src/feature/pubsub/schema.ts
|
|
7985
8002
|
import { z as z13 } from "zod";
|
|
7986
8003
|
var DomainSchema = ResourceIdSchema.describe("The domain id to link your Pubsub API with.");
|
|
@@ -8012,9 +8029,9 @@ var PubSubSchema = z13.record(
|
|
|
8012
8029
|
).optional().describe("Define the pubsub subscriber in your stack.");
|
|
8013
8030
|
|
|
8014
8031
|
// src/feature/queue/schema.ts
|
|
8015
|
-
import { z as z14 } from "zod";
|
|
8016
8032
|
import { days as days2, hours, minutes as minutes3, seconds as seconds2 } from "@awsless/duration";
|
|
8017
8033
|
import { kibibytes } from "@awsless/size";
|
|
8034
|
+
import { z as z14 } from "zod";
|
|
8018
8035
|
var RetentionPeriodSchema = DurationSchema.refine(
|
|
8019
8036
|
durationMin(minutes3(1)),
|
|
8020
8037
|
"Minimum retention period is 1 minute"
|
|
@@ -8073,7 +8090,7 @@ var QueuesSchema = z14.record(
|
|
|
8073
8090
|
}
|
|
8074
8091
|
})),
|
|
8075
8092
|
z14.object({
|
|
8076
|
-
consumer: FunctionSchema.describe("
|
|
8093
|
+
consumer: FunctionSchema.describe("The consuming lambda function properties."),
|
|
8077
8094
|
retentionPeriod: RetentionPeriodSchema.optional(),
|
|
8078
8095
|
visibilityTimeout: VisibilityTimeoutSchema.optional(),
|
|
8079
8096
|
deliveryDelay: DeliveryDelaySchema.optional(),
|
|
@@ -8264,6 +8281,8 @@ var AppSchema = z21.object({
|
|
|
8264
8281
|
// .regex(/^[a-z]+$/)
|
|
8265
8282
|
// .default('prod')
|
|
8266
8283
|
// .describe('The deployment stage.'),
|
|
8284
|
+
// onFailure: OnFailureSchema,
|
|
8285
|
+
logSubscription: LogSubscriptionSchema2,
|
|
8267
8286
|
defaults: z21.object({
|
|
8268
8287
|
auth: AuthDefaultSchema,
|
|
8269
8288
|
domains: DomainsDefaultSchema,
|
|
@@ -10929,6 +10948,14 @@ var createLambdaFunction = (group, ctx, ns, id, local2) => {
|
|
|
10929
10948
|
resources: [logGroup.arn.apply((arn) => `${arn}:*`)]
|
|
10930
10949
|
}
|
|
10931
10950
|
);
|
|
10951
|
+
const logSubscriptionArn = ctx.shared.get("log-subscription-destination-arn");
|
|
10952
|
+
if (logSubscriptionArn) {
|
|
10953
|
+
new aws2.cloudWatch.SubscriptionFilter(group, `log-subscription`, {
|
|
10954
|
+
destinationArn: logSubscriptionArn,
|
|
10955
|
+
logGroupName: logGroup.name,
|
|
10956
|
+
filterPattern: "{$.level = ERROR}"
|
|
10957
|
+
});
|
|
10958
|
+
}
|
|
10932
10959
|
}
|
|
10933
10960
|
if (ctx.appConfig.defaults.function.permissions) {
|
|
10934
10961
|
policy.addStatement(...ctx.appConfig.defaults.function.permissions);
|
|
@@ -12302,8 +12329,75 @@ var instanceFeature = defineFeature({
|
|
|
12302
12329
|
}
|
|
12303
12330
|
});
|
|
12304
12331
|
|
|
12305
|
-
// src/feature/
|
|
12332
|
+
// src/feature/log-subscription/index.ts
|
|
12306
12333
|
import { Node as Node10, aws as aws11 } from "@awsless/formation";
|
|
12334
|
+
var logSubscriptionFeature = defineFeature({
|
|
12335
|
+
name: "log-subscription",
|
|
12336
|
+
onApp(ctx) {
|
|
12337
|
+
if (!ctx.appConfig.logSubscription) {
|
|
12338
|
+
return;
|
|
12339
|
+
}
|
|
12340
|
+
const group = new Node10(ctx.base, "log-subscription", "main");
|
|
12341
|
+
const { lambda, policy } = createLambdaFunction(
|
|
12342
|
+
group,
|
|
12343
|
+
ctx,
|
|
12344
|
+
"log-subscription",
|
|
12345
|
+
"main",
|
|
12346
|
+
ctx.appConfig.logSubscription
|
|
12347
|
+
);
|
|
12348
|
+
new aws11.lambda.Permission(group, "log-subscription-permission", {
|
|
12349
|
+
action: "lambda:InvokeFunction",
|
|
12350
|
+
principal: "logs.amazonaws.com",
|
|
12351
|
+
functionArn: lambda.arn,
|
|
12352
|
+
sourceArn: `arn:aws:logs:${ctx.appConfig.region}:${ctx.accountId}:log-group:/aws/lambda/app-kennedy--*`
|
|
12353
|
+
});
|
|
12354
|
+
ctx.shared.set("log-subscription-destination-arn", lambda.arn);
|
|
12355
|
+
for (const stack of ctx.stackConfigs) {
|
|
12356
|
+
for (const id of stack.topics ?? []) {
|
|
12357
|
+
policy.addStatement({
|
|
12358
|
+
actions: ["sns:Publish"],
|
|
12359
|
+
resources: [ctx.shared.get(`topic-${id}-arn`)]
|
|
12360
|
+
});
|
|
12361
|
+
}
|
|
12362
|
+
for (const [id, props] of Object.entries(stack.tables ?? {})) {
|
|
12363
|
+
const tableName = formatLocalResourceName({
|
|
12364
|
+
appName: ctx.app.name,
|
|
12365
|
+
stackName: stack.name,
|
|
12366
|
+
resourceType: "table",
|
|
12367
|
+
resourceName: id
|
|
12368
|
+
});
|
|
12369
|
+
policy.addStatement({
|
|
12370
|
+
actions: [
|
|
12371
|
+
"dynamodb:DescribeTable",
|
|
12372
|
+
"dynamodb:PutItem",
|
|
12373
|
+
"dynamodb:GetItem",
|
|
12374
|
+
"dynamodb:UpdateItem",
|
|
12375
|
+
"dynamodb:DeleteItem",
|
|
12376
|
+
"dynamodb:TransactWrite",
|
|
12377
|
+
"dynamodb:BatchWriteItem",
|
|
12378
|
+
"dynamodb:BatchGetItem",
|
|
12379
|
+
"dynamodb:ConditionCheckItem",
|
|
12380
|
+
"dynamodb:Query",
|
|
12381
|
+
"dynamodb:Scan"
|
|
12382
|
+
],
|
|
12383
|
+
resources: [`arn:aws:dynamodb:${ctx.appConfig.region}:${ctx.accountId}:table/${tableName}`]
|
|
12384
|
+
});
|
|
12385
|
+
const indexes = Object.keys(props.indexes ?? {});
|
|
12386
|
+
if (indexes.length) {
|
|
12387
|
+
policy.addStatement({
|
|
12388
|
+
actions: ["dynamodb:Query"],
|
|
12389
|
+
resources: indexes.map(
|
|
12390
|
+
(indexName) => `arn:aws:dynamodb:${ctx.appConfig.region}:${ctx.accountId}:table/${tableName}/index/${indexName}`
|
|
12391
|
+
)
|
|
12392
|
+
});
|
|
12393
|
+
}
|
|
12394
|
+
}
|
|
12395
|
+
}
|
|
12396
|
+
}
|
|
12397
|
+
});
|
|
12398
|
+
|
|
12399
|
+
// src/feature/on-failure/index.ts
|
|
12400
|
+
import { Node as Node11, aws as aws12 } from "@awsless/formation";
|
|
12307
12401
|
var onFailureFeature = defineFeature({
|
|
12308
12402
|
name: "on-failure",
|
|
12309
12403
|
onApp(ctx) {
|
|
@@ -12314,7 +12408,7 @@ var onFailureFeature = defineFeature({
|
|
|
12314
12408
|
if (count > 1) {
|
|
12315
12409
|
throw new TypeError("Only 1 onFailure configuration is allowed in your app.");
|
|
12316
12410
|
}
|
|
12317
|
-
const queue2 = new
|
|
12411
|
+
const queue2 = new aws12.sqs.Queue(ctx.base, "on-failure", {
|
|
12318
12412
|
name: formatGlobalResourceName({
|
|
12319
12413
|
appName: ctx.app.name,
|
|
12320
12414
|
resourceType: "on-failure",
|
|
@@ -12329,9 +12423,9 @@ var onFailureFeature = defineFeature({
|
|
|
12329
12423
|
return;
|
|
12330
12424
|
}
|
|
12331
12425
|
const queueArn = ctx.shared.get("on-failure-queue-arn");
|
|
12332
|
-
const group = new
|
|
12426
|
+
const group = new Node11(ctx.stack, "on-failure", "failure");
|
|
12333
12427
|
const { lambda, policy } = createLambdaFunction(group, ctx, "on-failure", "failure", onFailure);
|
|
12334
|
-
const source = new
|
|
12428
|
+
const source = new aws12.lambda.EventSourceMapping(group, "on-failure", {
|
|
12335
12429
|
functionArn: lambda.arn,
|
|
12336
12430
|
sourceArn: queueArn,
|
|
12337
12431
|
batchSize: 10
|
|
@@ -12351,13 +12445,13 @@ var onFailureFeature = defineFeature({
|
|
|
12351
12445
|
});
|
|
12352
12446
|
|
|
12353
12447
|
// src/feature/pubsub/index.ts
|
|
12354
|
-
import { aws as
|
|
12448
|
+
import { aws as aws13, Node as Node12 } from "@awsless/formation";
|
|
12355
12449
|
import { constantCase as constantCase6 } from "change-case";
|
|
12356
12450
|
var pubsubFeature = defineFeature({
|
|
12357
12451
|
name: "pubsub",
|
|
12358
12452
|
onApp(ctx) {
|
|
12359
12453
|
for (const [id, props] of Object.entries(ctx.appConfig.defaults.pubsub ?? {})) {
|
|
12360
|
-
const group = new
|
|
12454
|
+
const group = new Node12(ctx.base, "pubsub", id);
|
|
12361
12455
|
const functionProps = typeof props.auth === "string" ? { file: "" } : props.auth.authorizer;
|
|
12362
12456
|
const { lambda } = createLambdaFunction(group, ctx, "pubsub-authorizer", id, functionProps);
|
|
12363
12457
|
lambda.addEnvironment("PUBSUB_POLICY", JSON.stringify(props.policy));
|
|
@@ -12367,23 +12461,23 @@ var pubsubFeature = defineFeature({
|
|
|
12367
12461
|
resourceType: "pubsub",
|
|
12368
12462
|
resourceName: id
|
|
12369
12463
|
});
|
|
12370
|
-
const authorizer = new
|
|
12464
|
+
const authorizer = new aws13.iot.Authorizer(group, "authorizer", {
|
|
12371
12465
|
name,
|
|
12372
12466
|
functionArn: lambda.arn
|
|
12373
12467
|
});
|
|
12374
|
-
new
|
|
12468
|
+
new aws13.lambda.Permission(group, "permission", {
|
|
12375
12469
|
functionArn: lambda.arn,
|
|
12376
12470
|
principal: "iot.amazonaws.com",
|
|
12377
12471
|
sourceArn: authorizer.arn,
|
|
12378
12472
|
action: "lambda:InvokeFunction"
|
|
12379
12473
|
});
|
|
12380
12474
|
ctx.bind(`PUBSUB_${constantCase6(id)}_AUTHORIZER`, name);
|
|
12381
|
-
const endpoint = new
|
|
12475
|
+
const endpoint = new aws13.iot.Endpoint(group, "endpoint", {
|
|
12382
12476
|
type: "data-ats"
|
|
12383
12477
|
});
|
|
12384
12478
|
if (props.domain) {
|
|
12385
12479
|
const domainName = formatFullDomainName(ctx.appConfig, props.domain, props.subDomain);
|
|
12386
|
-
new
|
|
12480
|
+
new aws13.iot.DomainConfiguration(group, "domain", {
|
|
12387
12481
|
name,
|
|
12388
12482
|
domainName,
|
|
12389
12483
|
certificates: [ctx.shared.get(`local-certificate-${props.domain}-arn`)],
|
|
@@ -12392,7 +12486,7 @@ var pubsubFeature = defineFeature({
|
|
|
12392
12486
|
}
|
|
12393
12487
|
// validationCertificate: ctx.shared.get(`global-certificate-${props.domain}-arn`),
|
|
12394
12488
|
});
|
|
12395
|
-
new
|
|
12489
|
+
new aws13.route53.RecordSet(group, "record", {
|
|
12396
12490
|
hostedZoneId: ctx.shared.get(`hosted-zone-${props.domain}-id`),
|
|
12397
12491
|
name: domainName,
|
|
12398
12492
|
type: "CNAME",
|
|
@@ -12413,7 +12507,7 @@ var pubsubFeature = defineFeature({
|
|
|
12413
12507
|
},
|
|
12414
12508
|
onStack(ctx) {
|
|
12415
12509
|
for (const [id, props] of Object.entries(ctx.stackConfig.pubsub ?? {})) {
|
|
12416
|
-
const group = new
|
|
12510
|
+
const group = new Node12(ctx.stack, "pubsub", id);
|
|
12417
12511
|
const { lambda } = createAsyncLambdaFunction(group, ctx, `pubsub`, id, props.consumer);
|
|
12418
12512
|
const name = formatLocalResourceName({
|
|
12419
12513
|
appName: ctx.app.name,
|
|
@@ -12421,13 +12515,13 @@ var pubsubFeature = defineFeature({
|
|
|
12421
12515
|
resourceType: "pubsub",
|
|
12422
12516
|
resourceName: id
|
|
12423
12517
|
});
|
|
12424
|
-
const topic = new
|
|
12518
|
+
const topic = new aws13.iot.TopicRule(group, "rule", {
|
|
12425
12519
|
name: name.replaceAll("-", "_"),
|
|
12426
12520
|
sql: props.sql,
|
|
12427
12521
|
sqlVersion: props.sqlVersion,
|
|
12428
12522
|
actions: [{ lambda: { functionArn: lambda.arn } }]
|
|
12429
12523
|
});
|
|
12430
|
-
new
|
|
12524
|
+
new aws13.lambda.Permission(group, "permission", {
|
|
12431
12525
|
action: "lambda:InvokeFunction",
|
|
12432
12526
|
principal: "iot.amazonaws.com",
|
|
12433
12527
|
functionArn: lambda.arn,
|
|
@@ -12438,7 +12532,7 @@ var pubsubFeature = defineFeature({
|
|
|
12438
12532
|
});
|
|
12439
12533
|
|
|
12440
12534
|
// src/feature/queue/index.ts
|
|
12441
|
-
import { aws as
|
|
12535
|
+
import { aws as aws14, Node as Node13 } from "@awsless/formation";
|
|
12442
12536
|
import { camelCase as camelCase5, constantCase as constantCase7 } from "change-case";
|
|
12443
12537
|
import deepmerge3 from "deepmerge";
|
|
12444
12538
|
import { relative as relative4 } from "path";
|
|
@@ -12498,21 +12592,21 @@ var queueFeature = defineFeature({
|
|
|
12498
12592
|
onStack(ctx) {
|
|
12499
12593
|
for (const [id, local2] of Object.entries(ctx.stackConfig.queues || {})) {
|
|
12500
12594
|
const props = deepmerge3(ctx.appConfig.defaults.queue, local2);
|
|
12501
|
-
const group = new
|
|
12595
|
+
const group = new Node13(ctx.stack, "queue", id);
|
|
12502
12596
|
const name = formatLocalResourceName({
|
|
12503
12597
|
appName: ctx.app.name,
|
|
12504
12598
|
stackName: ctx.stack.name,
|
|
12505
12599
|
resourceType: "queue",
|
|
12506
12600
|
resourceName: id
|
|
12507
12601
|
});
|
|
12508
|
-
const queue2 = new
|
|
12602
|
+
const queue2 = new aws14.sqs.Queue(group, "queue", {
|
|
12509
12603
|
name,
|
|
12510
12604
|
deadLetterArn: getGlobalOnFailure(ctx),
|
|
12511
12605
|
...props
|
|
12512
12606
|
});
|
|
12513
12607
|
const { lambda, policy } = createLambdaFunction(group, ctx, `queue`, id, props.consumer);
|
|
12514
12608
|
lambda.addEnvironment("LOG_VIEWABLE_ERROR", "1");
|
|
12515
|
-
new
|
|
12609
|
+
new aws14.lambda.EventSourceMapping(group, "event", {
|
|
12516
12610
|
functionArn: lambda.arn,
|
|
12517
12611
|
sourceArn: queue2.arn,
|
|
12518
12612
|
batchSize: props.batchSize,
|
|
@@ -12532,23 +12626,23 @@ var queueFeature = defineFeature({
|
|
|
12532
12626
|
});
|
|
12533
12627
|
|
|
12534
12628
|
// src/feature/rest/index.ts
|
|
12535
|
-
import { aws as
|
|
12629
|
+
import { aws as aws15, Node as Node14 } from "@awsless/formation";
|
|
12536
12630
|
import { constantCase as constantCase8 } from "change-case";
|
|
12537
12631
|
var restFeature = defineFeature({
|
|
12538
12632
|
name: "rest",
|
|
12539
12633
|
onApp(ctx) {
|
|
12540
12634
|
for (const [id, props] of Object.entries(ctx.appConfig.defaults?.rest ?? {})) {
|
|
12541
|
-
const group = new
|
|
12635
|
+
const group = new Node14(ctx.base, "rest", id);
|
|
12542
12636
|
const name = formatGlobalResourceName({
|
|
12543
12637
|
appName: ctx.app.name,
|
|
12544
12638
|
resourceType: "rest",
|
|
12545
12639
|
resourceName: id
|
|
12546
12640
|
});
|
|
12547
|
-
const api = new
|
|
12641
|
+
const api = new aws15.apiGatewayV2.Api(group, "api", {
|
|
12548
12642
|
name,
|
|
12549
12643
|
protocolType: "HTTP"
|
|
12550
12644
|
});
|
|
12551
|
-
const stage = new
|
|
12645
|
+
const stage = new aws15.apiGatewayV2.Stage(group, "stage", {
|
|
12552
12646
|
name: "v1",
|
|
12553
12647
|
apiId: api.id
|
|
12554
12648
|
});
|
|
@@ -12557,7 +12651,7 @@ var restFeature = defineFeature({
|
|
|
12557
12651
|
const domainName = formatFullDomainName(ctx.appConfig, props.domain, props.subDomain);
|
|
12558
12652
|
const hostedZoneId = ctx.shared.get(`hosted-zone-${props.domain}-id`);
|
|
12559
12653
|
const certificateArn = ctx.shared.get(`certificate-${props.domain}-arn`);
|
|
12560
|
-
const domain = new
|
|
12654
|
+
const domain = new aws15.apiGatewayV2.DomainName(group, "domain", {
|
|
12561
12655
|
name: domainName,
|
|
12562
12656
|
certificates: [
|
|
12563
12657
|
{
|
|
@@ -12565,12 +12659,12 @@ var restFeature = defineFeature({
|
|
|
12565
12659
|
}
|
|
12566
12660
|
]
|
|
12567
12661
|
});
|
|
12568
|
-
const mapping = new
|
|
12662
|
+
const mapping = new aws15.apiGatewayV2.ApiMapping(group, "mapping", {
|
|
12569
12663
|
apiId: api.id,
|
|
12570
12664
|
domainName: domain.name,
|
|
12571
12665
|
stage: stage.name
|
|
12572
12666
|
});
|
|
12573
|
-
const record = new
|
|
12667
|
+
const record = new aws15.route53.RecordSet(group, "record", {
|
|
12574
12668
|
hostedZoneId,
|
|
12575
12669
|
type: "A",
|
|
12576
12670
|
name: domainName,
|
|
@@ -12588,21 +12682,21 @@ var restFeature = defineFeature({
|
|
|
12588
12682
|
},
|
|
12589
12683
|
onStack(ctx) {
|
|
12590
12684
|
for (const [id, routes] of Object.entries(ctx.stackConfig.rest ?? {})) {
|
|
12591
|
-
const restGroup = new
|
|
12685
|
+
const restGroup = new Node14(ctx.stack, "rest", id);
|
|
12592
12686
|
for (const [routeKey, props] of Object.entries(routes)) {
|
|
12593
|
-
const group = new
|
|
12687
|
+
const group = new Node14(restGroup, "route", routeKey);
|
|
12594
12688
|
const apiId = ctx.shared.get(`rest-${id}-id`);
|
|
12595
12689
|
const routeId = shortId(routeKey);
|
|
12596
12690
|
const { lambda } = createLambdaFunction(group, ctx, "rest", `${id}-${routeId}`, {
|
|
12597
12691
|
...props,
|
|
12598
12692
|
description: `${id} ${routeKey}`
|
|
12599
12693
|
});
|
|
12600
|
-
const permission = new
|
|
12694
|
+
const permission = new aws15.lambda.Permission(group, "permission", {
|
|
12601
12695
|
action: "lambda:InvokeFunction",
|
|
12602
12696
|
principal: "apigateway.amazonaws.com",
|
|
12603
12697
|
functionArn: lambda.arn
|
|
12604
12698
|
});
|
|
12605
|
-
const integration = new
|
|
12699
|
+
const integration = new aws15.apiGatewayV2.Integration(group, "integration", {
|
|
12606
12700
|
apiId,
|
|
12607
12701
|
description: `${id} ${routeKey}`,
|
|
12608
12702
|
method: "POST",
|
|
@@ -12612,7 +12706,7 @@ var restFeature = defineFeature({
|
|
|
12612
12706
|
return `arn:aws:apigateway:${ctx.appConfig.region}:lambda:path/2015-03-31/functions/${arn}/invocations`;
|
|
12613
12707
|
})
|
|
12614
12708
|
});
|
|
12615
|
-
const route = new
|
|
12709
|
+
const route = new aws15.apiGatewayV2.Route(group, "route", {
|
|
12616
12710
|
apiId,
|
|
12617
12711
|
routeKey,
|
|
12618
12712
|
target: integration.id.apply((id2) => `integrations/${id2}`)
|
|
@@ -12625,13 +12719,13 @@ var restFeature = defineFeature({
|
|
|
12625
12719
|
|
|
12626
12720
|
// src/feature/rpc/index.ts
|
|
12627
12721
|
import { camelCase as camelCase6, constantCase as constantCase9, paramCase as paramCase6 } from "change-case";
|
|
12628
|
-
import { aws as
|
|
12722
|
+
import { aws as aws17, Node as Node16, Output as Output3 } from "@awsless/formation";
|
|
12629
12723
|
import { mebibytes as mebibytes2 } from "@awsless/size";
|
|
12630
12724
|
import { dirname as dirname10, join as join8, relative as relative5 } from "path";
|
|
12631
12725
|
import { fileURLToPath } from "node:url";
|
|
12632
12726
|
|
|
12633
12727
|
// src/feature/function/prebuild.ts
|
|
12634
|
-
import { Asset as Asset4, aws as
|
|
12728
|
+
import { Asset as Asset4, aws as aws16 } from "@awsless/formation";
|
|
12635
12729
|
var createPrebuildLambdaFunction = (group, ctx, ns, id, local2) => {
|
|
12636
12730
|
let name;
|
|
12637
12731
|
if ("stack" in ctx) {
|
|
@@ -12653,21 +12747,21 @@ var createPrebuildLambdaFunction = (group, ctx, ns, id, local2) => {
|
|
|
12653
12747
|
runtime: "nodejs20.x",
|
|
12654
12748
|
...local2
|
|
12655
12749
|
};
|
|
12656
|
-
const code = new
|
|
12750
|
+
const code = new aws16.s3.BucketObject(group, "code", {
|
|
12657
12751
|
bucket: ctx.shared.get("function-bucket-name"),
|
|
12658
12752
|
key: `/lambda/${name}.zip`,
|
|
12659
12753
|
body: Asset4.fromFile(props.bundleFile)
|
|
12660
12754
|
});
|
|
12661
|
-
const role = new
|
|
12755
|
+
const role = new aws16.iam.Role(group, "role", {
|
|
12662
12756
|
name,
|
|
12663
12757
|
assumedBy: "lambda.amazonaws.com"
|
|
12664
12758
|
});
|
|
12665
|
-
const policy = new
|
|
12759
|
+
const policy = new aws16.iam.RolePolicy(group, "policy", {
|
|
12666
12760
|
role: role.name,
|
|
12667
12761
|
name: "lambda-policy",
|
|
12668
12762
|
version: "2012-10-17"
|
|
12669
12763
|
});
|
|
12670
|
-
const lambda = new
|
|
12764
|
+
const lambda = new aws16.lambda.Function(group, `function`, {
|
|
12671
12765
|
...props,
|
|
12672
12766
|
name,
|
|
12673
12767
|
role: role.arn,
|
|
@@ -12677,7 +12771,7 @@ var createPrebuildLambdaFunction = (group, ctx, ns, id, local2) => {
|
|
|
12677
12771
|
vpc: void 0,
|
|
12678
12772
|
log: props.log
|
|
12679
12773
|
});
|
|
12680
|
-
new
|
|
12774
|
+
new aws16.lambda.SourceCodeUpdate(group, "update", {
|
|
12681
12775
|
functionName: lambda.name,
|
|
12682
12776
|
version: Asset4.fromFile(props.bundleHash),
|
|
12683
12777
|
architecture: props.architecture,
|
|
@@ -12693,7 +12787,7 @@ var createPrebuildLambdaFunction = (group, ctx, ns, id, local2) => {
|
|
|
12693
12787
|
lambda.addEnvironment("STACK", ctx.stackConfig.name);
|
|
12694
12788
|
}
|
|
12695
12789
|
if (props.log?.retention && props.log?.retention?.value > 0n) {
|
|
12696
|
-
const logGroup = new
|
|
12790
|
+
const logGroup = new aws16.cloudWatch.LogGroup(group, "log", {
|
|
12697
12791
|
name: lambda.name.apply((name2) => `/aws/lambda/${name2}`),
|
|
12698
12792
|
retention: props.log.retention
|
|
12699
12793
|
});
|
|
@@ -12712,7 +12806,7 @@ var createPrebuildLambdaFunction = (group, ctx, ns, id, local2) => {
|
|
|
12712
12806
|
policy.addStatement(...local2.permissions);
|
|
12713
12807
|
}
|
|
12714
12808
|
if (props.warm) {
|
|
12715
|
-
const rule = new
|
|
12809
|
+
const rule = new aws16.events.Rule(group, "warm", {
|
|
12716
12810
|
name: `${name}--warm`,
|
|
12717
12811
|
schedule: "rate(5 minutes)",
|
|
12718
12812
|
enabled: true,
|
|
@@ -12727,7 +12821,7 @@ var createPrebuildLambdaFunction = (group, ctx, ns, id, local2) => {
|
|
|
12727
12821
|
}
|
|
12728
12822
|
]
|
|
12729
12823
|
});
|
|
12730
|
-
new
|
|
12824
|
+
new aws16.lambda.Permission(group, `warm`, {
|
|
12731
12825
|
action: "lambda:InvokeFunction",
|
|
12732
12826
|
principal: "events.amazonaws.com",
|
|
12733
12827
|
functionArn: lambda.arn,
|
|
@@ -12742,7 +12836,7 @@ var createPrebuildLambdaFunction = (group, ctx, ns, id, local2) => {
|
|
|
12742
12836
|
ctx.shared.get(`vpc-public-subnet-id-2`)
|
|
12743
12837
|
]
|
|
12744
12838
|
});
|
|
12745
|
-
const vpcPolicy = new
|
|
12839
|
+
const vpcPolicy = new aws16.iam.RolePolicy(group, "vpc-policy", {
|
|
12746
12840
|
role: role.name,
|
|
12747
12841
|
name: "lambda-vpc-policy",
|
|
12748
12842
|
version: "2012-10-17",
|
|
@@ -12776,6 +12870,9 @@ var rpcFeature = defineFeature({
|
|
|
12776
12870
|
name: "rpc",
|
|
12777
12871
|
async onTypeGen(ctx) {
|
|
12778
12872
|
const types2 = new TypeFile("@awsless/awsless/client");
|
|
12873
|
+
types2.addCode(`type Input<T> = Parameters<T>[0]`);
|
|
12874
|
+
types2.addCode(`type Output<T> = Promise<ReturnType<T>>`);
|
|
12875
|
+
types2.addCode(`type Handle<T> = (input:Input<T>) => Output<T>`);
|
|
12779
12876
|
const schemas = new TypeObject(1);
|
|
12780
12877
|
for (const id of Object.keys(ctx.appConfig.defaults.rpc ?? {})) {
|
|
12781
12878
|
const schema = new TypeObject(2);
|
|
@@ -12784,7 +12881,7 @@ var rpcFeature = defineFeature({
|
|
|
12784
12881
|
const relFile = relative5(directories.types, props.file);
|
|
12785
12882
|
const varName = camelCase6(`${stack.name}-${name}`);
|
|
12786
12883
|
types2.addImport(varName, relFile);
|
|
12787
|
-
schema.addType(name, `
|
|
12884
|
+
schema.addType(name, `Handle<typeof ${varName}>`);
|
|
12788
12885
|
}
|
|
12789
12886
|
}
|
|
12790
12887
|
schemas.addType(id, schema);
|
|
@@ -12794,7 +12891,7 @@ var rpcFeature = defineFeature({
|
|
|
12794
12891
|
},
|
|
12795
12892
|
onApp(ctx) {
|
|
12796
12893
|
for (const [id, props] of Object.entries(ctx.appConfig.defaults.rpc ?? {})) {
|
|
12797
|
-
const group = new
|
|
12894
|
+
const group = new Node16(ctx.base, "rpc", id);
|
|
12798
12895
|
const name = formatGlobalResourceName({
|
|
12799
12896
|
appName: ctx.app.name,
|
|
12800
12897
|
resourceType: "rpc",
|
|
@@ -12803,7 +12900,8 @@ var rpcFeature = defineFeature({
|
|
|
12803
12900
|
const { lambda } = createPrebuildLambdaFunction(group, ctx, "rpc", id, {
|
|
12804
12901
|
bundleFile: join8(__dirname, "/prebuild/rpc/bundle.zip"),
|
|
12805
12902
|
bundleHash: join8(__dirname, "/prebuild/rpc/HASH"),
|
|
12806
|
-
memorySize: mebibytes2(256)
|
|
12903
|
+
memorySize: mebibytes2(256),
|
|
12904
|
+
warm: 3
|
|
12807
12905
|
});
|
|
12808
12906
|
const schema = {};
|
|
12809
12907
|
lambda.addEnvironment(
|
|
@@ -12816,40 +12914,49 @@ var rpcFeature = defineFeature({
|
|
|
12816
12914
|
);
|
|
12817
12915
|
ctx.shared.set(`rpc-${id}-schema`, schema);
|
|
12818
12916
|
if (props.auth) {
|
|
12819
|
-
const authGroup = new
|
|
12917
|
+
const authGroup = new Node16(group, "auth", "authorizer");
|
|
12820
12918
|
const auth2 = createLambdaFunction(authGroup, ctx, "rpc", `${id}-auth`, props.auth);
|
|
12821
12919
|
lambda.addEnvironment("AUTH", auth2.lambda.name);
|
|
12822
12920
|
}
|
|
12823
|
-
const permission = new
|
|
12921
|
+
const permission = new aws17.lambda.Permission(group, "permission", {
|
|
12824
12922
|
principal: "*",
|
|
12825
12923
|
action: "lambda:InvokeFunctionUrl",
|
|
12826
12924
|
functionArn: lambda.arn,
|
|
12827
12925
|
urlAuthType: "none"
|
|
12828
12926
|
});
|
|
12829
|
-
const url = new
|
|
12927
|
+
const url = new aws17.lambda.Url(group, "url-2", {
|
|
12830
12928
|
targetArn: lambda.arn,
|
|
12831
|
-
authType: "none"
|
|
12929
|
+
authType: "none",
|
|
12930
|
+
cors: {
|
|
12931
|
+
allow: {
|
|
12932
|
+
origins: ["*"],
|
|
12933
|
+
methods: ["*"],
|
|
12934
|
+
headers: ["Authentication", "Content-Type"]
|
|
12935
|
+
// credentials: true,
|
|
12936
|
+
}
|
|
12937
|
+
}
|
|
12832
12938
|
}).dependsOn(permission);
|
|
12833
12939
|
const domainName = props.domain ? formatFullDomainName(ctx.appConfig, props.domain, props.subDomain) : void 0;
|
|
12834
12940
|
const certificateArn = props.domain ? ctx.shared.get(`global-certificate-${props.domain}-arn`) : void 0;
|
|
12835
|
-
const cache = new
|
|
12941
|
+
const cache = new aws17.cloudFront.CachePolicy(group, "cache", {
|
|
12836
12942
|
name,
|
|
12837
12943
|
minTtl: seconds3(1),
|
|
12838
12944
|
maxTtl: days5(365),
|
|
12839
12945
|
defaultTtl: days5(1)
|
|
12840
12946
|
});
|
|
12841
|
-
const originRequest = new
|
|
12947
|
+
const originRequest = new aws17.cloudFront.OriginRequestPolicy(group, "request", {
|
|
12842
12948
|
name,
|
|
12843
12949
|
header: {
|
|
12844
12950
|
behavior: "all-except",
|
|
12845
|
-
values: ["
|
|
12951
|
+
values: ["Host"]
|
|
12846
12952
|
}
|
|
12847
12953
|
});
|
|
12848
|
-
const cdn = new
|
|
12954
|
+
const cdn = new aws17.cloudFront.Distribution(group, "cdn-2", {
|
|
12849
12955
|
name,
|
|
12850
12956
|
compress: true,
|
|
12851
12957
|
certificateArn,
|
|
12852
12958
|
viewerProtocol: "https-only",
|
|
12959
|
+
allowMethod: ["GET", "HEAD", "OPTIONS", "PUT", "PATCH", "POST", "DELETE"],
|
|
12853
12960
|
aliases: domainName ? [domainName] : void 0,
|
|
12854
12961
|
origins: [
|
|
12855
12962
|
{
|
|
@@ -12861,11 +12968,10 @@ var rpcFeature = defineFeature({
|
|
|
12861
12968
|
targetOriginId: "default",
|
|
12862
12969
|
cachePolicyId: cache.id,
|
|
12863
12970
|
originRequestPolicyId: originRequest.id
|
|
12864
|
-
// responseHeadersPolicyId: responseHeaders.id,
|
|
12865
12971
|
});
|
|
12866
12972
|
if (props.domain) {
|
|
12867
12973
|
const fullDomainName = formatFullDomainName(ctx.appConfig, props.domain, props.subDomain);
|
|
12868
|
-
new
|
|
12974
|
+
new aws17.route53.RecordSet(group, "record", {
|
|
12869
12975
|
hostedZoneId: ctx.shared.get(`hosted-zone-${props.domain}-id`),
|
|
12870
12976
|
type: "A",
|
|
12871
12977
|
name: fullDomainName,
|
|
@@ -12884,9 +12990,9 @@ var rpcFeature = defineFeature({
|
|
|
12884
12990
|
throw new FileError(ctx.stackConfig.file, `RPC definition is not defined on app level for "${id}"`);
|
|
12885
12991
|
}
|
|
12886
12992
|
const schema = ctx.shared.get(`rpc-${id}-schema`);
|
|
12887
|
-
const group = new
|
|
12993
|
+
const group = new Node16(ctx.stack, "rpc", id);
|
|
12888
12994
|
for (const [name, props] of Object.entries(queries ?? {})) {
|
|
12889
|
-
const queryGroup = new
|
|
12995
|
+
const queryGroup = new Node16(group, "query", name);
|
|
12890
12996
|
const entryId = paramCase6(`${id}-${shortId(name)}`);
|
|
12891
12997
|
const lambda = createLambdaFunction(queryGroup, ctx, `rpc`, entryId, {
|
|
12892
12998
|
...props,
|
|
@@ -12899,7 +13005,7 @@ var rpcFeature = defineFeature({
|
|
|
12899
13005
|
});
|
|
12900
13006
|
|
|
12901
13007
|
// src/feature/search/index.ts
|
|
12902
|
-
import { aws as
|
|
13008
|
+
import { aws as aws18, Node as Node17 } from "@awsless/formation";
|
|
12903
13009
|
import { constantCase as constantCase10 } from "change-case";
|
|
12904
13010
|
var typeGenCode4 = `
|
|
12905
13011
|
import { AnyStruct, Table } from '@awsless/open-search'
|
|
@@ -12927,9 +13033,9 @@ var searchFeature = defineFeature({
|
|
|
12927
13033
|
},
|
|
12928
13034
|
onStack(ctx) {
|
|
12929
13035
|
for (const [id, props] of Object.entries(ctx.stackConfig.searchs ?? {})) {
|
|
12930
|
-
const group = new
|
|
13036
|
+
const group = new Node17(ctx.stack, "search", id);
|
|
12931
13037
|
const name = `${id}-${shortId([ctx.app.name, ctx.stack.name, this.name, id].join("--"))}`;
|
|
12932
|
-
const openSearch = new
|
|
13038
|
+
const openSearch = new aws18.openSearch.Domain(group, "domain", {
|
|
12933
13039
|
name,
|
|
12934
13040
|
version: props.version,
|
|
12935
13041
|
storageSize: props.storage,
|
|
@@ -12969,7 +13075,7 @@ var searchFeature = defineFeature({
|
|
|
12969
13075
|
|
|
12970
13076
|
// src/feature/site/index.ts
|
|
12971
13077
|
import { days as days6, seconds as seconds4 } from "@awsless/duration";
|
|
12972
|
-
import { Asset as Asset5, aws as
|
|
13078
|
+
import { Asset as Asset5, aws as aws19, Node as Node18 } from "@awsless/formation";
|
|
12973
13079
|
import { glob as glob2 } from "glob";
|
|
12974
13080
|
import { join as join9 } from "path";
|
|
12975
13081
|
|
|
@@ -12999,7 +13105,7 @@ var siteFeature = defineFeature({
|
|
|
12999
13105
|
name: "site",
|
|
13000
13106
|
onStack(ctx) {
|
|
13001
13107
|
for (const [id, props] of Object.entries(ctx.stackConfig.sites ?? {})) {
|
|
13002
|
-
const group = new
|
|
13108
|
+
const group = new Node18(ctx.stack, "site", id);
|
|
13003
13109
|
const name = formatLocalResourceName({
|
|
13004
13110
|
appName: ctx.app.name,
|
|
13005
13111
|
stackName: ctx.stack.name,
|
|
@@ -13018,7 +13124,7 @@ var siteFeature = defineFeature({
|
|
|
13018
13124
|
ctx.onBind((name2, value) => {
|
|
13019
13125
|
lambda.addEnvironment(name2, value);
|
|
13020
13126
|
});
|
|
13021
|
-
new
|
|
13127
|
+
new aws19.lambda.Permission(group, "permission", {
|
|
13022
13128
|
principal: "*",
|
|
13023
13129
|
// principal: 'cloudfront.amazonaws.com',
|
|
13024
13130
|
action: "lambda:InvokeFunctionUrl",
|
|
@@ -13027,7 +13133,7 @@ var siteFeature = defineFeature({
|
|
|
13027
13133
|
// urlAuthType: 'aws-iam',
|
|
13028
13134
|
// sourceArn: distribution.arn,
|
|
13029
13135
|
});
|
|
13030
|
-
const url = new
|
|
13136
|
+
const url = new aws19.lambda.Url(group, "url", {
|
|
13031
13137
|
targetArn: lambda.arn,
|
|
13032
13138
|
authType: "none"
|
|
13033
13139
|
// authType: 'aws-iam',
|
|
@@ -13039,7 +13145,7 @@ var siteFeature = defineFeature({
|
|
|
13039
13145
|
});
|
|
13040
13146
|
}
|
|
13041
13147
|
if (props.static) {
|
|
13042
|
-
bucket = new
|
|
13148
|
+
bucket = new aws19.s3.Bucket(group, "bucket", {
|
|
13043
13149
|
name: formatLocalResourceName({
|
|
13044
13150
|
appName: ctx.app.name,
|
|
13045
13151
|
stackName: ctx.stack.name,
|
|
@@ -13065,7 +13171,7 @@ var siteFeature = defineFeature({
|
|
|
13065
13171
|
policy.addStatement(bucket.permissions);
|
|
13066
13172
|
});
|
|
13067
13173
|
bucket.deletionPolicy = "after-deployment";
|
|
13068
|
-
const accessControl = new
|
|
13174
|
+
const accessControl = new aws19.cloudFront.OriginAccessControl(group, `access`, {
|
|
13069
13175
|
name,
|
|
13070
13176
|
type: "s3",
|
|
13071
13177
|
behavior: "always",
|
|
@@ -13077,7 +13183,7 @@ var siteFeature = defineFeature({
|
|
|
13077
13183
|
nodir: true
|
|
13078
13184
|
});
|
|
13079
13185
|
for (const file of files) {
|
|
13080
|
-
const object = new
|
|
13186
|
+
const object = new aws19.s3.BucketObject(group, file, {
|
|
13081
13187
|
bucket: bucket.name,
|
|
13082
13188
|
key: file,
|
|
13083
13189
|
body: Asset5.fromFile(join9(props.static, file)),
|
|
@@ -13100,21 +13206,21 @@ var siteFeature = defineFeature({
|
|
|
13100
13206
|
statusCodes: [403, 404]
|
|
13101
13207
|
});
|
|
13102
13208
|
}
|
|
13103
|
-
const cache = new
|
|
13209
|
+
const cache = new aws19.cloudFront.CachePolicy(group, "cache", {
|
|
13104
13210
|
name,
|
|
13105
13211
|
minTtl: seconds4(1),
|
|
13106
13212
|
maxTtl: days6(365),
|
|
13107
13213
|
defaultTtl: days6(1),
|
|
13108
13214
|
...props.cache
|
|
13109
13215
|
});
|
|
13110
|
-
const originRequest = new
|
|
13216
|
+
const originRequest = new aws19.cloudFront.OriginRequestPolicy(group, "request", {
|
|
13111
13217
|
name,
|
|
13112
13218
|
header: {
|
|
13113
13219
|
behavior: "all-except",
|
|
13114
13220
|
values: ["host", "authorization"]
|
|
13115
13221
|
}
|
|
13116
13222
|
});
|
|
13117
|
-
const responseHeaders = new
|
|
13223
|
+
const responseHeaders = new aws19.cloudFront.ResponseHeadersPolicy(group, "response", {
|
|
13118
13224
|
name,
|
|
13119
13225
|
cors: props.cors,
|
|
13120
13226
|
remove: ["server"]
|
|
@@ -13124,7 +13230,7 @@ var siteFeature = defineFeature({
|
|
|
13124
13230
|
});
|
|
13125
13231
|
const domainName = props.domain ? formatFullDomainName(ctx.appConfig, props.domain, props.subDomain) : void 0;
|
|
13126
13232
|
const certificateArn = props.domain ? ctx.shared.get(`global-certificate-${props.domain}-arn`) : void 0;
|
|
13127
|
-
const distribution = new
|
|
13233
|
+
const distribution = new aws19.cloudFront.Distribution(group, "distribution", {
|
|
13128
13234
|
name,
|
|
13129
13235
|
compress: true,
|
|
13130
13236
|
certificateArn,
|
|
@@ -13152,13 +13258,13 @@ var siteFeature = defineFeature({
|
|
|
13152
13258
|
};
|
|
13153
13259
|
})
|
|
13154
13260
|
});
|
|
13155
|
-
new
|
|
13261
|
+
new aws19.cloudFront.InvalidateCache(group, "invalidate", {
|
|
13156
13262
|
distributionId: distribution.id,
|
|
13157
13263
|
paths: ["/*"],
|
|
13158
13264
|
versions
|
|
13159
13265
|
});
|
|
13160
13266
|
if (props.static) {
|
|
13161
|
-
new
|
|
13267
|
+
new aws19.s3.BucketPolicy(group, `policy`, {
|
|
13162
13268
|
bucketName: bucket.name,
|
|
13163
13269
|
statements: [
|
|
13164
13270
|
{
|
|
@@ -13185,7 +13291,7 @@ var siteFeature = defineFeature({
|
|
|
13185
13291
|
});
|
|
13186
13292
|
}
|
|
13187
13293
|
if (domainName) {
|
|
13188
|
-
new
|
|
13294
|
+
new aws19.route53.RecordSet(group, `record`, {
|
|
13189
13295
|
hostedZoneId: ctx.shared.get(`hosted-zone-${props.domain}-id`),
|
|
13190
13296
|
type: "A",
|
|
13191
13297
|
name: domainName,
|
|
@@ -13201,7 +13307,7 @@ var siteFeature = defineFeature({
|
|
|
13201
13307
|
});
|
|
13202
13308
|
|
|
13203
13309
|
// src/feature/store/index.ts
|
|
13204
|
-
import { aws as
|
|
13310
|
+
import { aws as aws20, Node as Node19 } from "@awsless/formation";
|
|
13205
13311
|
import { paramCase as paramCase7 } from "change-case";
|
|
13206
13312
|
var typeGenCode5 = `
|
|
13207
13313
|
import { Body, PutObjectProps, BodyStream } from '@awsless/s3'
|
|
@@ -13238,7 +13344,7 @@ var storeFeature = defineFeature({
|
|
|
13238
13344
|
},
|
|
13239
13345
|
onStack(ctx) {
|
|
13240
13346
|
for (const [id, props] of Object.entries(ctx.stackConfig.stores ?? {})) {
|
|
13241
|
-
const group = new
|
|
13347
|
+
const group = new Node19(ctx.stack, "store", id);
|
|
13242
13348
|
const name = formatLocalResourceName({
|
|
13243
13349
|
appName: ctx.app.name,
|
|
13244
13350
|
stackName: ctx.stack.name,
|
|
@@ -13258,13 +13364,13 @@ var storeFeature = defineFeature({
|
|
|
13258
13364
|
"removed:marker": "s3:ObjectRemoved:DeleteMarkerCreated"
|
|
13259
13365
|
};
|
|
13260
13366
|
for (const [event, funcProps] of Object.entries(props.events ?? {})) {
|
|
13261
|
-
const eventGroup = new
|
|
13367
|
+
const eventGroup = new Node19(group, "event", event);
|
|
13262
13368
|
const eventId = paramCase7(`${id}-${shortId(event)}`);
|
|
13263
13369
|
const { lambda } = createAsyncLambdaFunction(eventGroup, ctx, `store`, eventId, {
|
|
13264
13370
|
...funcProps,
|
|
13265
13371
|
description: `${id} event "${event}"`
|
|
13266
13372
|
});
|
|
13267
|
-
new
|
|
13373
|
+
new aws20.lambda.Permission(eventGroup, "permission", {
|
|
13268
13374
|
action: "lambda:InvokeFunction",
|
|
13269
13375
|
principal: "s3.amazonaws.com",
|
|
13270
13376
|
functionArn: lambda.arn,
|
|
@@ -13275,7 +13381,7 @@ var storeFeature = defineFeature({
|
|
|
13275
13381
|
function: lambda.arn
|
|
13276
13382
|
});
|
|
13277
13383
|
}
|
|
13278
|
-
const bucket = new
|
|
13384
|
+
const bucket = new aws20.s3.Bucket(group, "store", {
|
|
13279
13385
|
name,
|
|
13280
13386
|
versioning: props.versioning,
|
|
13281
13387
|
forceDelete: true,
|
|
@@ -13303,24 +13409,24 @@ var storeFeature = defineFeature({
|
|
|
13303
13409
|
});
|
|
13304
13410
|
|
|
13305
13411
|
// src/feature/stream/index.ts
|
|
13306
|
-
import { aws as
|
|
13412
|
+
import { aws as aws21, Node as Node20 } from "@awsless/formation";
|
|
13307
13413
|
import { constantCase as constantCase12 } from "change-case";
|
|
13308
13414
|
var streamFeature = defineFeature({
|
|
13309
13415
|
name: "stream",
|
|
13310
13416
|
onStack(ctx) {
|
|
13311
13417
|
for (const [id, props] of Object.entries(ctx.stackConfig.streams ?? {})) {
|
|
13312
|
-
const group = new
|
|
13418
|
+
const group = new Node20(ctx.stack, "stream", id);
|
|
13313
13419
|
const name = formatLocalResourceName({
|
|
13314
13420
|
appName: ctx.app.name,
|
|
13315
13421
|
stackName: ctx.stack.name,
|
|
13316
13422
|
resourceType: "stream",
|
|
13317
13423
|
resourceName: id
|
|
13318
13424
|
});
|
|
13319
|
-
const channel = new
|
|
13425
|
+
const channel = new aws21.ivs.Channel(group, "channel", {
|
|
13320
13426
|
name,
|
|
13321
13427
|
...props
|
|
13322
13428
|
});
|
|
13323
|
-
const streamKey = new
|
|
13429
|
+
const streamKey = new aws21.ivs.StreamKey(group, "key", {
|
|
13324
13430
|
channel: channel.arn
|
|
13325
13431
|
});
|
|
13326
13432
|
const prefix = `STREAM_${constantCase12(ctx.stack.name)}_${constantCase12(id)}`;
|
|
@@ -13332,7 +13438,7 @@ var streamFeature = defineFeature({
|
|
|
13332
13438
|
});
|
|
13333
13439
|
|
|
13334
13440
|
// src/feature/table/index.ts
|
|
13335
|
-
import { aws as
|
|
13441
|
+
import { aws as aws22, Node as Node21 } from "@awsless/formation";
|
|
13336
13442
|
var tableFeature = defineFeature({
|
|
13337
13443
|
name: "table",
|
|
13338
13444
|
async onTypeGen(ctx) {
|
|
@@ -13356,7 +13462,7 @@ var tableFeature = defineFeature({
|
|
|
13356
13462
|
},
|
|
13357
13463
|
onStack(ctx) {
|
|
13358
13464
|
for (const [id, props] of Object.entries(ctx.stackConfig.tables ?? {})) {
|
|
13359
|
-
const group = new
|
|
13465
|
+
const group = new Node21(ctx.stack, "table", id);
|
|
13360
13466
|
const name = formatLocalResourceName({
|
|
13361
13467
|
appName: ctx.app.name,
|
|
13362
13468
|
stackName: ctx.stack.name,
|
|
@@ -13364,7 +13470,7 @@ var tableFeature = defineFeature({
|
|
|
13364
13470
|
resourceName: id
|
|
13365
13471
|
});
|
|
13366
13472
|
const deletionProtection = props.deletionProtection ?? ctx.appConfig.defaults.table?.deletionProtection;
|
|
13367
|
-
const table2 = new
|
|
13473
|
+
const table2 = new aws22.dynamodb.Table(group, "table", {
|
|
13368
13474
|
...props,
|
|
13369
13475
|
name,
|
|
13370
13476
|
stream: props.stream?.type,
|
|
@@ -13377,7 +13483,7 @@ var tableFeature = defineFeature({
|
|
|
13377
13483
|
const { lambda, policy } = createLambdaFunction(group, ctx, "table", id, props.stream.consumer);
|
|
13378
13484
|
lambda.addEnvironment("LOG_VIEWABLE_ERROR", "1");
|
|
13379
13485
|
const onFailure = getGlobalOnFailure(ctx);
|
|
13380
|
-
const source = new
|
|
13486
|
+
const source = new aws22.lambda.EventSourceMapping(group, id, {
|
|
13381
13487
|
functionArn: lambda.arn,
|
|
13382
13488
|
sourceArn: table2.streamArn,
|
|
13383
13489
|
batchSize: 100,
|
|
@@ -13404,7 +13510,7 @@ var tableFeature = defineFeature({
|
|
|
13404
13510
|
});
|
|
13405
13511
|
|
|
13406
13512
|
// src/feature/task/index.ts
|
|
13407
|
-
import { Node as
|
|
13513
|
+
import { Node as Node22 } from "@awsless/formation";
|
|
13408
13514
|
import { camelCase as camelCase7 } from "change-case";
|
|
13409
13515
|
import { relative as relative6 } from "path";
|
|
13410
13516
|
var typeGenCode6 = `
|
|
@@ -13466,7 +13572,7 @@ var taskFeature = defineFeature({
|
|
|
13466
13572
|
},
|
|
13467
13573
|
onStack(ctx) {
|
|
13468
13574
|
for (const [id, props] of Object.entries(ctx.stackConfig.tasks ?? {})) {
|
|
13469
|
-
const group = new
|
|
13575
|
+
const group = new Node22(ctx.stack, "task", id);
|
|
13470
13576
|
createAsyncLambdaFunction(group, ctx, "task", id, props.consumer);
|
|
13471
13577
|
}
|
|
13472
13578
|
}
|
|
@@ -13483,7 +13589,7 @@ var testFeature = defineFeature({
|
|
|
13483
13589
|
});
|
|
13484
13590
|
|
|
13485
13591
|
// src/feature/topic/index.ts
|
|
13486
|
-
import { aws as
|
|
13592
|
+
import { aws as aws23, Node as Node23 } from "@awsless/formation";
|
|
13487
13593
|
var typeGenCode7 = `
|
|
13488
13594
|
import type { PublishOptions } from '@awsless/sns'
|
|
13489
13595
|
import type { Mock } from 'vitest'
|
|
@@ -13524,13 +13630,13 @@ var topicFeature = defineFeature({
|
|
|
13524
13630
|
onApp(ctx) {
|
|
13525
13631
|
for (const stack of ctx.stackConfigs) {
|
|
13526
13632
|
for (const id of stack.topics ?? []) {
|
|
13527
|
-
const group = new
|
|
13633
|
+
const group = new Node23(ctx.base, "topic", id);
|
|
13528
13634
|
const name = formatGlobalResourceName({
|
|
13529
13635
|
appName: ctx.appConfig.name,
|
|
13530
13636
|
resourceType: "topic",
|
|
13531
13637
|
resourceName: id
|
|
13532
13638
|
});
|
|
13533
|
-
const topic = new
|
|
13639
|
+
const topic = new aws23.sns.Topic(group, "topic", {
|
|
13534
13640
|
name
|
|
13535
13641
|
});
|
|
13536
13642
|
ctx.shared.set(`topic-${id}-arn`, topic.arn);
|
|
@@ -13547,22 +13653,22 @@ var topicFeature = defineFeature({
|
|
|
13547
13653
|
});
|
|
13548
13654
|
}
|
|
13549
13655
|
for (const [id, props] of Object.entries(ctx.stackConfig.subscribers ?? {})) {
|
|
13550
|
-
const group = new
|
|
13656
|
+
const group = new Node23(ctx.stack, "topic", id);
|
|
13551
13657
|
const topicArn = ctx.shared.get(`topic-${id}-arn`);
|
|
13552
13658
|
if (typeof props === "string" && isEmail(props)) {
|
|
13553
|
-
new
|
|
13659
|
+
new aws23.sns.Subscription(group, id, {
|
|
13554
13660
|
topicArn,
|
|
13555
13661
|
protocol: "email",
|
|
13556
13662
|
endpoint: props
|
|
13557
13663
|
});
|
|
13558
13664
|
} else if (typeof props === "object") {
|
|
13559
13665
|
const { lambda } = createAsyncLambdaFunction(group, ctx, `topic`, id, props);
|
|
13560
|
-
new
|
|
13666
|
+
new aws23.sns.Subscription(group, id, {
|
|
13561
13667
|
topicArn,
|
|
13562
13668
|
protocol: "lambda",
|
|
13563
13669
|
endpoint: lambda.arn
|
|
13564
13670
|
});
|
|
13565
|
-
new
|
|
13671
|
+
new aws23.lambda.Permission(group, id, {
|
|
13566
13672
|
action: "lambda:InvokeFunction",
|
|
13567
13673
|
principal: "sns.amazonaws.com",
|
|
13568
13674
|
functionArn: lambda.arn,
|
|
@@ -13574,36 +13680,36 @@ var topicFeature = defineFeature({
|
|
|
13574
13680
|
});
|
|
13575
13681
|
|
|
13576
13682
|
// src/feature/vpc/index.ts
|
|
13577
|
-
import { aws as
|
|
13683
|
+
import { aws as aws24, combine as combine2, Node as Node24 } from "@awsless/formation";
|
|
13578
13684
|
var vpcFeature = defineFeature({
|
|
13579
13685
|
name: "vpc",
|
|
13580
13686
|
onApp(ctx) {
|
|
13581
|
-
const group = new
|
|
13582
|
-
const vpc = new
|
|
13687
|
+
const group = new Node24(ctx.base, "vpc", "main");
|
|
13688
|
+
const vpc = new aws24.ec2.Vpc(group, "vpc", {
|
|
13583
13689
|
name: ctx.app.name,
|
|
13584
|
-
cidrBlock:
|
|
13690
|
+
cidrBlock: aws24.ec2.Peer.ipv4("10.0.0.0/16")
|
|
13585
13691
|
// cidrBlock: aws.ec2.Peer.ipv6('fd00:10:20::/48'),
|
|
13586
13692
|
// cidrBlock: aws.ec2.Peer.ipv6('2a05:d018:c69:6600::/56'),
|
|
13587
13693
|
// enableDnsSupport: true,
|
|
13588
13694
|
// enableDnsHostnames: true,
|
|
13589
13695
|
});
|
|
13590
|
-
const privateRouteTable = new
|
|
13696
|
+
const privateRouteTable = new aws24.ec2.RouteTable(group, "private", {
|
|
13591
13697
|
vpcId: vpc.id,
|
|
13592
13698
|
name: "private"
|
|
13593
13699
|
});
|
|
13594
|
-
const publicRouteTable = new
|
|
13700
|
+
const publicRouteTable = new aws24.ec2.RouteTable(group, "public", {
|
|
13595
13701
|
vpcId: vpc.id,
|
|
13596
13702
|
name: "public"
|
|
13597
13703
|
});
|
|
13598
|
-
const gateway = new
|
|
13599
|
-
const attachment = new
|
|
13704
|
+
const gateway = new aws24.ec2.InternetGateway(group, "gateway");
|
|
13705
|
+
const attachment = new aws24.ec2.VPCGatewayAttachment(group, "attachment", {
|
|
13600
13706
|
vpcId: vpc.id,
|
|
13601
13707
|
internetGatewayId: gateway.id
|
|
13602
13708
|
});
|
|
13603
|
-
new
|
|
13709
|
+
new aws24.ec2.Route(group, "route", {
|
|
13604
13710
|
gatewayId: gateway.id,
|
|
13605
13711
|
routeTableId: publicRouteTable.id,
|
|
13606
|
-
destination:
|
|
13712
|
+
destination: aws24.ec2.Peer.anyIpv4()
|
|
13607
13713
|
// destination: aws.ec2.Peer.anyIpv6(),
|
|
13608
13714
|
});
|
|
13609
13715
|
ctx.shared.set(
|
|
@@ -13619,10 +13725,10 @@ var vpcFeature = defineFeature({
|
|
|
13619
13725
|
for (const i in zones) {
|
|
13620
13726
|
const index = Number(i) + 1;
|
|
13621
13727
|
const id = `${table2.identifier}-${index}`;
|
|
13622
|
-
const subnet = new
|
|
13728
|
+
const subnet = new aws24.ec2.Subnet(group, id, {
|
|
13623
13729
|
name: `${ctx.app.name}--${table2.identifier}-${index}`,
|
|
13624
13730
|
vpcId: vpc.id,
|
|
13625
|
-
cidrBlock:
|
|
13731
|
+
cidrBlock: aws24.ec2.Peer.ipv4(`10.0.${block++}.0/24`),
|
|
13626
13732
|
// ipv6CidrBlock: aws.ec2.Peer.ipv6(`fd00:10:20:${++block}::/64`),
|
|
13627
13733
|
// ipv6CidrBlock: aws.ec2.Peer.ipv6(`2a05:d018:c69:660${++block}::/64`),
|
|
13628
13734
|
// ipv6CidrBlock: ipv6CidrBlock.ipv6CidrBlock.apply(ip => ),
|
|
@@ -13632,7 +13738,7 @@ var vpcFeature = defineFeature({
|
|
|
13632
13738
|
mapPublicIpOnLaunch: table2.identifier === "public",
|
|
13633
13739
|
availabilityZone: ctx.appConfig.region + zones[i]
|
|
13634
13740
|
});
|
|
13635
|
-
new
|
|
13741
|
+
new aws24.ec2.SubnetRouteTableAssociation(group, id, {
|
|
13636
13742
|
routeTableId: table2.id,
|
|
13637
13743
|
subnetId: subnet.id
|
|
13638
13744
|
});
|
|
@@ -13670,6 +13776,9 @@ var features = [
|
|
|
13670
13776
|
httpFeature,
|
|
13671
13777
|
restFeature,
|
|
13672
13778
|
siteFeature,
|
|
13779
|
+
// 4
|
|
13780
|
+
logSubscriptionFeature,
|
|
13781
|
+
// I think needs to be after s3 feature
|
|
13673
13782
|
rpcFeature
|
|
13674
13783
|
];
|
|
13675
13784
|
|