@awsless/awsless 0.0.539 → 0.0.541

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 CHANGED
@@ -606,7 +606,7 @@ var debug = (...parts) => {
606
606
  };
607
607
 
608
608
  // src/config/app.ts
609
- import { z as z24 } from "zod";
609
+ import { z as z25 } from "zod";
610
610
 
611
611
  // src/feature/alert/schema.ts
612
612
  import { kebabCase } from "change-case";
@@ -840,7 +840,7 @@ var LogRetentionSchema = DurationSchema.refine(
840
840
  (duration) => {
841
841
  return validLogRetentionDays.includes(toDays(duration));
842
842
  },
843
- `Invalid log retention. Valid days are: ${validLogRetentionDays.map((days8) => `${days8}`).join(", ")}`
843
+ `Invalid log retention. Valid days are: ${validLogRetentionDays.map((days9) => `${days9}`).join(", ")}`
844
844
  ).describe("The log retention duration.");
845
845
  var LogSchema = z14.union([
846
846
  z14.boolean().transform((enabled) => ({ retention: enabled ? days(7) : days(0) })),
@@ -1145,8 +1145,159 @@ var RpcDefaultSchema = z22.record(
1145
1145
  ).describe(`Define the global RPC API's.`).optional();
1146
1146
  var RpcSchema = z22.record(ResourceIdSchema, z22.record(z22.string(), FunctionSchema).describe("The queries for your global RPC API.")).describe("Define the schema in your stack for your global RPC API.").optional();
1147
1147
 
1148
- // src/config/schema/region.ts
1148
+ // src/feature/instance/schema.ts
1149
+ import { days as days3, toDays as toDays2 } from "@awsless/duration";
1149
1150
  import { z as z23 } from "zod";
1151
+ var CpuSizeSchema = z23.union([
1152
+ z23.literal("0.25 vCPU"),
1153
+ z23.literal("0.5 vCPU"),
1154
+ z23.literal("1 vCPU"),
1155
+ z23.literal("2 vCPU"),
1156
+ z23.literal("4 vCPU"),
1157
+ z23.literal("8 vCPU"),
1158
+ z23.literal("16 vCPU")
1159
+ ]).describe(
1160
+ "The number of vCPU units used by the task. For tasks using the Fargate launch type, this field is required. Valid values: 0.25, 0.5, 1, 2, 4, 8, 16 vCPU."
1161
+ );
1162
+ var MemorySizeSchema2 = z23.union([
1163
+ // 0.25 vCPU
1164
+ z23.literal(512),
1165
+ z23.literal(1024),
1166
+ z23.literal(2048),
1167
+ // 0.5 vCPU
1168
+ z23.literal(1024),
1169
+ z23.literal(2048),
1170
+ z23.literal(3072),
1171
+ z23.literal(4096),
1172
+ // 1 vCPU
1173
+ z23.literal(2048),
1174
+ z23.literal(3072),
1175
+ z23.literal(4096),
1176
+ z23.literal(5120),
1177
+ z23.literal(6144),
1178
+ z23.literal(7168),
1179
+ z23.literal(8192),
1180
+ // 2 vCPU
1181
+ z23.literal(4096),
1182
+ z23.literal(5120),
1183
+ z23.literal(6144),
1184
+ z23.literal(7168),
1185
+ z23.literal(8192),
1186
+ z23.literal(9216),
1187
+ z23.literal(10240),
1188
+ z23.literal(11264),
1189
+ z23.literal(12288),
1190
+ z23.literal(13312),
1191
+ z23.literal(14336),
1192
+ z23.literal(15360),
1193
+ z23.literal(16384)
1194
+ ]).describe(
1195
+ "The amount of memory (in MiB) used by the task. For tasks using the Fargate launch type, this field is required and must be compatible with the CPU value. Valid memory values depend on the CPU configuration."
1196
+ );
1197
+ var HealthCheckSchema = z23.object({
1198
+ command: z23.union([z23.string(), z23.string().array()]).describe("The command that the container runs to determine if it is healthy."),
1199
+ interval: DurationSchema.describe("The time period in seconds between each health check execution."),
1200
+ retries: z23.number().int().min(1).max(10).describe(
1201
+ "The number of times to retry a failed health check before the container is considered unhealthy."
1202
+ ),
1203
+ startPeriod: DurationSchema.describe(
1204
+ "The optional grace period to provide containers time to bootstrap before failed health checks count towards the maximum number of retries."
1205
+ ),
1206
+ timeout: DurationSchema.describe(
1207
+ "The time period in seconds to wait for a health check to succeed before it is considered a failure."
1208
+ )
1209
+ }).describe("The health check command and associated configuration parameters for the container.");
1210
+ var RestartPolicySchema = z23.object({
1211
+ enabled: z23.boolean().describe("Whether to enable the restart policy for the container."),
1212
+ ignoredExitCodes: z23.number().int().array().optional().describe("A list of exit codes that Amazon ECS will ignore and not attempt a restart against."),
1213
+ restartAttemptPeriod: z23.number().int().min(0).max(1800).optional().describe(
1214
+ "A period of time (in seconds) that the container must run for before a restart can be attempted. A container can be restarted only once every restartAttemptPeriod seconds. If a container isn't able to run for this time period and exits early, it will not be restarted. You can set a minimum restartAttemptPeriod of 60 seconds and a maximum restartAttemptPeriod of 1800 seconds."
1215
+ )
1216
+ }).describe("The restart policy for the container. This parameter maps to the --restart option to docker run.");
1217
+ var EnvironmentSchema2 = z23.record(z23.string(), z23.string()).optional().describe("Environment variable key-value pairs.");
1218
+ var ArchitectureSchema3 = z23.enum(["x86_64", "arm64"]).describe("The instruction set architecture that the function supports.");
1219
+ var ActionSchema2 = z23.string();
1220
+ var ActionsSchema2 = z23.union([ActionSchema2.transform((v) => [v]), ActionSchema2.array()]);
1221
+ var ArnSchema2 = z23.string().startsWith("arn:");
1222
+ var WildcardSchema2 = z23.literal("*");
1223
+ var ResourceSchema2 = z23.union([ArnSchema2, WildcardSchema2]);
1224
+ var ResourcesSchema2 = z23.union([ResourceSchema2.transform((v) => [v]), ResourceSchema2.array()]);
1225
+ var PermissionSchema2 = z23.object({
1226
+ effect: z23.enum(["allow", "deny"]).default("allow"),
1227
+ actions: ActionsSchema2,
1228
+ resources: ResourcesSchema2
1229
+ });
1230
+ var PermissionsSchema2 = z23.union([PermissionSchema2.transform((v) => [v]), PermissionSchema2.array()]).describe("Add IAM permissions to your function.");
1231
+ var MinifySchema2 = z23.boolean().describe("Minify the function code.");
1232
+ var DescriptionSchema2 = z23.string().describe("A description of the function.");
1233
+ var ImageSchema = z23.string().optional().describe("The URL of the container image to use.");
1234
+ var validLogRetentionDays2 = [
1235
+ ...[1, 3, 5, 7, 14, 30, 60, 90, 120, 150],
1236
+ ...[180, 365, 400, 545, 731, 1096, 1827, 2192],
1237
+ ...[2557, 2922, 3288, 3653]
1238
+ ];
1239
+ var LogRetentionSchema2 = DurationSchema.refine(
1240
+ durationMin(days3(0)),
1241
+ "Minimum log retention is 0 day, which will disable logging."
1242
+ ).refine(
1243
+ (duration) => {
1244
+ return validLogRetentionDays2.includes(toDays2(duration));
1245
+ },
1246
+ `Invalid log retention. Valid days are: ${validLogRetentionDays2.map((days9) => `${days9}`).join(", ")}`
1247
+ ).describe("The log retention duration.");
1248
+ var LogSchema2 = z23.union([
1249
+ z23.boolean().transform((enabled) => ({ retention: enabled ? days3(7) : days3(0) })),
1250
+ LogRetentionSchema2.transform((retention) => ({ retention })),
1251
+ z23.object({
1252
+ retention: LogRetentionSchema2.optional()
1253
+ })
1254
+ ]).describe("Enable logging to a CloudWatch log group. Providing a duration value will set the log retention time.");
1255
+ var FileCodeSchema2 = z23.object({
1256
+ file: LocalFileSchema.describe("The file path of the function code."),
1257
+ minify: MinifySchema2.optional().default(true)
1258
+ });
1259
+ var CodeSchema2 = z23.union([
1260
+ LocalFileSchema.transform((file) => ({
1261
+ file
1262
+ })).pipe(FileCodeSchema2),
1263
+ FileCodeSchema2
1264
+ ]).describe("Specify the code of your instance.");
1265
+ var ISchema = z23.object({
1266
+ code: CodeSchema2,
1267
+ description: DescriptionSchema2.optional(),
1268
+ image: ImageSchema.optional(),
1269
+ log: LogSchema2.optional(),
1270
+ memorySize: MemorySizeSchema2.optional(),
1271
+ cpuSize: CpuSizeSchema.optional(),
1272
+ architecture: ArchitectureSchema3.optional(),
1273
+ environment: EnvironmentSchema2.optional(),
1274
+ permissions: PermissionsSchema2.optional(),
1275
+ healthCheck: HealthCheckSchema.optional(),
1276
+ restartPolicy: RestartPolicySchema.optional()
1277
+ });
1278
+ var InstanceSchema = z23.union([
1279
+ LocalFileSchema.transform((code) => ({
1280
+ code
1281
+ })).pipe(ISchema),
1282
+ ISchema
1283
+ ]);
1284
+ var InstancesSchema = z23.record(ResourceIdSchema, InstanceSchema).optional().describe("Define the instances in your stack.");
1285
+ var InstanceDefaultSchema = z23.object({
1286
+ image: ImageSchema.default("public.ecr.aws/aws-cli/aws-cli:amd64"),
1287
+ memorySize: MemorySizeSchema2.default(512),
1288
+ cpuSize: CpuSizeSchema.default("0.25 vCPU"),
1289
+ architecture: ArchitectureSchema3.default("arm64"),
1290
+ environment: EnvironmentSchema2.optional(),
1291
+ permissions: PermissionsSchema2.optional(),
1292
+ healthCheck: HealthCheckSchema.optional(),
1293
+ restartPolicy: RestartPolicySchema.default({ enabled: true }),
1294
+ log: LogSchema2.default(true).transform((log25) => ({
1295
+ retention: log25.retention ?? days3(7)
1296
+ }))
1297
+ }).default({});
1298
+
1299
+ // src/config/schema/region.ts
1300
+ import { z as z24 } from "zod";
1150
1301
  var US = ["us-east-2", "us-east-1", "us-west-1", "us-west-2"];
1151
1302
  var AF = ["af-south-1"];
1152
1303
  var AP = [
@@ -1175,16 +1326,16 @@ var EU = [
1175
1326
  var ME = ["me-south-1", "me-central-1"];
1176
1327
  var SA = ["sa-east-1"];
1177
1328
  var regions = [...US, ...AF, ...AP, ...CA, ...EU, ...ME, ...SA];
1178
- var RegionSchema = z23.enum(regions);
1329
+ var RegionSchema = z24.enum(regions);
1179
1330
 
1180
1331
  // src/config/app.ts
1181
- var AppSchema = z24.object({
1182
- $schema: z24.string().optional(),
1332
+ var AppSchema = z25.object({
1333
+ $schema: z25.string().optional(),
1183
1334
  name: ResourceIdSchema.describe("App name."),
1184
1335
  region: RegionSchema.describe("The AWS region to deploy to."),
1185
- profile: z24.string().describe("The AWS profile to deploy to."),
1186
- protect: z24.boolean().default(false).describe("Protect your app & stacks from being deleted."),
1187
- removal: z24.enum(["remove", "retain"]).default("remove").describe(
1336
+ profile: z25.string().describe("The AWS profile to deploy to."),
1337
+ protect: z25.boolean().default(false).describe("Protect your app & stacks from being deleted."),
1338
+ removal: z25.enum(["remove", "retain"]).default("remove").describe(
1188
1339
  [
1189
1340
  "Configure how your resources are handled when they have to be removed.",
1190
1341
  "",
@@ -1198,13 +1349,13 @@ var AppSchema = z24.object({
1198
1349
  // .default('prod')
1199
1350
  // .describe('The deployment stage.'),
1200
1351
  // onFailure: OnFailureSchema,
1201
- defaults: z24.object({
1352
+ defaults: z25.object({
1202
1353
  onFailure: OnFailureDefaultSchema,
1203
1354
  onLog: OnLogDefaultSchema,
1204
1355
  auth: AuthDefaultSchema,
1205
1356
  domains: DomainsDefaultSchema,
1206
1357
  function: FunctionDefaultSchema,
1207
- // instance: InstanceDefaultSchema,
1358
+ instance: InstanceDefaultSchema,
1208
1359
  queue: QueueDefaultSchema,
1209
1360
  // graphql: GraphQLDefaultSchema,
1210
1361
  // http: HttpDefaultSchema,
@@ -1220,11 +1371,11 @@ var AppSchema = z24.object({
1220
1371
  });
1221
1372
 
1222
1373
  // src/config/stack.ts
1223
- import { z as z40 } from "zod";
1374
+ import { z as z41 } from "zod";
1224
1375
 
1225
1376
  // src/feature/cache/schema.ts
1226
1377
  import { gibibytes as gibibytes2 } from "@awsless/size";
1227
- import { z as z25 } from "zod";
1378
+ import { z as z26 } from "zod";
1228
1379
  var StorageSchema = SizeSchema.refine(sizeMin(gibibytes2(1)), "Minimum storage size is 1 GB").refine(
1229
1380
  sizeMax(gibibytes2(5e3)),
1230
1381
  "Maximum storage size is 5000 GB"
@@ -1235,31 +1386,31 @@ var MinimumStorageSchema = StorageSchema.describe(
1235
1386
  var MaximumStorageSchema = StorageSchema.describe(
1236
1387
  "The upper limit for data storage the cache is set to use. You can specify a size value from 1 GB to 5000 GB."
1237
1388
  );
1238
- var EcpuSchema = z25.number().int().min(1e3).max(15e6);
1389
+ var EcpuSchema = z26.number().int().min(1e3).max(15e6);
1239
1390
  var MinimumEcpuSchema = EcpuSchema.describe(
1240
1391
  "The minimum number of ECPUs the cache can consume per second. You can specify a integer from 1,000 to 15,000,000."
1241
1392
  );
1242
1393
  var MaximumEcpuSchema = EcpuSchema.describe(
1243
1394
  "The maximum number of ECPUs the cache can consume per second. You can specify a integer from 1,000 to 15,000,000."
1244
1395
  );
1245
- var CachesSchema = z25.record(
1396
+ var CachesSchema = z26.record(
1246
1397
  ResourceIdSchema,
1247
- z25.object({
1398
+ z26.object({
1248
1399
  minStorage: MinimumStorageSchema.optional(),
1249
1400
  maxStorage: MaximumStorageSchema.optional(),
1250
1401
  minECPU: MinimumEcpuSchema.optional(),
1251
1402
  maxECPU: MaximumEcpuSchema.optional(),
1252
- snapshotRetentionLimit: z25.number().int().positive().default(1)
1403
+ snapshotRetentionLimit: z26.number().int().positive().default(1)
1253
1404
  })
1254
1405
  ).optional().describe("Define the caches in your stack. For access to the cache put your functions inside the global VPC.");
1255
1406
 
1256
1407
  // src/feature/command/schema.ts
1257
- import { z as z26 } from "zod";
1258
- var CommandSchema = z26.union([
1259
- z26.object({
1408
+ import { z as z27 } from "zod";
1409
+ var CommandSchema = z27.union([
1410
+ z27.object({
1260
1411
  file: LocalFileSchema,
1261
- handler: z26.string().default("default").describe("The name of the handler that needs to run"),
1262
- description: z26.string().optional().describe("A description of the command")
1412
+ handler: z27.string().default("default").describe("The name of the handler that needs to run"),
1413
+ description: z27.string().optional().describe("A description of the command")
1263
1414
  // options: z.record(ResourceIdSchema, OptionSchema).optional(),
1264
1415
  // arguments: z.record(ResourceIdSchema, ArgumentSchema).optional(),
1265
1416
  }),
@@ -1269,22 +1420,22 @@ var CommandSchema = z26.union([
1269
1420
  description: void 0
1270
1421
  }))
1271
1422
  ]);
1272
- var CommandsSchema = z26.record(ResourceIdSchema, CommandSchema).optional().describe("Define the custom commands for your stack.");
1423
+ var CommandsSchema = z27.record(ResourceIdSchema, CommandSchema).optional().describe("Define the custom commands for your stack.");
1273
1424
 
1274
1425
  // src/feature/config/schema.ts
1275
- import { z as z27 } from "zod";
1276
- var ConfigNameSchema = z27.string().regex(/[a-z0-9\-]/g, "Invalid config name");
1277
- var ConfigsSchema = z27.array(ConfigNameSchema).optional().describe("Define the config values for your stack.");
1426
+ import { z as z28 } from "zod";
1427
+ var ConfigNameSchema = z28.string().regex(/[a-z0-9\-]/g, "Invalid config name");
1428
+ var ConfigsSchema = z28.array(ConfigNameSchema).optional().describe("Define the config values for your stack.");
1278
1429
 
1279
1430
  // src/feature/cron/schema/index.ts
1280
- import { z as z29 } from "zod";
1431
+ import { z as z30 } from "zod";
1281
1432
 
1282
1433
  // src/feature/cron/schema/schedule.ts
1283
- import { z as z28 } from "zod";
1434
+ import { z as z29 } from "zod";
1284
1435
  import { awsCronExpressionValidator } from "aws-cron-expression-validator";
1285
- var RateExpressionSchema = z28.custom(
1436
+ var RateExpressionSchema = z29.custom(
1286
1437
  (value) => {
1287
- return z28.string().regex(/^[0-9]+ (seconds?|minutes?|hours?|days?)$/).refine((rate) => {
1438
+ return z29.string().regex(/^[0-9]+ (seconds?|minutes?|hours?|days?)$/).refine((rate) => {
1288
1439
  const [str] = rate.split(" ");
1289
1440
  const number = parseInt(str);
1290
1441
  return number > 0;
@@ -1300,9 +1451,9 @@ var RateExpressionSchema = z28.custom(
1300
1451
  }
1301
1452
  return `rate(${rate})`;
1302
1453
  });
1303
- var CronExpressionSchema = z28.custom(
1454
+ var CronExpressionSchema = z29.custom(
1304
1455
  (value) => {
1305
- return z28.string().safeParse(value).success;
1456
+ return z29.string().safeParse(value).success;
1306
1457
  },
1307
1458
  { message: "Invalid cron expression" }
1308
1459
  ).superRefine((value, ctx) => {
@@ -1311,12 +1462,12 @@ var CronExpressionSchema = z28.custom(
1311
1462
  } catch (error) {
1312
1463
  if (error instanceof Error) {
1313
1464
  ctx.addIssue({
1314
- code: z28.ZodIssueCode.custom,
1465
+ code: z29.ZodIssueCode.custom,
1315
1466
  message: `Invalid cron expression: ${error.message}`
1316
1467
  });
1317
1468
  } else {
1318
1469
  ctx.addIssue({
1319
- code: z28.ZodIssueCode.custom,
1470
+ code: z29.ZodIssueCode.custom,
1320
1471
  message: "Invalid cron expression"
1321
1472
  });
1322
1473
  }
@@ -1327,28 +1478,28 @@ var CronExpressionSchema = z28.custom(
1327
1478
  var ScheduleExpressionSchema = RateExpressionSchema.or(CronExpressionSchema);
1328
1479
 
1329
1480
  // src/feature/cron/schema/index.ts
1330
- var CronsSchema = z29.record(
1481
+ var CronsSchema = z30.record(
1331
1482
  ResourceIdSchema,
1332
- z29.object({
1333
- enabled: z29.boolean().default(true).describe("If the cron is enabled."),
1483
+ z30.object({
1484
+ enabled: z30.boolean().default(true).describe("If the cron is enabled."),
1334
1485
  consumer: FunctionSchema.describe("The consuming lambda function properties."),
1335
1486
  schedule: ScheduleExpressionSchema.describe(
1336
1487
  'The scheduling expression.\n\nexample: "0 20 * * ? *"\nexample: "5 minutes"'
1337
1488
  ),
1338
- payload: z29.unknown().optional().describe("The JSON payload that will be passed to the consumer.")
1489
+ payload: z30.unknown().optional().describe("The JSON payload that will be passed to the consumer.")
1339
1490
  })
1340
1491
  ).optional().describe(`Define the cron jobs in your stack.`);
1341
1492
 
1342
1493
  // src/feature/search/schema.ts
1343
1494
  import { gibibytes as gibibytes3 } from "@awsless/size";
1344
- import { z as z30 } from "zod";
1345
- var VersionSchema = z30.union([
1495
+ import { z as z31 } from "zod";
1496
+ var VersionSchema = z31.union([
1346
1497
  //
1347
- z30.enum(["2.13", "2.11", "2.9", "2.7", "2.5", "2.3", "1.3"]),
1348
- z30.string()
1498
+ z31.enum(["2.13", "2.11", "2.9", "2.7", "2.5", "2.3", "1.3"]),
1499
+ z31.string()
1349
1500
  ]).describe("Specify the OpenSearch engine version.");
1350
- var TypeSchema = z30.union([
1351
- z30.enum([
1501
+ var TypeSchema = z31.union([
1502
+ z31.enum([
1352
1503
  "t3.small",
1353
1504
  "t3.medium",
1354
1505
  "m3.medium",
@@ -1422,13 +1573,13 @@ var TypeSchema = z30.union([
1422
1573
  "r6gd.12xlarge",
1423
1574
  "r6gd.16xlarge"
1424
1575
  ]),
1425
- z30.string()
1576
+ z31.string()
1426
1577
  ]).describe("Instance type of data nodes in the cluster.");
1427
- var CountSchema = z30.number().int().min(1).describe("Number of instances in the cluster.");
1578
+ var CountSchema = z31.number().int().min(1).describe("Number of instances in the cluster.");
1428
1579
  var StorageSizeSchema = SizeSchema.refine(sizeMin(gibibytes3(10)), "Minimum storage size is 10 GB").refine(sizeMax(gibibytes3(100)), "Maximum storage size is 100 GB").describe("The size of the function's /tmp directory. You can specify a size value from 512 MB to 10 GiB.");
1429
- var SearchsSchema = z30.record(
1580
+ var SearchsSchema = z31.record(
1430
1581
  ResourceIdSchema,
1431
- z30.object({
1582
+ z31.object({
1432
1583
  type: TypeSchema.default("t3.small"),
1433
1584
  count: CountSchema.default(1),
1434
1585
  version: VersionSchema.default("2.13"),
@@ -1439,12 +1590,12 @@ var SearchsSchema = z30.record(
1439
1590
  ).optional().describe("Define the search instances in your stack. Backed by OpenSearch.");
1440
1591
 
1441
1592
  // src/feature/site/schema.ts
1442
- import { z as z32 } from "zod";
1593
+ import { z as z33 } from "zod";
1443
1594
 
1444
1595
  // src/config/schema/local-entry.ts
1445
1596
  import { stat as stat3 } from "fs/promises";
1446
- import { z as z31 } from "zod";
1447
- var LocalEntrySchema = z31.union([
1597
+ import { z as z32 } from "zod";
1598
+ var LocalEntrySchema = z32.union([
1448
1599
  RelativePathSchema.refine(async (path) => {
1449
1600
  try {
1450
1601
  const s = await stat3(path);
@@ -1453,7 +1604,7 @@ var LocalEntrySchema = z31.union([
1453
1604
  return false;
1454
1605
  }
1455
1606
  }, `File or directory doesn't exist`),
1456
- z31.object({
1607
+ z32.object({
1457
1608
  nocheck: RelativePathSchema.describe(
1458
1609
  "Specifies a local file or directory without checking if the file or directory exists."
1459
1610
  )
@@ -1461,14 +1612,14 @@ var LocalEntrySchema = z31.union([
1461
1612
  ]);
1462
1613
 
1463
1614
  // src/feature/site/schema.ts
1464
- var ErrorResponsePathSchema = z32.string().describe(
1615
+ var ErrorResponsePathSchema = z33.string().describe(
1465
1616
  [
1466
1617
  "The path to the custom error page that you want to return to the viewer when your origin returns the HTTP status code specified.",
1467
1618
  "- We recommend that you store custom error pages in an Amazon S3 bucket.",
1468
1619
  "If you store custom error pages on an HTTP server and the server starts to return 5xx errors, CloudFront can't get the files that you want to return to viewers because the origin server is unavailable."
1469
1620
  ].join("\n")
1470
1621
  );
1471
- var StatusCodeSchema = z32.number().int().positive().optional().describe(
1622
+ var StatusCodeSchema = z33.number().int().positive().optional().describe(
1472
1623
  [
1473
1624
  "The HTTP status code that you want CloudFront to return to the viewer along with the custom error page.",
1474
1625
  "There are a variety of reasons that you might want CloudFront to return a status code different from the status code that your origin returned to CloudFront, for example:",
@@ -1481,19 +1632,19 @@ var StatusCodeSchema = z32.number().int().positive().optional().describe(
1481
1632
  var MinTTLSchema = DurationSchema.describe(
1482
1633
  "The minimum amount of time, that you want to cache the error response. When this time period has elapsed, CloudFront queries your origin to see whether the problem that caused the error has been resolved and the requested object is now available."
1483
1634
  );
1484
- var ErrorResponseSchema = z32.union([
1635
+ var ErrorResponseSchema = z33.union([
1485
1636
  ErrorResponsePathSchema,
1486
- z32.object({
1637
+ z33.object({
1487
1638
  path: ErrorResponsePathSchema,
1488
1639
  statusCode: StatusCodeSchema.optional(),
1489
1640
  minTTL: MinTTLSchema.optional()
1490
1641
  })
1491
1642
  ]).optional();
1492
- var SitesSchema = z32.record(
1643
+ var SitesSchema = z33.record(
1493
1644
  ResourceIdSchema,
1494
- z32.object({
1645
+ z33.object({
1495
1646
  domain: ResourceIdSchema.describe("The domain id to link your site with.").optional(),
1496
- subDomain: z32.string().optional(),
1647
+ subDomain: z33.string().optional(),
1497
1648
  // bind: z
1498
1649
  // .object({
1499
1650
  // auth: z.array(ResourceIdSchema),
@@ -1502,16 +1653,16 @@ var SitesSchema = z32.record(
1502
1653
  // // rest: z.array(ResourceIdSchema),
1503
1654
  // })
1504
1655
  // .optional(),
1505
- build: z32.object({
1506
- command: z32.string().describe(
1656
+ build: z33.object({
1657
+ command: z33.string().describe(
1507
1658
  `Specifies the files and directories to generate the cache key for your custom build command.`
1508
1659
  ),
1509
- cacheKey: z32.union([LocalEntrySchema.transform((v) => [v]), LocalEntrySchema.array()]).describe(
1660
+ cacheKey: z33.union([LocalEntrySchema.transform((v) => [v]), LocalEntrySchema.array()]).describe(
1510
1661
  `Specifies the files and directories to generate the cache key for your custom build command.`
1511
1662
  ),
1512
- configs: z32.string().array().describe("Define the config values for your build command.")
1663
+ configs: z33.string().array().describe("Define the config values for your build command.")
1513
1664
  }).optional().describe(`Specifies the build process for sites that need a build step.`),
1514
- static: z32.union([LocalDirectorySchema, z32.boolean()]).optional().describe(
1665
+ static: z33.union([LocalDirectorySchema, z33.boolean()]).optional().describe(
1515
1666
  "Specifies the path to the static files directory. Additionally you can also pass `true` when you don't have local static files, but still want to make an S3 bucket."
1516
1667
  ),
1517
1668
  ssr: FunctionSchema.optional().describe("Specifies the file that will render the site on the server."),
@@ -1532,7 +1683,7 @@ var SitesSchema = z32.record(
1532
1683
  // build: z.string().optional(),
1533
1684
  // }),
1534
1685
  // ]),
1535
- geoRestrictions: z32.array(z32.string().length(2).toUpperCase()).default([]).describe("Specifies a blacklist of countries that should be blocked."),
1686
+ geoRestrictions: z33.array(z33.string().length(2).toUpperCase()).default([]).describe("Specifies a blacklist of countries that should be blocked."),
1536
1687
  // forwardHost: z
1537
1688
  // .boolean()
1538
1689
  // .default(false)
@@ -1543,7 +1694,7 @@ var SitesSchema = z32.record(
1543
1694
  // 'Keep in mind that this requires an extra CloudFront Function.',
1544
1695
  // ].join('\n')
1545
1696
  // ),
1546
- errors: z32.object({
1697
+ errors: z33.object({
1547
1698
  400: ErrorResponseSchema.describe("Customize a `400 Bad Request` response."),
1548
1699
  403: ErrorResponseSchema.describe("Customize a `403 Forbidden` response."),
1549
1700
  404: ErrorResponseSchema.describe("Customize a `404 Not Found` response."),
@@ -1556,20 +1707,20 @@ var SitesSchema = z32.record(
1556
1707
  503: ErrorResponseSchema.describe("Customize a `503 Service Unavailable` response."),
1557
1708
  504: ErrorResponseSchema.describe("Customize a `504 Gateway Timeout` response.")
1558
1709
  }).optional().describe("Customize the error responses for specific HTTP status codes."),
1559
- cors: z32.object({
1560
- override: z32.boolean().default(false),
1710
+ cors: z33.object({
1711
+ override: z33.boolean().default(false),
1561
1712
  maxAge: DurationSchema.default("365 days"),
1562
- exposeHeaders: z32.string().array().optional(),
1563
- credentials: z32.boolean().default(false),
1564
- headers: z32.string().array().default(["*"]),
1565
- origins: z32.string().array().default(["*"]),
1566
- methods: z32.enum(["GET", "DELETE", "HEAD", "OPTIONS", "PATCH", "POST", "PUT", "ALL"]).array().default(["ALL"])
1713
+ exposeHeaders: z33.string().array().optional(),
1714
+ credentials: z33.boolean().default(false),
1715
+ headers: z33.string().array().default(["*"]),
1716
+ origins: z33.string().array().default(["*"]),
1717
+ methods: z33.enum(["GET", "DELETE", "HEAD", "OPTIONS", "PATCH", "POST", "PUT", "ALL"]).array().default(["ALL"])
1567
1718
  }).optional().describe("Specify the cors headers."),
1568
- auth: z32.object({
1569
- username: z32.string().describe("Basic auth username"),
1570
- password: z32.string().describe("Basic auth password")
1719
+ auth: z33.object({
1720
+ username: z33.string().describe("Basic auth username"),
1721
+ password: z33.string().describe("Basic auth password")
1571
1722
  }).optional().describe("Enable basic authentication for the site"),
1572
- security: z32.object({
1723
+ security: z33.object({
1573
1724
  // contentSecurityPolicy: z.object({
1574
1725
  // override: z.boolean().default(false),
1575
1726
  // policy: z.string(),
@@ -1611,10 +1762,10 @@ var SitesSchema = z32.record(
1611
1762
  // reportUri?: string
1612
1763
  // }
1613
1764
  }).optional().describe("Specify the security policy."),
1614
- cache: z32.object({
1615
- cookies: z32.string().array().optional().describe("Specifies the cookies that CloudFront includes in the cache key."),
1616
- headers: z32.string().array().optional().describe("Specifies the headers that CloudFront includes in the cache key."),
1617
- queries: z32.string().array().optional().describe("Specifies the query values that CloudFront includes in the cache key.")
1765
+ cache: z33.object({
1766
+ cookies: z33.string().array().optional().describe("Specifies the cookies that CloudFront includes in the cache key."),
1767
+ headers: z33.string().array().optional().describe("Specifies the headers that CloudFront includes in the cache key."),
1768
+ queries: z33.string().array().optional().describe("Specifies the query values that CloudFront includes in the cache key.")
1618
1769
  }).optional().describe(
1619
1770
  "Specifies the cookies, headers, and query values that CloudFront includes in the cache key."
1620
1771
  )
@@ -1622,22 +1773,22 @@ var SitesSchema = z32.record(
1622
1773
  ).optional().describe("Define the sites in your stack.");
1623
1774
 
1624
1775
  // src/feature/store/schema.ts
1625
- import { z as z33 } from "zod";
1626
- var StoresSchema = z33.union([
1627
- z33.array(ResourceIdSchema).transform((list3) => {
1776
+ import { z as z34 } from "zod";
1777
+ var StoresSchema = z34.union([
1778
+ z34.array(ResourceIdSchema).transform((list3) => {
1628
1779
  const stores = {};
1629
1780
  for (const key of list3) {
1630
1781
  stores[key] = {};
1631
1782
  }
1632
1783
  return stores;
1633
1784
  }),
1634
- z33.record(
1785
+ z34.record(
1635
1786
  ResourceIdSchema,
1636
- z33.object({
1787
+ z34.object({
1637
1788
  // cors: CorsSchema,
1638
1789
  // deletionProtection: DeletionProtectionSchema.optional(),
1639
- versioning: z33.boolean().default(false).describe("Enable versioning of your store."),
1640
- events: z33.object({
1790
+ versioning: z34.boolean().default(false).describe("Enable versioning of your store."),
1791
+ events: z34.object({
1641
1792
  // create
1642
1793
  "created:*": FunctionSchema.optional().describe(
1643
1794
  "Subscribe to notifications regardless of the API that was used to create an object."
@@ -1670,58 +1821,58 @@ var StoresSchema = z33.union([
1670
1821
  ]).optional().describe("Define the stores in your stack.");
1671
1822
 
1672
1823
  // src/feature/icon/schema.ts
1673
- import { z as z34 } from "zod";
1824
+ import { z as z35 } from "zod";
1674
1825
  var staticOriginSchema = LocalDirectorySchema.describe(
1675
1826
  "Specifies the path to a local image directory that will be uploaded in S3."
1676
1827
  );
1677
1828
  var functionOriginSchema = FunctionSchema.describe(
1678
1829
  "Specifies the file that will be called when an image isn't found in the (cache) bucket."
1679
1830
  );
1680
- var IconsSchema = z34.record(
1831
+ var IconsSchema = z35.record(
1681
1832
  ResourceIdSchema,
1682
- z34.object({
1833
+ z35.object({
1683
1834
  domain: ResourceIdSchema.describe("The domain id to link your site with.").optional(),
1684
- subDomain: z34.string().optional(),
1835
+ subDomain: z35.string().optional(),
1685
1836
  log: LogSchema.optional(),
1686
1837
  cacheDuration: DurationSchema.optional().describe("The cache duration of the cached icons."),
1687
- preserveId: z34.boolean().optional().default(false).describe("Preserve the IDs of the icons."),
1688
- symbols: z34.boolean().optional().default(false).describe("Use SVG symbols for icons."),
1689
- origin: z34.union([
1690
- z34.object({
1838
+ preserveId: z35.boolean().optional().default(false).describe("Preserve the IDs of the icons."),
1839
+ symbols: z35.boolean().optional().default(false).describe("Use SVG symbols for icons."),
1840
+ origin: z35.union([
1841
+ z35.object({
1691
1842
  static: staticOriginSchema,
1692
1843
  function: functionOriginSchema.optional()
1693
1844
  }),
1694
- z34.object({
1845
+ z35.object({
1695
1846
  static: staticOriginSchema.optional(),
1696
1847
  function: functionOriginSchema
1697
1848
  }),
1698
- z34.object({
1849
+ z35.object({
1699
1850
  static: staticOriginSchema,
1700
1851
  function: functionOriginSchema
1701
1852
  })
1702
1853
  ]).describe(
1703
1854
  "Image transformation will be applied from a base image. Base images orginates from a local directory that will be uploaded to S3 or from a lambda function."
1704
1855
  ),
1705
- cors: z34.object({
1706
- override: z34.boolean().default(true),
1856
+ cors: z35.object({
1857
+ override: z35.boolean().default(true),
1707
1858
  maxAge: DurationSchema.default("365 days"),
1708
- exposeHeaders: z34.string().array().optional(),
1709
- credentials: z34.boolean().default(false),
1710
- headers: z34.string().array().default(["*"]),
1711
- origins: z34.string().array().default(["*"])
1859
+ exposeHeaders: z35.string().array().optional(),
1860
+ credentials: z35.boolean().default(false),
1861
+ headers: z35.string().array().default(["*"]),
1862
+ origins: z35.string().array().default(["*"])
1712
1863
  }).optional().describe("Specify the cors headers.")
1713
1864
  // version: z.number().int().min(1).optional().describe('Version of the icon configuration.'),
1714
1865
  })
1715
1866
  ).optional().describe("Define an icon proxy in your stack. Store, optimize, and deliver icons at scale.");
1716
1867
 
1717
1868
  // src/feature/image/schema.ts
1718
- import { z as z35 } from "zod";
1719
- var transformationOptionsSchema = z35.object({
1720
- width: z35.number().int().positive().optional(),
1721
- height: z35.number().int().positive().optional(),
1722
- fit: z35.enum(["cover", "contain", "fill", "inside", "outside"]).optional(),
1723
- position: z35.enum(["top", "right top", "right", "right bottom", "bottom", "left bottom", "left", "left top", "center"]).optional(),
1724
- quality: z35.number().int().min(1).max(100).optional()
1869
+ import { z as z36 } from "zod";
1870
+ var transformationOptionsSchema = z36.object({
1871
+ width: z36.number().int().positive().optional(),
1872
+ height: z36.number().int().positive().optional(),
1873
+ fit: z36.enum(["cover", "contain", "fill", "inside", "outside"]).optional(),
1874
+ position: z36.enum(["top", "right top", "right", "right bottom", "bottom", "left bottom", "left", "left top", "center"]).optional(),
1875
+ quality: z36.number().int().min(1).max(100).optional()
1725
1876
  });
1726
1877
  var staticOriginSchema2 = LocalDirectorySchema.describe(
1727
1878
  "Specifies the path to a local image directory that will be uploaded in S3."
@@ -1729,68 +1880,68 @@ var staticOriginSchema2 = LocalDirectorySchema.describe(
1729
1880
  var functionOriginSchema2 = FunctionSchema.describe(
1730
1881
  "Specifies the file that will be called when an image isn't found in the (cache) bucket."
1731
1882
  );
1732
- var ImagesSchema = z35.record(
1883
+ var ImagesSchema = z36.record(
1733
1884
  ResourceIdSchema,
1734
- z35.object({
1885
+ z36.object({
1735
1886
  domain: ResourceIdSchema.describe("The domain id to link your site with.").optional(),
1736
- subDomain: z35.string().optional(),
1887
+ subDomain: z36.string().optional(),
1737
1888
  log: LogSchema.optional(),
1738
1889
  cacheDuration: DurationSchema.optional().describe("Cache duration of the cached images."),
1739
- presets: z35.record(z35.string(), transformationOptionsSchema).describe("Named presets for image transformations"),
1740
- extensions: z35.object({
1741
- jpeg: z35.object({
1742
- mozjpeg: z35.boolean().optional(),
1743
- progressive: z35.boolean().optional()
1890
+ presets: z36.record(z36.string(), transformationOptionsSchema).describe("Named presets for image transformations"),
1891
+ extensions: z36.object({
1892
+ jpeg: z36.object({
1893
+ mozjpeg: z36.boolean().optional(),
1894
+ progressive: z36.boolean().optional()
1744
1895
  }).optional(),
1745
- webp: z35.object({
1746
- effort: z35.number().int().min(1).max(10).default(7).optional(),
1747
- lossless: z35.boolean().optional(),
1748
- nearLossless: z35.boolean().optional()
1896
+ webp: z36.object({
1897
+ effort: z36.number().int().min(1).max(10).default(7).optional(),
1898
+ lossless: z36.boolean().optional(),
1899
+ nearLossless: z36.boolean().optional()
1749
1900
  }).optional(),
1750
- png: z35.object({
1751
- compressionLevel: z35.number().int().min(0).max(9).default(6).optional()
1901
+ png: z36.object({
1902
+ compressionLevel: z36.number().int().min(0).max(9).default(6).optional()
1752
1903
  }).optional()
1753
1904
  }).refine((data) => {
1754
1905
  return Object.keys(data).length > 0;
1755
1906
  }, "At least one extension must be defined.").describe("Specify the allowed extensions."),
1756
- origin: z35.union([
1757
- z35.object({
1907
+ origin: z36.union([
1908
+ z36.object({
1758
1909
  static: staticOriginSchema2,
1759
1910
  function: functionOriginSchema2.optional()
1760
1911
  }),
1761
- z35.object({
1912
+ z36.object({
1762
1913
  static: staticOriginSchema2.optional(),
1763
1914
  function: functionOriginSchema2
1764
1915
  }),
1765
- z35.object({
1916
+ z36.object({
1766
1917
  static: staticOriginSchema2,
1767
1918
  function: functionOriginSchema2
1768
1919
  })
1769
1920
  ]).describe(
1770
1921
  "Specify the origin of your images. Image transformation will be applied from a base image. Base images can be loaded from a S3 bucket (that is synced from a local directory) or dynamicly from a lambda function."
1771
1922
  ),
1772
- version: z35.number().int().min(1).optional().describe("Version of the image configuration.")
1923
+ version: z36.number().int().min(1).optional().describe("Version of the image configuration.")
1773
1924
  })
1774
1925
  ).optional().describe("Define an image proxy in your stack. Store, transform, optimize, and deliver images at scale.");
1775
1926
 
1776
1927
  // src/feature/table/schema.ts
1777
1928
  import { minutes as minutes4, seconds as seconds4 } from "@awsless/duration";
1778
- import { z as z36 } from "zod";
1779
- var KeySchema = z36.string().min(1).max(255);
1780
- var TablesSchema = z36.record(
1929
+ import { z as z37 } from "zod";
1930
+ var KeySchema = z37.string().min(1).max(255);
1931
+ var TablesSchema = z37.record(
1781
1932
  ResourceIdSchema,
1782
- z36.object({
1933
+ z37.object({
1783
1934
  hash: KeySchema.describe(
1784
1935
  "Specifies the name of the partition / hash key that makes up the primary key for the table."
1785
1936
  ),
1786
1937
  sort: KeySchema.optional().describe(
1787
1938
  "Specifies the name of the range / sort key that makes up the primary key for the table."
1788
1939
  ),
1789
- fields: z36.record(z36.string(), z36.enum(["string", "number", "binary"])).optional().describe(
1940
+ fields: z37.record(z37.string(), z37.enum(["string", "number", "binary"])).optional().describe(
1790
1941
  'A list of attributes that describe the key schema for the table and indexes. If no attribute field is defined we default to "string".'
1791
1942
  ),
1792
- class: z36.enum(["standard", "standard-infrequent-access"]).default("standard").describe("The table class of the table."),
1793
- pointInTimeRecovery: z36.boolean().default(false).describe("Indicates whether point in time recovery is enabled on the table."),
1943
+ class: z37.enum(["standard", "standard-infrequent-access"]).default("standard").describe("The table class of the table."),
1944
+ pointInTimeRecovery: z37.boolean().default(false).describe("Indicates whether point in time recovery is enabled on the table."),
1794
1945
  ttl: KeySchema.optional().describe(
1795
1946
  [
1796
1947
  "The name of the TTL attribute used to store the expiration time for items in the table.",
@@ -1798,8 +1949,8 @@ var TablesSchema = z36.record(
1798
1949
  ].join("\n")
1799
1950
  ),
1800
1951
  // deletionProtection: DeletionProtectionSchema.optional(),
1801
- stream: z36.object({
1802
- type: z36.enum(["keys-only", "new-image", "old-image", "new-and-old-images"]).describe(
1952
+ stream: z37.object({
1953
+ type: z37.enum(["keys-only", "new-image", "old-image", "new-and-old-images"]).describe(
1803
1954
  [
1804
1955
  "When an item in the table is modified, you can determines what information is written to the stream for this table.",
1805
1956
  "Valid values are:",
@@ -1809,7 +1960,7 @@ var TablesSchema = z36.record(
1809
1960
  "- new-and-old-images - Both the new and the old item images of the item are written to the stream."
1810
1961
  ].join("\n")
1811
1962
  ),
1812
- batchSize: z36.number().min(1).max(1e4).default(1).describe(
1963
+ batchSize: z37.number().min(1).max(1e4).default(1).describe(
1813
1964
  [
1814
1965
  "The maximum number of records in each batch that Lambda pulls from your stream and sends to your function.",
1815
1966
  "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).",
@@ -1839,7 +1990,7 @@ var TablesSchema = z36.record(
1839
1990
  // 'You can specify a number from -1 to 10000.',
1840
1991
  // ].join('\n')
1841
1992
  // ),
1842
- retryAttempts: z36.number().min(-1).max(1e4).default(-1).describe(
1993
+ retryAttempts: z37.number().min(-1).max(1e4).default(-1).describe(
1843
1994
  [
1844
1995
  "Discard records after the specified number of retries.",
1845
1996
  "The default value is -1, which sets the maximum number of retries to infinite.",
@@ -1847,7 +1998,7 @@ var TablesSchema = z36.record(
1847
1998
  "You can specify a number from -1 to 10000."
1848
1999
  ].join("\n")
1849
2000
  ),
1850
- concurrencyPerShard: z36.number().min(1).max(10).default(1).describe(
2001
+ concurrencyPerShard: z37.number().min(1).max(10).default(1).describe(
1851
2002
  [
1852
2003
  "The number of batches to process concurrently from each shard.",
1853
2004
  "You can specify a number from 1 to 10."
@@ -1857,16 +2008,16 @@ var TablesSchema = z36.record(
1857
2008
  }).optional().describe(
1858
2009
  "The settings for the DynamoDB table stream, which capture changes to items stored in the table."
1859
2010
  ),
1860
- indexes: z36.record(
1861
- z36.string(),
1862
- z36.object({
2011
+ indexes: z37.record(
2012
+ z37.string(),
2013
+ z37.object({
1863
2014
  hash: KeySchema.describe(
1864
2015
  "Specifies the name of the partition / hash key that makes up the primary key for the global secondary index."
1865
2016
  ),
1866
2017
  sort: KeySchema.optional().describe(
1867
2018
  "Specifies the name of the range / sort key that makes up the primary key for the global secondary index."
1868
2019
  ),
1869
- projection: z36.enum(["all", "keys-only"]).default("all").describe(
2020
+ projection: z37.enum(["all", "keys-only"]).default("all").describe(
1870
2021
  [
1871
2022
  "The set of attributes that are projected into the index:",
1872
2023
  "- all - All of the table attributes are projected into the index.",
@@ -1880,11 +2031,11 @@ var TablesSchema = z36.record(
1880
2031
  ).optional().describe("Define the tables in your stack.");
1881
2032
 
1882
2033
  // src/feature/task/schema.ts
1883
- import { z as z37 } from "zod";
1884
- var RetryAttemptsSchema2 = z37.number().int().min(0).max(2).describe(
2034
+ import { z as z38 } from "zod";
2035
+ var RetryAttemptsSchema2 = z38.number().int().min(0).max(2).describe(
1885
2036
  "The maximum number of times to retry when the function returns an error. You can specify a number from 0 to 2."
1886
2037
  );
1887
- var TaskSchema = z37.union([
2038
+ var TaskSchema = z38.union([
1888
2039
  LocalFileSchema.transform((file) => ({
1889
2040
  consumer: {
1890
2041
  code: {
@@ -1895,33 +2046,33 @@ var TaskSchema = z37.union([
1895
2046
  },
1896
2047
  retryAttempts: void 0
1897
2048
  })),
1898
- z37.object({
2049
+ z38.object({
1899
2050
  consumer: FunctionSchema,
1900
2051
  retryAttempts: RetryAttemptsSchema2.optional()
1901
2052
  })
1902
2053
  ]);
1903
- var TasksSchema = z37.record(ResourceIdSchema, TaskSchema).optional().describe("Define the tasks in your stack.");
2054
+ var TasksSchema = z38.record(ResourceIdSchema, TaskSchema).optional().describe("Define the tasks in your stack.");
1904
2055
 
1905
2056
  // src/feature/test/schema.ts
1906
- import { z as z38 } from "zod";
1907
- var TestsSchema = z38.union([LocalDirectorySchema.transform((v) => [v]), LocalDirectorySchema.array()]).describe("Define the location of your tests for your stack.").optional();
2057
+ import { z as z39 } from "zod";
2058
+ var TestsSchema = z39.union([LocalDirectorySchema.transform((v) => [v]), LocalDirectorySchema.array()]).describe("Define the location of your tests for your stack.").optional();
1908
2059
 
1909
2060
  // src/feature/topic/schema.ts
1910
2061
  import { kebabCase as kebabCase3 } from "change-case";
1911
- import { z as z39 } from "zod";
1912
- var TopicNameSchema = z39.string().min(3).max(256).regex(/^[a-z0-9\-]+$/i, "Invalid topic name").transform((value) => kebabCase3(value)).describe("Define event topic name.");
1913
- var TopicsSchema = z39.array(TopicNameSchema).refine((topics) => {
2062
+ import { z as z40 } from "zod";
2063
+ var TopicNameSchema = z40.string().min(3).max(256).regex(/^[a-z0-9\-]+$/i, "Invalid topic name").transform((value) => kebabCase3(value)).describe("Define event topic name.");
2064
+ var TopicsSchema = z40.array(TopicNameSchema).refine((topics) => {
1914
2065
  return topics.length === new Set(topics).size;
1915
2066
  }, "Must be a list of unique topic names").optional().describe("Define the event topics to publish too in your stack.");
1916
- var SubscribersSchema = z39.record(TopicNameSchema, FunctionSchema).optional().describe("Define the event topics to subscribe too in your stack.");
2067
+ var SubscribersSchema = z40.record(TopicNameSchema, FunctionSchema).optional().describe("Define the event topics to subscribe too in your stack.");
1917
2068
 
1918
2069
  // src/config/stack.ts
1919
2070
  var DependsSchema = ResourceIdSchema.array().optional().describe("Define the stacks that this stack is depended on.");
1920
2071
  var NameSchema = ResourceIdSchema.refine((name) => !["base", "hostedzones"].includes(name), {
1921
2072
  message: `Stack name can't be a reserved name.`
1922
2073
  }).describe("Stack name.");
1923
- var StackSchema = z40.object({
1924
- $schema: z40.string().optional(),
2074
+ var StackSchema = z41.object({
2075
+ $schema: z41.string().optional(),
1925
2076
  name: NameSchema,
1926
2077
  depends: DependsSchema,
1927
2078
  commands: CommandsSchema,
@@ -1937,7 +2088,7 @@ var StackSchema = z40.object({
1937
2088
  topics: TopicsSchema,
1938
2089
  subscribers: SubscribersSchema,
1939
2090
  functions: FunctionsSchema,
1940
- // instances: InstancesSchema,
2091
+ instances: InstancesSchema,
1941
2092
  tasks: TasksSchema,
1942
2093
  tables: TablesSchema,
1943
2094
  stores: StoresSchema,
@@ -1990,13 +2141,13 @@ var readConfigWithStage = async (file, stage) => {
1990
2141
  };
1991
2142
 
1992
2143
  // src/config/load/validate.ts
1993
- import { z as z41 } from "zod";
2144
+ import { z as z42 } from "zod";
1994
2145
  var validateConfig = async (schema, file, data) => {
1995
2146
  try {
1996
2147
  const result = await schema.parseAsync(data);
1997
2148
  return result;
1998
2149
  } catch (error) {
1999
- if (error instanceof z41.ZodError) {
2150
+ if (error instanceof z42.ZodError) {
2000
2151
  throw new ConfigError(file, error, data);
2001
2152
  }
2002
2153
  throw error;
@@ -2186,7 +2337,7 @@ var generateGlobalAppId = (opt) => {
2186
2337
  };
2187
2338
 
2188
2339
  // src/feature/auth/index.ts
2189
- import { toDays as toDays2, toHours } from "@awsless/duration";
2340
+ import { toDays as toDays3, toHours } from "@awsless/duration";
2190
2341
  var authFeature = defineFeature({
2191
2342
  name: "auth",
2192
2343
  async onTypeGen(ctx) {
@@ -2320,9 +2471,9 @@ var authFeature = defineFeature({
2320
2471
  requireUppercase: props.password.uppercase,
2321
2472
  requireNumbers: props.password.numbers,
2322
2473
  requireSymbols: props.password.symbols,
2323
- temporaryPasswordValidityDays: toDays2(props.password.temporaryPasswordValidity)
2474
+ temporaryPasswordValidityDays: toDays3(props.password.temporaryPasswordValidity)
2324
2475
  },
2325
- deletionProtection: "ACTIVE"
2476
+ deletionProtection: ctx.appConfig.protect ? "ACTIVE" : "INACTIVE"
2326
2477
  },
2327
2478
  {
2328
2479
  retainOnDelete: ctx.appConfig.removal === "retain",
@@ -2334,7 +2485,7 @@ var authFeature = defineFeature({
2334
2485
  name,
2335
2486
  idTokenValidity: toHours(props.validity.idToken),
2336
2487
  accessTokenValidity: toHours(props.validity.accessToken),
2337
- refreshTokenValidity: toDays2(props.validity.refreshToken),
2488
+ refreshTokenValidity: toDays3(props.validity.refreshToken),
2338
2489
  tokenValidityUnits: [
2339
2490
  {
2340
2491
  idToken: "hours",
@@ -2858,7 +3009,7 @@ var zipFiles = (files) => {
2858
3009
  };
2859
3010
 
2860
3011
  // src/feature/function/util.ts
2861
- import { toDays as toDays3, toSeconds } from "@awsless/duration";
3012
+ import { toDays as toDays4, toSeconds } from "@awsless/duration";
2862
3013
  import { toMebibytes } from "@awsless/size";
2863
3014
  import { pascalCase } from "change-case";
2864
3015
 
@@ -3199,7 +3350,7 @@ var createLambdaFunction = (parentGroup, ctx, ns, id, local) => {
3199
3350
  const logGroup = new $3.aws.cloudwatch.LogGroup(group, "log", {
3200
3351
  // name: lambda.functionName.pipe(name => `/aws/lambda/${name}`),
3201
3352
  name: `/aws/lambda/${name}`,
3202
- retentionInDays: toDays3(props.log.retention)
3353
+ retentionInDays: toDays4(props.log.retention)
3203
3354
  });
3204
3355
  addPermission({
3205
3356
  actions: ["logs:PutLogEvents", "logs:CreateLogStream"],
@@ -3735,6 +3886,7 @@ var onFailureFeature = defineFeature({
3735
3886
  resourceName: "failure"
3736
3887
  })
3737
3888
  });
3889
+ ctx.addEnv("ON_FAILURE_QUEUE_ARN", queue2.arn);
3738
3890
  ctx.shared.set("on-failure", "queue-arn", queue2.arn);
3739
3891
  const result = createLambdaFunction(group, ctx, "on-failure", "consumer", ctx.appConfig.defaults.onFailure);
3740
3892
  new $8.aws.lambda.EventSourceMapping(
@@ -4136,7 +4288,7 @@ import { dirname as dirname6, join as join10, relative as relative5 } from "path
4136
4288
  import { fileURLToPath } from "node:url";
4137
4289
 
4138
4290
  // src/feature/function/prebuild.ts
4139
- import { days as days3, seconds as seconds6, toDays as toDays4, toSeconds as toSeconds4 } from "@awsless/duration";
4291
+ import { days as days4, seconds as seconds6, toDays as toDays5, toSeconds as toSeconds4 } from "@awsless/duration";
4140
4292
  import { $ as $12, Future as Future2, resolveInputs as resolveInputs2 } from "@awsless/formation";
4141
4293
  import { mebibytes as mebibytes2, toMebibytes as toMebibytes2 } from "@awsless/size";
4142
4294
  import { pascalCase as pascalCase2 } from "change-case";
@@ -4264,7 +4416,7 @@ var createPrebuildLambdaFunction = (group, ctx, ns, id, props) => {
4264
4416
  if (props.log?.retention && props.log?.retention?.value > 0n) {
4265
4417
  const logGroup = new $12.aws.cloudwatch.LogGroup(group, "log", {
4266
4418
  name: `/aws/lambda/${name}`,
4267
- retentionInDays: toDays4(props.log.retention ?? days3(7))
4419
+ retentionInDays: toDays5(props.log.retention ?? days4(7))
4268
4420
  });
4269
4421
  addPermission({
4270
4422
  actions: ["logs:PutLogEvents", "logs:CreateLogStream"],
@@ -4319,7 +4471,7 @@ var createPrebuildLambdaFunction = (group, ctx, ns, id, props) => {
4319
4471
  };
4320
4472
 
4321
4473
  // src/feature/rpc/index.ts
4322
- import { days as days4, seconds as seconds7, toSeconds as toSeconds5 } from "@awsless/duration";
4474
+ import { days as days5, seconds as seconds7, toSeconds as toSeconds5 } from "@awsless/duration";
4323
4475
  var __dirname = dirname6(fileURLToPath(import.meta.url));
4324
4476
  var rpcFeature = defineFeature({
4325
4477
  name: "rpc",
@@ -4494,8 +4646,8 @@ var rpcFeature = defineFeature({
4494
4646
  const cache = new $13.aws.cloudfront.CachePolicy(group, "cache", {
4495
4647
  name,
4496
4648
  minTtl: toSeconds5(seconds7(1)),
4497
- maxTtl: toSeconds5(days4(365)),
4498
- defaultTtl: toSeconds5(days4(1))
4649
+ maxTtl: toSeconds5(days5(365)),
4650
+ defaultTtl: toSeconds5(days5(1))
4499
4651
  });
4500
4652
  const originRequest = new $13.aws.cloudfront.OriginRequestPolicy(group, "request", {
4501
4653
  name,
@@ -4722,7 +4874,7 @@ var searchFeature = defineFeature({
4722
4874
  });
4723
4875
 
4724
4876
  // src/feature/site/index.ts
4725
- import { days as days5, seconds as seconds8, toSeconds as toSeconds6 } from "@awsless/duration";
4877
+ import { days as days6, seconds as seconds8, toSeconds as toSeconds6 } from "@awsless/duration";
4726
4878
  import { $ as $15, Group as Group15 } from "@awsless/formation";
4727
4879
  import { glob as glob2 } from "glob";
4728
4880
  import { dirname as dirname7, join as join11 } from "path";
@@ -5047,8 +5199,8 @@ var siteFeature = defineFeature({
5047
5199
  const cache = new $15.aws.cloudfront.CachePolicy(group, "cache", {
5048
5200
  name,
5049
5201
  minTtl: toSeconds6(seconds8(1)),
5050
- maxTtl: toSeconds6(days5(365)),
5051
- defaultTtl: toSeconds6(days5(1)),
5202
+ maxTtl: toSeconds6(days6(365)),
5203
+ defaultTtl: toSeconds6(days6(1)),
5052
5204
  parametersInCacheKeyAndForwardedToOrigin: {
5053
5205
  cookiesConfig: {
5054
5206
  cookieBehavior: props.cache?.cookies ? "whitelist" : "none",
@@ -5089,7 +5241,7 @@ var siteFeature = defineFeature({
5089
5241
  name,
5090
5242
  corsConfig: {
5091
5243
  originOverride: props.cors?.override ?? false,
5092
- accessControlMaxAgeSec: toSeconds6(props.cors?.maxAge ?? days5(365)),
5244
+ accessControlMaxAgeSec: toSeconds6(props.cors?.maxAge ?? days6(365)),
5093
5245
  accessControlAllowHeaders: { items: props.cors?.headers ?? ["*"] },
5094
5246
  accessControlAllowMethods: { items: props.cors?.methods ?? ["ALL"] },
5095
5247
  accessControlAllowOrigins: { items: props.cors?.origins ?? ["*"] },
@@ -5114,7 +5266,7 @@ var siteFeature = defineFeature({
5114
5266
  strictTransportSecurity: {
5115
5267
  override: false,
5116
5268
  preload: true,
5117
- accessControlMaxAgeSec: toSeconds6(days5(365)),
5269
+ accessControlMaxAgeSec: toSeconds6(days6(365)),
5118
5270
  includeSubdomains: true
5119
5271
  },
5120
5272
  xssProtection: {
@@ -5594,6 +5746,7 @@ var tableFeature = defineFeature({
5594
5746
  import { Group as Group18 } from "@awsless/formation";
5595
5747
  import { camelCase as camelCase7 } from "change-case";
5596
5748
  import { relative as relative6 } from "path";
5749
+ import { $ as $18 } from "@awsless/formation";
5597
5750
  var typeGenCode6 = `
5598
5751
  import { InvokeOptions } from '@awsless/lambda'
5599
5752
  import type { Mock } from 'vitest'
@@ -5653,49 +5806,64 @@ var taskFeature = defineFeature({
5653
5806
  types2.addInterface("TaskMockResponse", mockResponses);
5654
5807
  await ctx.write("task.d.ts", types2, true);
5655
5808
  },
5656
- // onApp(ctx) {
5657
- // const group = new Group(ctx.base, 'task', 'main')
5658
- // const scheduleRole = new $.aws.iam.Role(group, 'schedule', {
5659
- // name: formatGlobalResourceName({
5660
- // appName: ctx.app.name,
5661
- // resourceType: 'task',
5662
- // resourceName: 'schedule',
5663
- // }),
5664
- // description: `Task schedule ${ctx.app.name}`,
5665
- // assumeRolePolicy: JSON.stringify({
5666
- // Version: '2012-10-17',
5667
- // Statement: [
5668
- // {
5669
- // Action: 'sts:AssumeRole',
5670
- // Effect: 'Allow',
5671
- // Principal: {
5672
- // Service: 'scheduler.amazonaws.com',
5673
- // },
5674
- // },
5675
- // ],
5676
- // }),
5677
- // inlinePolicy: [
5678
- // {
5679
- // name: 'Invoke function',
5680
- // policy: JSON.stringify({
5681
- // Version: '2012-10-17',
5682
- // Statement: [
5683
- // {
5684
- // Action: ['lambda:InvokeFunction'],
5685
- // Effect: 'Allow',
5686
- // Resource: [`arn:aws:lambda:*:*:function:${ctx.appConfig.name}--*--task--*`],
5687
- // },
5688
- // ],
5689
- // }),
5690
- // },
5691
- // ],
5692
- // })
5693
- // ctx.addGlobalPermission({
5694
- // actions: ['schedule:CreateSchedule'],
5695
- // resources: [`arn:aws:schedule:*:*:schedule:${ctx.appConfig.name}--*`],
5696
- // })
5697
- // ctx.addEnv('TASK_SCHEDULE_ROLE', scheduleRole.arn)
5698
- // },
5809
+ onApp(ctx) {
5810
+ const group = new Group18(ctx.base, "task", "main");
5811
+ const scheduleGroupName = formatGlobalResourceName({
5812
+ appName: ctx.app.name,
5813
+ resourceType: "task",
5814
+ resourceName: "group"
5815
+ });
5816
+ new $18.aws.scheduler.ScheduleGroup(group, "group", {
5817
+ name: scheduleGroupName,
5818
+ tags: {
5819
+ app: ctx.app.name
5820
+ }
5821
+ });
5822
+ const role = new $18.aws.iam.Role(group, "schedule", {
5823
+ name: formatGlobalResourceName({
5824
+ appName: ctx.app.name,
5825
+ resourceType: "task",
5826
+ resourceName: "schedule"
5827
+ }),
5828
+ description: `Task schedule ${ctx.app.name}`,
5829
+ assumeRolePolicy: JSON.stringify({
5830
+ Version: "2012-10-17",
5831
+ Statement: [
5832
+ {
5833
+ Action: "sts:AssumeRole",
5834
+ Effect: "Allow",
5835
+ Principal: {
5836
+ Service: "scheduler.amazonaws.com"
5837
+ }
5838
+ }
5839
+ ]
5840
+ }),
5841
+ inlinePolicy: [
5842
+ {
5843
+ name: "InvokeFunction",
5844
+ policy: JSON.stringify({
5845
+ Version: "2012-10-17",
5846
+ Statement: [
5847
+ {
5848
+ Action: ["lambda:InvokeFunction"],
5849
+ Effect: "Allow",
5850
+ Resource: [`arn:aws:lambda:*:*:function:${ctx.appConfig.name}--*--task--*`]
5851
+ }
5852
+ ]
5853
+ })
5854
+ }
5855
+ ]
5856
+ });
5857
+ ctx.addGlobalPermission({
5858
+ actions: ["scheduler:CreateSchedule"],
5859
+ // resources: [`arn:aws:scheduler:*:*:schedule:${ctx.appConfig.name}--*`],
5860
+ resources: [`arn:aws:scheduler:*:*:schedule/${scheduleGroupName}/*`]
5861
+ });
5862
+ ctx.addGlobalPermission({
5863
+ actions: ["iam:PassRole"],
5864
+ resources: [role.arn]
5865
+ });
5866
+ },
5699
5867
  onStack(ctx) {
5700
5868
  for (const [id, props] of Object.entries(ctx.stackConfig.tasks ?? {})) {
5701
5869
  const group = new Group18(ctx.stack, "task", id);
@@ -5715,7 +5883,7 @@ var testFeature = defineFeature({
5715
5883
  });
5716
5884
 
5717
5885
  // src/feature/topic/index.ts
5718
- import { $ as $18, Group as Group19 } from "@awsless/formation";
5886
+ import { $ as $19, Group as Group19 } from "@awsless/formation";
5719
5887
  var typeGenCode7 = `
5720
5888
  import type { PublishOptions } from '@awsless/sns'
5721
5889
 
@@ -5780,7 +5948,7 @@ var topicFeature = defineFeature({
5780
5948
  resourceType: "topic",
5781
5949
  resourceName: id
5782
5950
  });
5783
- const topic = new $18.aws.sns.Topic(group, "topic", {
5951
+ const topic = new $19.aws.sns.Topic(group, "topic", {
5784
5952
  name
5785
5953
  });
5786
5954
  ctx.shared.add("topic", `arn`, id, topic.arn);
@@ -5808,12 +5976,12 @@ var topicFeature = defineFeature({
5808
5976
  const group = new Group19(ctx.stack, "topic", id);
5809
5977
  const topicArn = ctx.shared.entry("topic", "arn", id);
5810
5978
  const { lambda } = createAsyncLambdaFunction(group, ctx, `topic`, id, props);
5811
- new $18.aws.sns.TopicSubscription(group, id, {
5979
+ new $19.aws.sns.TopicSubscription(group, id, {
5812
5980
  topicArn,
5813
5981
  protocol: "lambda",
5814
5982
  endpoint: lambda.arn
5815
5983
  });
5816
- new $18.aws.lambda.Permission(group, id, {
5984
+ new $19.aws.lambda.Permission(group, id, {
5817
5985
  action: "lambda:InvokeFunction",
5818
5986
  principal: "sns.amazonaws.com",
5819
5987
  functionName: lambda.functionName,
@@ -5824,39 +5992,39 @@ var topicFeature = defineFeature({
5824
5992
  });
5825
5993
 
5826
5994
  // src/feature/vpc/index.ts
5827
- import { $ as $19, Group as Group20 } from "@awsless/formation";
5995
+ import { $ as $20, Group as Group20 } from "@awsless/formation";
5828
5996
  var vpcFeature = defineFeature({
5829
5997
  name: "vpc",
5830
5998
  onApp(ctx) {
5831
5999
  const group = new Group20(ctx.base, "vpc", "main");
5832
- const vpc = new $19.aws.Vpc(group, "vpc", {
6000
+ const vpc = new $20.aws.Vpc(group, "vpc", {
5833
6001
  tags: {
5834
6002
  Name: ctx.app.name
5835
6003
  },
5836
6004
  cidrBlock: "10.0.0.0/16"
5837
6005
  });
5838
- const privateRouteTable = new $19.aws.route.Table(group, "private", {
6006
+ const privateRouteTable = new $20.aws.route.Table(group, "private", {
5839
6007
  vpcId: vpc.id,
5840
6008
  tags: {
5841
6009
  Name: "private"
5842
6010
  }
5843
6011
  });
5844
- const publicRouteTable = new $19.aws.route.Table(group, "public", {
6012
+ const publicRouteTable = new $20.aws.route.Table(group, "public", {
5845
6013
  vpcId: vpc.id,
5846
6014
  tags: {
5847
6015
  Name: "public"
5848
6016
  }
5849
6017
  });
5850
- const gateway = new $19.aws.internet.Gateway(group, "gateway", {
6018
+ const gateway = new $20.aws.internet.Gateway(group, "gateway", {
5851
6019
  tags: {
5852
6020
  Name: ctx.app.name
5853
6021
  }
5854
6022
  });
5855
- const attachment = new $19.aws.internet.GatewayAttachment(group, "attachment", {
6023
+ const attachment = new $20.aws.internet.GatewayAttachment(group, "attachment", {
5856
6024
  vpcId: vpc.id,
5857
6025
  internetGatewayId: gateway.id
5858
6026
  });
5859
- new $19.aws.Route(group, "route", {
6027
+ new $20.aws.Route(group, "route", {
5860
6028
  gatewayId: gateway.id,
5861
6029
  routeTableId: publicRouteTable.id,
5862
6030
  destinationCidrBlock: "0.0.0.0/0"
@@ -5880,7 +6048,7 @@ var vpcFeature = defineFeature({
5880
6048
  for (const i in zones) {
5881
6049
  const index = Number(i) + 1;
5882
6050
  const id = `${type}-${index}`;
5883
- const subnet = new $19.aws.Subnet(group, id, {
6051
+ const subnet = new $20.aws.Subnet(group, id, {
5884
6052
  tags: {
5885
6053
  Name: `${ctx.app.name}--${type}-${index}`
5886
6054
  },
@@ -5889,7 +6057,7 @@ var vpcFeature = defineFeature({
5889
6057
  mapPublicIpOnLaunch: type === "public",
5890
6058
  availabilityZone: ctx.appConfig.region + zones[i]
5891
6059
  });
5892
- new $19.aws.route.TableAssociation(group, id, {
6060
+ new $20.aws.route.TableAssociation(group, id, {
5893
6061
  routeTableId: table.id,
5894
6062
  subnetId: subnet.id
5895
6063
  });
@@ -5901,7 +6069,7 @@ var vpcFeature = defineFeature({
5901
6069
  });
5902
6070
 
5903
6071
  // src/feature/alert/index.ts
5904
- import { $ as $20, Group as Group21 } from "@awsless/formation";
6072
+ import { $ as $21, Group as Group21 } from "@awsless/formation";
5905
6073
  var typeGenCode8 = `
5906
6074
  import type { PublishOptions } from '@awsless/sns'
5907
6075
 
@@ -5944,11 +6112,11 @@ var alertFeature = defineFeature({
5944
6112
  resourceType: "alert",
5945
6113
  resourceName: id
5946
6114
  });
5947
- const topic = new $20.aws.sns.Topic(group, "topic", {
6115
+ const topic = new $21.aws.sns.Topic(group, "topic", {
5948
6116
  name
5949
6117
  });
5950
6118
  for (const email of emails) {
5951
- new $20.aws.sns.TopicSubscription(group, id, {
6119
+ new $21.aws.sns.TopicSubscription(group, id, {
5952
6120
  topicArn: topic.arn,
5953
6121
  protocol: "email",
5954
6122
  endpoint: email
@@ -5969,12 +6137,12 @@ var alertFeature = defineFeature({
5969
6137
  });
5970
6138
 
5971
6139
  // src/feature/layer/index.ts
5972
- import { $ as $21, Group as Group22 } from "@awsless/formation";
6140
+ import { $ as $22, Group as Group22 } from "@awsless/formation";
5973
6141
  var layerFeature = defineFeature({
5974
6142
  name: "layer",
5975
6143
  onBefore(ctx) {
5976
6144
  const group = new Group22(ctx.base, "layer", "asset");
5977
- const bucket = new $21.aws.s3.Bucket(group, "bucket", {
6145
+ const bucket = new $22.aws.s3.Bucket(group, "bucket", {
5978
6146
  bucket: formatGlobalResourceName({
5979
6147
  appName: ctx.app.name,
5980
6148
  resourceType: "layer",
@@ -6004,14 +6172,14 @@ var layerFeature = defineFeature({
6004
6172
  for (const [id, _props] of layers) {
6005
6173
  const props = _props;
6006
6174
  const group = new Group22(ctx.base, "layer", id);
6007
- const zip = new $21.aws.s3.BucketObject(group, "zip", {
6175
+ const zip = new $22.aws.s3.BucketObject(group, "zip", {
6008
6176
  bucket: ctx.shared.get("layer", "bucket-name"),
6009
6177
  key: `/layer/${id}.zip`,
6010
6178
  contentType: "application/zip",
6011
6179
  source: props.file,
6012
6180
  sourceHash: $hash(props.file)
6013
6181
  });
6014
- const layer = new $21.aws.lambda.LayerVersion(
6182
+ const layer = new $22.aws.lambda.LayerVersion(
6015
6183
  group,
6016
6184
  "layer",
6017
6185
  {
@@ -6044,10 +6212,10 @@ var layerFeature = defineFeature({
6044
6212
  });
6045
6213
 
6046
6214
  // src/feature/image/index.ts
6047
- import { $ as $22, Group as Group23 } from "@awsless/formation";
6215
+ import { $ as $23, Group as Group23 } from "@awsless/formation";
6048
6216
  import { join as join12, dirname as dirname8 } from "path";
6049
6217
  import { mebibytes as mebibytes4 } from "@awsless/size";
6050
- import { days as days6, seconds as seconds9, toDays as toDays5, toSeconds as toSeconds8 } from "@awsless/duration";
6218
+ import { days as days7, seconds as seconds9, toDays as toDays6, toSeconds as toSeconds8 } from "@awsless/duration";
6051
6219
  import { constantCase as constantCase12 } from "change-case";
6052
6220
  import { fileURLToPath as fileURLToPath2 } from "url";
6053
6221
  import { glob as glob3 } from "glob";
@@ -6068,14 +6236,14 @@ var imageFeature = defineFeature({
6068
6236
  resourceType: "layer",
6069
6237
  resourceName: "sharp"
6070
6238
  });
6071
- const zipFile = new $22.aws.s3.BucketObject(group, "layer", {
6239
+ const zipFile = new $23.aws.s3.BucketObject(group, "layer", {
6072
6240
  bucket: ctx.shared.get("layer", "bucket-name"),
6073
6241
  key: `/layer/${layerId}.zip`,
6074
6242
  contentType: "application/zip",
6075
6243
  source: path,
6076
6244
  sourceHash: $hash(path)
6077
6245
  });
6078
- const layer = new $22.aws.lambda.LayerVersion(group, "layer", {
6246
+ const layer = new $23.aws.lambda.LayerVersion(group, "layer", {
6079
6247
  layerName: layerId,
6080
6248
  description: "sharp-arm.zip for the awsless image feature.",
6081
6249
  compatibleArchitectures: ["arm64"],
@@ -6106,7 +6274,7 @@ var imageFeature = defineFeature({
6106
6274
  }
6107
6275
  let s3Origin;
6108
6276
  if (props.origin.static) {
6109
- s3Origin = new $22.aws.s3.Bucket(group, "origin", {
6277
+ s3Origin = new $23.aws.s3.Bucket(group, "origin", {
6110
6278
  bucket: formatLocalResourceName({
6111
6279
  appName: ctx.app.name,
6112
6280
  stackName: ctx.stack.name,
@@ -6116,7 +6284,7 @@ var imageFeature = defineFeature({
6116
6284
  forceDestroy: true
6117
6285
  });
6118
6286
  }
6119
- const cacheBucket = new $22.aws.s3.Bucket(group, "cache", {
6287
+ const cacheBucket = new $23.aws.s3.Bucket(group, "cache", {
6120
6288
  bucket: formatLocalResourceName({
6121
6289
  appName: ctx.app.name,
6122
6290
  stackName: ctx.stack.name,
@@ -6133,7 +6301,7 @@ var imageFeature = defineFeature({
6133
6301
  enabled: true,
6134
6302
  id: "image-cache-duration",
6135
6303
  expiration: {
6136
- days: toDays5(props.cacheDuration)
6304
+ days: toDays6(props.cacheDuration)
6137
6305
  }
6138
6306
  }
6139
6307
  ]
@@ -6154,14 +6322,14 @@ var imageFeature = defineFeature({
6154
6322
  log: props.log,
6155
6323
  layers: [sharpLayerId]
6156
6324
  });
6157
- const permission = new $22.aws.lambda.Permission(group, "permission", {
6325
+ const permission = new $23.aws.lambda.Permission(group, "permission", {
6158
6326
  principal: "cloudfront.amazonaws.com",
6159
6327
  action: "lambda:InvokeFunctionUrl",
6160
6328
  functionName: serverLambda.lambda.functionName,
6161
6329
  functionUrlAuthType: "AWS_IAM",
6162
6330
  sourceArn: `arn:aws:cloudfront::${ctx.accountId}:distribution/*`
6163
6331
  });
6164
- const serverLambdaUrl = new $22.aws.lambda.FunctionUrl(
6332
+ const serverLambdaUrl = new $23.aws.lambda.FunctionUrl(
6165
6333
  group,
6166
6334
  "url",
6167
6335
  {
@@ -6209,7 +6377,7 @@ var imageFeature = defineFeature({
6209
6377
  nodir: true
6210
6378
  });
6211
6379
  for (const file of files) {
6212
- new $22.aws.s3.BucketObject(group, `static-${file}`, {
6380
+ new $23.aws.s3.BucketObject(group, `static-${file}`, {
6213
6381
  bucket: s3Origin.bucket,
6214
6382
  key: file,
6215
6383
  source: join12(props.origin.static, file),
@@ -6220,25 +6388,25 @@ var imageFeature = defineFeature({
6220
6388
  });
6221
6389
  const domainName = props.domain ? formatFullDomainName(ctx.appConfig, props.domain, props.subDomain) : void 0;
6222
6390
  const certificateArn = props.domain ? ctx.shared.entry("domain", `global-certificate-arn`, props.domain) : void 0;
6223
- const s3AccessControl = new $22.aws.cloudfront.OriginAccessControl(group, `s3`, {
6391
+ const s3AccessControl = new $23.aws.cloudfront.OriginAccessControl(group, `s3`, {
6224
6392
  name: `${name}-s3`,
6225
6393
  description: `Policy for the ${id} image cache in S3`,
6226
6394
  originAccessControlOriginType: "s3",
6227
6395
  signingBehavior: "always",
6228
6396
  signingProtocol: "sigv4"
6229
6397
  });
6230
- const lambdaAccessControl = new $22.aws.cloudfront.OriginAccessControl(group, "lambda", {
6398
+ const lambdaAccessControl = new $23.aws.cloudfront.OriginAccessControl(group, "lambda", {
6231
6399
  name: `${name}-lambda`,
6232
6400
  description: `Policy for the ${id} image lambda server function URL`,
6233
6401
  originAccessControlOriginType: "lambda",
6234
6402
  signingBehavior: "always",
6235
6403
  signingProtocol: "sigv4"
6236
6404
  });
6237
- const cache = new $22.aws.cloudfront.CachePolicy(group, "cache", {
6405
+ const cache = new $23.aws.cloudfront.CachePolicy(group, "cache", {
6238
6406
  name,
6239
- defaultTtl: toSeconds8(days6(365))
6407
+ defaultTtl: toSeconds8(days7(365))
6240
6408
  });
6241
- const distribution = new $22.aws.cloudfront.Distribution(group, "distribution", {
6409
+ const distribution = new $23.aws.cloudfront.Distribution(group, "distribution", {
6242
6410
  comment: name,
6243
6411
  enabled: true,
6244
6412
  aliases: domainName ? [domainName] : void 0,
@@ -6298,7 +6466,7 @@ var imageFeature = defineFeature({
6298
6466
  cachedMethods: ["GET", "HEAD"]
6299
6467
  }
6300
6468
  });
6301
- new $22.aws.s3.BucketPolicy(
6469
+ new $23.aws.s3.BucketPolicy(
6302
6470
  group,
6303
6471
  `policy`,
6304
6472
  {
@@ -6329,7 +6497,7 @@ var imageFeature = defineFeature({
6329
6497
  }
6330
6498
  );
6331
6499
  if (domainName) {
6332
- new $22.aws.route53.Record(group, `record`, {
6500
+ new $23.aws.route53.Record(group, `record`, {
6333
6501
  zoneId: ctx.shared.entry("domain", "zone-id", props.domain),
6334
6502
  type: "A",
6335
6503
  name: domainName,
@@ -6351,10 +6519,10 @@ var imageFeature = defineFeature({
6351
6519
  });
6352
6520
 
6353
6521
  // src/feature/icon/index.ts
6354
- import { $ as $23, Group as Group24 } from "@awsless/formation";
6522
+ import { $ as $24, Group as Group24 } from "@awsless/formation";
6355
6523
  import { join as join13, dirname as dirname9 } from "path";
6356
6524
  import { mebibytes as mebibytes5 } from "@awsless/size";
6357
- import { days as days7, seconds as seconds10, toDays as toDays6, toSeconds as toSeconds9 } from "@awsless/duration";
6525
+ import { days as days8, seconds as seconds10, toDays as toDays7, toSeconds as toSeconds9 } from "@awsless/duration";
6358
6526
  import { constantCase as constantCase13 } from "change-case";
6359
6527
  import { fileURLToPath as fileURLToPath3 } from "url";
6360
6528
  import { glob as glob4 } from "glob";
@@ -6376,7 +6544,7 @@ var iconFeature = defineFeature({
6376
6544
  }
6377
6545
  let s3Origin;
6378
6546
  if (props.origin.static) {
6379
- s3Origin = new $23.aws.s3.Bucket(group, "origin", {
6547
+ s3Origin = new $24.aws.s3.Bucket(group, "origin", {
6380
6548
  bucket: formatLocalResourceName({
6381
6549
  appName: ctx.app.name,
6382
6550
  stackName: ctx.stack.name,
@@ -6386,7 +6554,7 @@ var iconFeature = defineFeature({
6386
6554
  forceDestroy: true
6387
6555
  });
6388
6556
  }
6389
- const cacheBucket = new $23.aws.s3.Bucket(group, "cache", {
6557
+ const cacheBucket = new $24.aws.s3.Bucket(group, "cache", {
6390
6558
  bucket: formatLocalResourceName({
6391
6559
  appName: ctx.app.name,
6392
6560
  stackName: ctx.stack.name,
@@ -6403,7 +6571,7 @@ var iconFeature = defineFeature({
6403
6571
  enabled: true,
6404
6572
  id: "icon-cache-duration",
6405
6573
  expiration: {
6406
- days: toDays6(props.cacheDuration)
6574
+ days: toDays7(props.cacheDuration)
6407
6575
  }
6408
6576
  }
6409
6577
  ]
@@ -6418,14 +6586,14 @@ var iconFeature = defineFeature({
6418
6586
  runtime: "nodejs22.x",
6419
6587
  log: props.log
6420
6588
  });
6421
- const permission = new $23.aws.lambda.Permission(group, "permission", {
6589
+ const permission = new $24.aws.lambda.Permission(group, "permission", {
6422
6590
  principal: "cloudfront.amazonaws.com",
6423
6591
  action: "lambda:InvokeFunctionUrl",
6424
6592
  functionName: serverLambda.lambda.functionName,
6425
6593
  functionUrlAuthType: "AWS_IAM",
6426
6594
  sourceArn: `arn:aws:cloudfront::${ctx.accountId}:distribution/*`
6427
6595
  });
6428
- const serverLambdaUrl = new $23.aws.lambda.FunctionUrl(
6596
+ const serverLambdaUrl = new $24.aws.lambda.FunctionUrl(
6429
6597
  group,
6430
6598
  "url",
6431
6599
  {
@@ -6475,7 +6643,7 @@ var iconFeature = defineFeature({
6475
6643
  if (!file.endsWith(".svg")) {
6476
6644
  throw new Error(`Icon file "${file}" in "${props.origin.static}" is not an SVG file.`);
6477
6645
  }
6478
- new $23.aws.s3.BucketObject(group, `static-${file}`, {
6646
+ new $24.aws.s3.BucketObject(group, `static-${file}`, {
6479
6647
  bucket: s3Origin.bucket,
6480
6648
  key: file,
6481
6649
  source: join13(props.origin.static, file),
@@ -6486,29 +6654,29 @@ var iconFeature = defineFeature({
6486
6654
  });
6487
6655
  const domainName = props.domain ? formatFullDomainName(ctx.appConfig, props.domain, props.subDomain) : void 0;
6488
6656
  const certificateArn = props.domain ? ctx.shared.entry("domain", `global-certificate-arn`, props.domain) : void 0;
6489
- const s3AccessControl = new $23.aws.cloudfront.OriginAccessControl(group, `s3`, {
6657
+ const s3AccessControl = new $24.aws.cloudfront.OriginAccessControl(group, `s3`, {
6490
6658
  name: `${name}-s3`,
6491
6659
  description: `Policy for the ${id} icon cache in S3`,
6492
6660
  originAccessControlOriginType: "s3",
6493
6661
  signingBehavior: "always",
6494
6662
  signingProtocol: "sigv4"
6495
6663
  });
6496
- const lambdaAccessControl = new $23.aws.cloudfront.OriginAccessControl(group, "lambda", {
6664
+ const lambdaAccessControl = new $24.aws.cloudfront.OriginAccessControl(group, "lambda", {
6497
6665
  name: `${name}-lambda`,
6498
6666
  description: `Policy for the ${id} icon lambda server function URL`,
6499
6667
  originAccessControlOriginType: "lambda",
6500
6668
  signingBehavior: "always",
6501
6669
  signingProtocol: "sigv4"
6502
6670
  });
6503
- const cache = new $23.aws.cloudfront.CachePolicy(group, "cache", {
6671
+ const cache = new $24.aws.cloudfront.CachePolicy(group, "cache", {
6504
6672
  name,
6505
- defaultTtl: toSeconds9(days7(365))
6673
+ defaultTtl: toSeconds9(days8(365))
6506
6674
  });
6507
- const responseHeaders = new $23.aws.cloudfront.ResponseHeadersPolicy(group, "response", {
6675
+ const responseHeaders = new $24.aws.cloudfront.ResponseHeadersPolicy(group, "response", {
6508
6676
  name,
6509
6677
  corsConfig: {
6510
6678
  originOverride: true,
6511
- accessControlMaxAgeSec: toSeconds9(days7(365)),
6679
+ accessControlMaxAgeSec: toSeconds9(days8(365)),
6512
6680
  accessControlAllowHeaders: { items: ["*"] },
6513
6681
  accessControlAllowMethods: { items: ["ALL"] },
6514
6682
  accessControlAllowOrigins: { items: ["*"] },
@@ -6516,7 +6684,7 @@ var iconFeature = defineFeature({
6516
6684
  accessControlAllowCredentials: false
6517
6685
  }
6518
6686
  });
6519
- const distribution = new $23.aws.cloudfront.Distribution(group, "distribution", {
6687
+ const distribution = new $24.aws.cloudfront.Distribution(group, "distribution", {
6520
6688
  waitForDeployment: false,
6521
6689
  comment: name,
6522
6690
  enabled: true,
@@ -6577,7 +6745,7 @@ var iconFeature = defineFeature({
6577
6745
  responseHeadersPolicyId: responseHeaders.id
6578
6746
  }
6579
6747
  });
6580
- new $23.aws.s3.BucketPolicy(
6748
+ new $24.aws.s3.BucketPolicy(
6581
6749
  group,
6582
6750
  `policy`,
6583
6751
  {
@@ -6608,7 +6776,7 @@ var iconFeature = defineFeature({
6608
6776
  }
6609
6777
  );
6610
6778
  if (domainName) {
6611
- new $23.aws.route53.Record(group, `record`, {
6779
+ new $24.aws.route53.Record(group, `record`, {
6612
6780
  zoneId: ctx.shared.entry("domain", "zone-id", props.domain),
6613
6781
  type: "A",
6614
6782
  name: domainName,
@@ -6629,6 +6797,395 @@ var iconFeature = defineFeature({
6629
6797
  }
6630
6798
  });
6631
6799
 
6800
+ // src/feature/instance/index.ts
6801
+ import { $ as $26, Group as Group26 } from "@awsless/formation";
6802
+
6803
+ // src/feature/instance/util.ts
6804
+ import { toDays as toDays8, toSeconds as toSeconds10 } from "@awsless/duration";
6805
+ import { $ as $25, Future as Future4, Group as Group25, resolveInputs as resolveInputs3 } from "@awsless/formation";
6806
+ import { generateFileHash as generateFileHash2 } from "@awsless/ts-file-cache";
6807
+ import { constantCase as constantCase14, pascalCase as pascalCase3 } from "change-case";
6808
+ import deepmerge4 from "deepmerge";
6809
+
6810
+ // src/feature/instance/build/executable.ts
6811
+ import { execSync } from "child_process";
6812
+ import { createHash as createHash5 } from "crypto";
6813
+ import { readFile as readFile4 } from "fs/promises";
6814
+ import { join as join14 } from "path";
6815
+ var buildExecutable = async (input, outputPath) => {
6816
+ const filePath = join14(outputPath, "program");
6817
+ const args = ["build", input, "--compile", "--target", "bun-linux-x64-modern", "--outfile", filePath];
6818
+ try {
6819
+ execSync(`bun ${args.join(" ")}`, { encoding: "utf8" });
6820
+ } catch (error) {
6821
+ throw new Error(`Executable build failed: ${error instanceof Error ? error.message : String(error)}`);
6822
+ }
6823
+ const file = await readFile4(filePath);
6824
+ return {
6825
+ hash: createHash5("sha1").update(file).digest("hex"),
6826
+ file
6827
+ };
6828
+ };
6829
+
6830
+ // src/feature/instance/util.ts
6831
+ var createFargateTask = (parentGroup, ctx, ns, id, local) => {
6832
+ const group = new Group25(parentGroup, "instance", ns);
6833
+ const name = formatLocalResourceName({
6834
+ appName: ctx.app.name,
6835
+ stackName: ctx.stack.name,
6836
+ resourceType: ns,
6837
+ resourceName: id
6838
+ });
6839
+ const shortName = shortId(`${ctx.app.name}:${ctx.stack.name}:${ns}:${id}:${ctx.appId}`);
6840
+ const props = deepmerge4(ctx.appConfig.defaults.instance, local);
6841
+ ctx.registerBuild("instance", name, async (build3, { workspace }) => {
6842
+ const fingerprint = await generateFileHash2(workspace, local.code.file);
6843
+ return build3(fingerprint, async (write) => {
6844
+ const temp = await createTempFolder(`instance--${name}`);
6845
+ const executable = await buildExecutable(local.code.file, temp.path);
6846
+ await Promise.all([
6847
+ //
6848
+ write("HASH", executable.hash),
6849
+ write("program", executable.file),
6850
+ temp.delete()
6851
+ ]);
6852
+ return {
6853
+ size: formatByteSize(executable.file.byteLength)
6854
+ };
6855
+ });
6856
+ });
6857
+ const code = new $25.aws.s3.BucketObject(group, "code", {
6858
+ bucket: ctx.shared.get("instance", "bucket-name"),
6859
+ key: `fargate/${name}`,
6860
+ source: relativePath(getBuildPath("instance", name, "program")),
6861
+ sourceHash: $hash(getBuildPath("instance", name, "HASH"))
6862
+ });
6863
+ const executionRole = new $25.aws.iam.Role(group, "execution-role", {
6864
+ name: shortId(`${shortName}:execution-role`),
6865
+ description: name,
6866
+ assumeRolePolicy: JSON.stringify({
6867
+ Version: "2012-10-17",
6868
+ Statement: [
6869
+ {
6870
+ Effect: "Allow",
6871
+ Action: "sts:AssumeRole",
6872
+ Principal: {
6873
+ Service: ["ecs-tasks.amazonaws.com"]
6874
+ }
6875
+ }
6876
+ ]
6877
+ }),
6878
+ managedPolicyArns: ["arn:aws:iam::aws:policy/service-role/AmazonECSTaskExecutionRolePolicy"]
6879
+ });
6880
+ const role = new $25.aws.iam.Role(
6881
+ group,
6882
+ "task-role",
6883
+ {
6884
+ name: shortId(`${shortName}:task-role`),
6885
+ description: name,
6886
+ assumeRolePolicy: JSON.stringify({
6887
+ Version: "2012-10-17",
6888
+ Statement: [
6889
+ {
6890
+ Effect: "Allow",
6891
+ Action: "sts:AssumeRole",
6892
+ Principal: {
6893
+ Service: ["ecs-tasks.amazonaws.com"]
6894
+ }
6895
+ }
6896
+ ]
6897
+ }),
6898
+ inlinePolicy: [
6899
+ {
6900
+ name: "s3-code-access",
6901
+ policy: $resolve([code.bucket, code.key], (bucket, key) => {
6902
+ return JSON.stringify({
6903
+ Version: "2012-10-17",
6904
+ Statement: [
6905
+ {
6906
+ Effect: pascalCase3("allow"),
6907
+ Action: ["s3:getObject", "s3:HeadObject"],
6908
+ Resource: `arn:aws:s3:::${bucket}/${key}`
6909
+ }
6910
+ ]
6911
+ });
6912
+ })
6913
+ }
6914
+ ]
6915
+ },
6916
+ {
6917
+ dependsOn: [code]
6918
+ }
6919
+ );
6920
+ const statements = [];
6921
+ const policy = new $25.aws.iam.RolePolicy(group, "policy", {
6922
+ role: role.name,
6923
+ name: "task-policy",
6924
+ policy: new Future4(async (resolve) => {
6925
+ const list3 = await resolveInputs3(statements);
6926
+ resolve(
6927
+ JSON.stringify({
6928
+ Version: "2012-10-17",
6929
+ Statement: list3.map((statement) => ({
6930
+ Effect: pascalCase3(statement.effect ?? "allow"),
6931
+ Action: statement.actions,
6932
+ Resource: statement.resources
6933
+ }))
6934
+ })
6935
+ );
6936
+ })
6937
+ });
6938
+ const addPermission = (...permissions) => {
6939
+ statements.push(...permissions);
6940
+ policy.$.attachDependencies(permissions);
6941
+ };
6942
+ ctx.onPermission((statement) => {
6943
+ addPermission(statement);
6944
+ });
6945
+ let logGroup;
6946
+ if (props.log.retention.value > 0n) {
6947
+ logGroup = new $25.aws.cloudwatch.LogGroup(group, "log", {
6948
+ name: `/aws/ecs/${name}`,
6949
+ retentionInDays: toDays8(props.log.retention)
6950
+ });
6951
+ const onLogArn = getGlobalOnLog(ctx);
6952
+ if (onLogArn && ctx.appConfig.defaults.onLog) {
6953
+ const logFilter = ctx.appConfig.defaults.onLog.filter;
6954
+ new $25.aws.cloudwatch.LogSubscriptionFilter(group, `on-log`, {
6955
+ name: "log-subscription",
6956
+ destinationArn: onLogArn,
6957
+ logGroupName: logGroup.name,
6958
+ filterPattern: formatFilterPattern(logFilter)
6959
+ });
6960
+ }
6961
+ }
6962
+ const tags = {
6963
+ APP: ctx.appConfig.name,
6964
+ APP_ID: ctx.appId,
6965
+ STACK: ctx.stackConfig.name
6966
+ };
6967
+ const variables = {};
6968
+ const task2 = new $25.aws.ecs.TaskDefinition(
6969
+ group,
6970
+ "task",
6971
+ {
6972
+ family: name,
6973
+ networkMode: "awsvpc",
6974
+ cpu: props.cpuSize,
6975
+ memory: props.memorySize.toString(),
6976
+ requiresCompatibilities: ["FARGATE"],
6977
+ executionRoleArn: executionRole.arn,
6978
+ taskRoleArn: role.arn,
6979
+ trackLatest: true,
6980
+ runtimePlatform: {
6981
+ cpuArchitecture: constantCase14(props.architecture),
6982
+ operatingSystemFamily: "LINUX"
6983
+ },
6984
+ containerDefinitions: new Future4(async (resolve) => {
6985
+ const data = await resolveInputs3(variables);
6986
+ const { s3Bucket, s3Key } = await resolveInputs3({
6987
+ s3Bucket: code.bucket,
6988
+ s3Key: code.key
6989
+ });
6990
+ resolve(
6991
+ JSON.stringify([
6992
+ {
6993
+ name: `container-${id}`,
6994
+ image: props.image,
6995
+ protocol: "tcp",
6996
+ workingDirectory: "/usr/app",
6997
+ entryPoint: ["sh", "-c"],
6998
+ command: [
6999
+ `aws s3 cp s3://${s3Bucket}/${s3Key} /usr/app/program && chmod +x /usr/app/program && /usr/app/program`
7000
+ // can only run a single command
7001
+ ],
7002
+ environment: Object.entries(data).map(([name2, value]) => ({
7003
+ name: name2,
7004
+ value
7005
+ })),
7006
+ portMappings: [
7007
+ {
7008
+ name: "http",
7009
+ protocol: "tcp",
7010
+ appProtocol: "http",
7011
+ containerPort: 80,
7012
+ hostPort: 80
7013
+ },
7014
+ {
7015
+ name: "https",
7016
+ protocol: "tcp",
7017
+ appProtocol: "http",
7018
+ containerPort: 443,
7019
+ hostPort: 443
7020
+ }
7021
+ ],
7022
+ ...props.restartPolicy && {
7023
+ restartPolicy: {
7024
+ enabled: props.restartPolicy.enabled,
7025
+ ...props.restartPolicy.ignoredExitCodes && {
7026
+ ignoredExitCodes: props.restartPolicy.ignoredExitCodes
7027
+ },
7028
+ ...props.restartPolicy.restartAttemptPeriod && {
7029
+ restartAttemptPeriod: props.restartPolicy.restartAttemptPeriod
7030
+ }
7031
+ }
7032
+ },
7033
+ ...logGroup && {
7034
+ logConfiguration: {
7035
+ logDriver: "awslogs",
7036
+ options: {
7037
+ "awslogs-group": `/aws/ecs/${name}`,
7038
+ "awslogs-region": ctx.appConfig.region,
7039
+ "awslogs-stream-prefix": "ecs"
7040
+ // mode: 'non-blocking',
7041
+ // 'max-buffer-size': '1m',
7042
+ }
7043
+ }
7044
+ },
7045
+ healthCheck: props.healthCheck ? {
7046
+ command: props.healthCheck.command,
7047
+ interval: toSeconds10(props.healthCheck.interval),
7048
+ retries: props.healthCheck.retries,
7049
+ startPeriod: toSeconds10(props.healthCheck.startPeriod),
7050
+ timeout: toSeconds10(props.healthCheck.timeout)
7051
+ } : void 0
7052
+ }
7053
+ ])
7054
+ );
7055
+ }),
7056
+ tags
7057
+ },
7058
+ {
7059
+ dependsOn: [code]
7060
+ }
7061
+ );
7062
+ const securityGroup = new $25.aws.security.Group(group, "security-group", {
7063
+ name,
7064
+ description: "Security group for the instance",
7065
+ vpcId: ctx.shared.get("vpc", "id"),
7066
+ tags
7067
+ });
7068
+ new $25.aws.vpc.SecurityGroupIngressRule(group, "ingress-rule-http", {
7069
+ securityGroupId: securityGroup.id,
7070
+ description: `Allow HTTP traffic on port 80 to the ${name} instance`,
7071
+ fromPort: 80,
7072
+ toPort: 80,
7073
+ ipProtocol: "tcp",
7074
+ cidrIpv4: "0.0.0.0/0",
7075
+ tags
7076
+ });
7077
+ new $25.aws.vpc.SecurityGroupIngressRule(group, "ingress-rule-https", {
7078
+ securityGroupId: securityGroup.id,
7079
+ description: `Allow HTTP traffic on port 443 to the ${name} instance`,
7080
+ fromPort: 443,
7081
+ toPort: 443,
7082
+ ipProtocol: "tcp",
7083
+ cidrIpv4: "0.0.0.0/0",
7084
+ tags
7085
+ });
7086
+ new $25.aws.vpc.SecurityGroupEgressRule(group, "egress-rule", {
7087
+ securityGroupId: securityGroup.id,
7088
+ description: `Allow all outbound traffic from the ${name} instance`,
7089
+ ipProtocol: "-1",
7090
+ cidrIpv4: "0.0.0.0/0",
7091
+ tags
7092
+ });
7093
+ const service = new $25.aws.ecs.Service(group, "service", {
7094
+ cluster: ctx.shared.get("instance", "cluster-arn"),
7095
+ name,
7096
+ taskDefinition: task2.arn,
7097
+ desiredCount: 1,
7098
+ launchType: "FARGATE",
7099
+ networkConfiguration: {
7100
+ subnets: ctx.shared.get("vpc", "public-subnets"),
7101
+ securityGroups: [securityGroup.id],
7102
+ assignPublicIp: true
7103
+ },
7104
+ forceNewDeployment: true,
7105
+ // serviceRegistries: {
7106
+ // registryArn: ctx.shared.get('instance', 'namespace'),
7107
+ // },
7108
+ tags
7109
+ // forceDelete: true,
7110
+ // deploymentCircuitBreaker: {
7111
+ // enable: true,
7112
+ // rollback: true,
7113
+ // },
7114
+ // deploymentController: { type: 'ECS' },
7115
+ // The internal url (dnsName) doesn't work for ldambda's
7116
+ // https://github.com/aws/containers-roadmap/issues/1960
7117
+ // serviceConnectConfiguration: {
7118
+ // enabled: true,
7119
+ // namespace: ctx.shared.get('instance', 'namespace'),
7120
+ // service: [
7121
+ // {
7122
+ // clientAlias: {
7123
+ // port: 80,
7124
+ // dnsName: `${id}.${ctx.app.name}.internal`,
7125
+ // },
7126
+ // discoveryName: name,
7127
+ // portName: 'http',
7128
+ // },
7129
+ // ],
7130
+ // },
7131
+ });
7132
+ variables.APP = ctx.appConfig.name;
7133
+ variables.APP_ID = ctx.appId;
7134
+ variables.AWS_ACCOUNT_ID = ctx.accountId;
7135
+ variables.STACK = ctx.stackConfig.name;
7136
+ variables.CODE_HASH = code.sourceHash;
7137
+ if (ctx.appConfig.defaults.instance.permissions) {
7138
+ statements.push(...ctx.appConfig.defaults.instance.permissions);
7139
+ }
7140
+ if ("permissions" in local && local.permissions) {
7141
+ statements.push(...local.permissions);
7142
+ }
7143
+ return { name, task: task2, service, policy, code, group };
7144
+ };
7145
+
7146
+ // src/feature/instance/index.ts
7147
+ var instanceFeature = defineFeature({
7148
+ name: "instance",
7149
+ onBefore(ctx) {
7150
+ const group = new Group26(ctx.base, "instance", "asset");
7151
+ const bucket = new $26.aws.s3.Bucket(group, "bucket", {
7152
+ bucket: formatGlobalResourceName({
7153
+ appName: ctx.app.name,
7154
+ resourceType: "instance",
7155
+ resourceName: "assets",
7156
+ postfix: ctx.appId
7157
+ }),
7158
+ forceDestroy: true
7159
+ });
7160
+ ctx.shared.set("instance", "bucket-name", bucket.bucket);
7161
+ },
7162
+ onApp(ctx) {
7163
+ const found = ctx.stackConfigs.filter((stack) => {
7164
+ return Object.keys(stack.instances ?? {}).length > 0;
7165
+ });
7166
+ if (found.length === 0) {
7167
+ return;
7168
+ }
7169
+ const group = new Group26(ctx.base, "instance", "cluster");
7170
+ const cluster = new $26.aws.ecs.Cluster(group, "cluster", {
7171
+ name: ctx.app.name
7172
+ });
7173
+ ctx.shared.set("instance", "cluster-arn", cluster.arn);
7174
+ const namespace = new $26.aws.service.DiscoveryPrivateDnsNamespace(group, "namespace", {
7175
+ name: ctx.app.name,
7176
+ vpc: ctx.shared.get("vpc", "id"),
7177
+ description: `Private DNS namespace for ${ctx.app.name}`
7178
+ });
7179
+ ctx.shared.set("instance", "namespace", namespace.name);
7180
+ },
7181
+ onStack(ctx) {
7182
+ for (const [id, props] of Object.entries(ctx.stackConfig.instances ?? {})) {
7183
+ const group = new Group26(ctx.stack, "instance", id);
7184
+ createFargateTask(group, ctx, "instance", id, props);
7185
+ }
7186
+ }
7187
+ });
7188
+
6632
7189
  // src/feature/index.ts
6633
7190
  var features = [
6634
7191
  // 1
@@ -6643,7 +7200,7 @@ var features = [
6643
7200
  authFeature,
6644
7201
  // 3
6645
7202
  functionFeature,
6646
- // instanceFeature,
7203
+ instanceFeature,
6647
7204
  // graphqlFeature,
6648
7205
  configFeature,
6649
7206
  searchFeature,
@@ -7526,14 +8083,14 @@ import wildstring4 from "wildstring";
7526
8083
  // src/cli/ui/complex/run-tests.ts
7527
8084
  import { log as log15 } from "@awsless/clui";
7528
8085
  import chalk4 from "chalk";
7529
- import { mkdir as mkdir4, readFile as readFile5, writeFile as writeFile3 } from "fs/promises";
7530
- import { join as join16 } from "path";
8086
+ import { mkdir as mkdir4, readFile as readFile6, writeFile as writeFile3 } from "fs/promises";
8087
+ import { join as join17 } from "path";
7531
8088
  import wildstring3 from "wildstring";
7532
8089
 
7533
8090
  // src/build/__fingerprint.ts
7534
- import { createHash as createHash5 } from "crypto";
7535
- import { readdir as readdir4, readFile as readFile4, stat as stat4 } from "fs/promises";
7536
- import { basename as basename4, dirname as dirname10, extname as extname3, join as join14 } from "path";
8091
+ import { createHash as createHash6 } from "crypto";
8092
+ import { readdir as readdir4, readFile as readFile5, stat as stat4 } from "fs/promises";
8093
+ import { basename as basename4, dirname as dirname10, extname as extname3, join as join15 } from "path";
7537
8094
  import parseStaticImports from "parse-static-imports";
7538
8095
  var extensions = ["js", "mjs", "jsx", "ts", "mts", "tsx"];
7539
8096
  var generateFileHashes = async (file, hashes) => {
@@ -7542,7 +8099,7 @@ var generateFileHashes = async (file, hashes) => {
7542
8099
  }
7543
8100
  const code = await readModuleFile(file);
7544
8101
  const deps = await findDependencies(file, code);
7545
- const hash = createHash5("sha1").update(code).digest();
8102
+ const hash = createHash6("sha1").update(code).digest();
7546
8103
  hashes.set(file, hash);
7547
8104
  for (const dep of deps) {
7548
8105
  if (dep.startsWith("/")) {
@@ -7555,11 +8112,11 @@ var fingerprintFromDirectory = async (dir) => {
7555
8112
  const files = await readdir4(dir, { recursive: true });
7556
8113
  for (const file of files) {
7557
8114
  if (extensions.includes(extname3(file).substring(1)) && file.at(0) !== "_") {
7558
- await generateFileHashes(join14(dir, file), hashes);
8115
+ await generateFileHashes(join15(dir, file), hashes);
7559
8116
  }
7560
8117
  }
7561
8118
  const merge2 = Buffer.concat(Array.from(hashes.values()).sort());
7562
- return createHash5("sha1").update(merge2).digest("hex");
8119
+ return createHash6("sha1").update(merge2).digest("hex");
7563
8120
  };
7564
8121
  var readModuleFile = (file) => {
7565
8122
  if (file.endsWith(".js")) {
@@ -7569,17 +8126,17 @@ var readModuleFile = (file) => {
7569
8126
  return readFiles([
7570
8127
  file,
7571
8128
  ...extensions.map((exp) => `${file}.${exp}`),
7572
- ...extensions.map((exp) => join14(file, `/index.${exp}`))
8129
+ ...extensions.map((exp) => join15(file, `/index.${exp}`))
7573
8130
  ]);
7574
8131
  }
7575
- return readFile4(file, "utf8");
8132
+ return readFile5(file, "utf8");
7576
8133
  };
7577
8134
  var readFiles = async (files) => {
7578
8135
  for (const file of files) {
7579
8136
  try {
7580
8137
  const s = await stat4(file);
7581
8138
  if (s.isFile()) {
7582
- return readFile4(file, "utf8");
8139
+ return readFile5(file, "utf8");
7583
8140
  }
7584
8141
  } catch (_) {
7585
8142
  continue;
@@ -7589,7 +8146,7 @@ var readFiles = async (files) => {
7589
8146
  };
7590
8147
  var findDependencies = async (file, code) => {
7591
8148
  const imports = await parseStaticImports(code);
7592
- return imports.map((entry) => entry.moduleName).filter(Boolean).map((value) => value?.startsWith(".") ? join14(dirname10(file), value) : value);
8149
+ return imports.map((entry) => entry.moduleName).filter(Boolean).map((value) => value?.startsWith(".") ? join15(dirname10(file), value) : value);
7593
8150
  };
7594
8151
 
7595
8152
  // src/test/reporter.ts
@@ -7669,7 +8226,7 @@ var CustomReporter = class {
7669
8226
  import commonjs2 from "@rollup/plugin-commonjs";
7670
8227
  import json2 from "@rollup/plugin-json";
7671
8228
  import nodeResolve2 from "@rollup/plugin-node-resolve";
7672
- import { dirname as dirname11, join as join15 } from "path";
8229
+ import { dirname as dirname11, join as join16 } from "path";
7673
8230
  import { swc as swc2 } from "rollup-plugin-swc3";
7674
8231
  import { fileURLToPath as fileURLToPath4 } from "url";
7675
8232
  import { configDefaults } from "vitest/config";
@@ -7691,7 +8248,7 @@ var startTest = async (props) => {
7691
8248
  reporters: props.reporter,
7692
8249
  setupFiles: [
7693
8250
  //
7694
- join15(__dirname4, "test-global-setup.js")
8251
+ join16(__dirname4, "test-global-setup.js")
7695
8252
  ]
7696
8253
  // globalSetup: [
7697
8254
  // //
@@ -7781,10 +8338,10 @@ var logTestErrors = (event) => {
7781
8338
  var runTest = async (stack, dir, filters, opts) => {
7782
8339
  await mkdir4(directories.test, { recursive: true });
7783
8340
  const fingerprint = await fingerprintFromDirectory(dir);
7784
- const file = join16(directories.test, `${stack}.json`);
8341
+ const file = join17(directories.test, `${stack}.json`);
7785
8342
  const exists = await fileExist(file);
7786
8343
  if (exists && !process.env.NO_CACHE) {
7787
- const raw = await readFile5(file, { encoding: "utf8" });
8344
+ const raw = await readFile6(file, { encoding: "utf8" });
7788
8345
  const data = JSON.parse(raw);
7789
8346
  if (data.fingerprint === fingerprint) {
7790
8347
  log15.step(
@@ -8024,7 +8581,7 @@ var auth = (program2) => {
8024
8581
 
8025
8582
  // src/cli/command/bind.ts
8026
8583
  import { log as log17 } from "@awsless/clui";
8027
- import { constantCase as constantCase14 } from "change-case";
8584
+ import { constantCase as constantCase15 } from "change-case";
8028
8585
  import { spawn } from "child_process";
8029
8586
  var bind = (program2) => {
8030
8587
  program2.command("bind").argument("[command...]", "The command to execute").option("--config <string...>", "List of config values that will be accessable", (v) => v.split(",")).description(`Bind your site environment variables to a command`).action(async (commands9 = [], opts) => {
@@ -8053,10 +8610,10 @@ var bind = (program2) => {
8053
8610
  const configList = opts.config ?? [];
8054
8611
  const configs = {};
8055
8612
  for (const name of configList) {
8056
- configs[`CONFIG_${constantCase14(name)}`] = name;
8613
+ configs[`CONFIG_${constantCase15(name)}`] = name;
8057
8614
  }
8058
8615
  if (configList.length ?? 0 > 0) {
8059
- log17.note("Bind Config", configList.map((v) => color.label(constantCase14(v))).join("\n"));
8616
+ log17.note("Bind Config", configList.map((v) => color.label(constantCase15(v))).join("\n"));
8060
8617
  }
8061
8618
  if (commands9.length === 0) {
8062
8619
  return "No command to execute.";
@@ -8119,7 +8676,7 @@ import { log as log18 } from "@awsless/clui";
8119
8676
 
8120
8677
  // src/type-gen/generate.ts
8121
8678
  import { mkdir as mkdir5, writeFile as writeFile4 } from "fs/promises";
8122
- import { dirname as dirname12, join as join17, relative as relative7 } from "path";
8679
+ import { dirname as dirname12, join as join18, relative as relative7 } from "path";
8123
8680
  var generateTypes = async (props) => {
8124
8681
  const files = [];
8125
8682
  await Promise.all(
@@ -8128,7 +8685,7 @@ var generateTypes = async (props) => {
8128
8685
  ...props,
8129
8686
  async write(file, data, include = false) {
8130
8687
  const code = data?.toString("utf8");
8131
- const path = join17(directories.types, file);
8688
+ const path = join18(directories.types, file);
8132
8689
  if (code) {
8133
8690
  if (include) {
8134
8691
  files.push(relative7(directories.root, path));
@@ -8142,7 +8699,7 @@ var generateTypes = async (props) => {
8142
8699
  );
8143
8700
  if (files.length) {
8144
8701
  const code = files.map((file) => `/// <reference path='${file}' />`).join("\n");
8145
- await writeFile4(join17(directories.root, `awsless.d.ts`), code);
8702
+ await writeFile4(join18(directories.root, `awsless.d.ts`), code);
8146
8703
  }
8147
8704
  };
8148
8705