@awsless/awsless 0.0.543 → 0.0.545
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/app.json +1 -1
- package/dist/bin.js +154 -138
- package/dist/build-json-schema.js +43 -53
- package/dist/chunk-W4ED7XCC.js +9 -0
- package/dist/prebuild/icon/bundle.zip +0 -0
- package/dist/prebuild/image/bundle.zip +0 -0
- package/dist/prebuild/rpc/bundle.zip +0 -0
- package/dist/server.d.ts +5 -1
- package/dist/server.js +16 -0
- package/dist/stack.json +1 -1
- package/package.json +13 -13
package/dist/bin.js
CHANGED
|
@@ -1,4 +1,7 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
+
import {
|
|
3
|
+
shortId
|
|
4
|
+
} from "./chunk-W4ED7XCC.js";
|
|
2
5
|
|
|
3
6
|
// src/cli/program.ts
|
|
4
7
|
import { Command } from "commander";
|
|
@@ -1147,55 +1150,52 @@ var RpcSchema = z22.record(ResourceIdSchema, z22.record(z22.string(), FunctionSc
|
|
|
1147
1150
|
|
|
1148
1151
|
// src/feature/instance/schema.ts
|
|
1149
1152
|
import { days as days3, toDays as toDays2 } from "@awsless/duration";
|
|
1153
|
+
import { toMebibytes } from "@awsless/size";
|
|
1150
1154
|
import { z as z23 } from "zod";
|
|
1151
|
-
var
|
|
1152
|
-
|
|
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."
|
|
1155
|
+
var CpuSchema = z23.union([z23.literal(0.25), z23.literal(0.5), z23.literal(1), z23.literal(2), z23.literal(4), z23.literal(8), z23.literal(16)]).transform((v) => `${v} vCPU`).describe(
|
|
1156
|
+
"The number of virtual CPU units (vCPU) 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
1157
|
);
|
|
1162
|
-
var
|
|
1158
|
+
var validMemorySize = [
|
|
1163
1159
|
// 0.25 vCPU
|
|
1164
|
-
|
|
1165
|
-
|
|
1166
|
-
|
|
1160
|
+
512,
|
|
1161
|
+
1024,
|
|
1162
|
+
2048,
|
|
1167
1163
|
// 0.5 vCPU
|
|
1168
|
-
|
|
1169
|
-
|
|
1170
|
-
|
|
1171
|
-
|
|
1164
|
+
1024,
|
|
1165
|
+
2048,
|
|
1166
|
+
3072,
|
|
1167
|
+
4096,
|
|
1172
1168
|
// 1 vCPU
|
|
1173
|
-
|
|
1174
|
-
|
|
1175
|
-
|
|
1176
|
-
|
|
1177
|
-
|
|
1178
|
-
|
|
1179
|
-
|
|
1169
|
+
2048,
|
|
1170
|
+
3072,
|
|
1171
|
+
4096,
|
|
1172
|
+
5120,
|
|
1173
|
+
6144,
|
|
1174
|
+
7168,
|
|
1175
|
+
8192,
|
|
1180
1176
|
// 2 vCPU
|
|
1181
|
-
|
|
1182
|
-
|
|
1183
|
-
|
|
1184
|
-
|
|
1185
|
-
|
|
1186
|
-
|
|
1187
|
-
|
|
1188
|
-
|
|
1189
|
-
|
|
1190
|
-
|
|
1191
|
-
|
|
1192
|
-
|
|
1193
|
-
|
|
1194
|
-
]
|
|
1177
|
+
4096,
|
|
1178
|
+
5120,
|
|
1179
|
+
6144,
|
|
1180
|
+
7168,
|
|
1181
|
+
8192,
|
|
1182
|
+
9216,
|
|
1183
|
+
10240,
|
|
1184
|
+
11264,
|
|
1185
|
+
12288,
|
|
1186
|
+
13312,
|
|
1187
|
+
14336,
|
|
1188
|
+
15360,
|
|
1189
|
+
16384
|
|
1190
|
+
];
|
|
1191
|
+
var MemorySizeSchema2 = SizeSchema.refine(
|
|
1192
|
+
(s) => validMemorySize.includes(toMebibytes(s)),
|
|
1193
|
+
`Invalid memory size. Allowed sizes: ${validMemorySize.join(", ")} MiB`
|
|
1194
|
+
).describe(
|
|
1195
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
1196
|
);
|
|
1197
1197
|
var HealthCheckSchema = z23.object({
|
|
1198
|
-
|
|
1198
|
+
path: z23.string().describe("The path that the container runs to determine if it is healthy."),
|
|
1199
1199
|
interval: DurationSchema.describe("The time period in seconds between each health check execution."),
|
|
1200
1200
|
retries: z23.number().int().min(1).max(10).describe(
|
|
1201
1201
|
"The number of times to retry a failed health check before the container is considered unhealthy."
|
|
@@ -1207,13 +1207,6 @@ var HealthCheckSchema = z23.object({
|
|
|
1207
1207
|
"The time period in seconds to wait for a health check to succeed before it is considered a failure."
|
|
1208
1208
|
)
|
|
1209
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
1210
|
var EnvironmentSchema2 = z23.record(z23.string(), z23.string()).optional().describe("Environment variable key-value pairs.");
|
|
1218
1211
|
var ArchitectureSchema3 = z23.enum(["x86_64", "arm64"]).describe("The instruction set architecture that the function supports.");
|
|
1219
1212
|
var ActionSchema2 = z23.string();
|
|
@@ -1267,13 +1260,13 @@ var ISchema = z23.object({
|
|
|
1267
1260
|
description: DescriptionSchema2.optional(),
|
|
1268
1261
|
image: ImageSchema.optional(),
|
|
1269
1262
|
log: LogSchema2.optional(),
|
|
1263
|
+
cpu: CpuSchema.optional(),
|
|
1270
1264
|
memorySize: MemorySizeSchema2.optional(),
|
|
1271
|
-
cpuSize: CpuSizeSchema.optional(),
|
|
1272
1265
|
architecture: ArchitectureSchema3.optional(),
|
|
1273
1266
|
environment: EnvironmentSchema2.optional(),
|
|
1274
1267
|
permissions: PermissionsSchema2.optional(),
|
|
1275
|
-
healthCheck: HealthCheckSchema.optional()
|
|
1276
|
-
restartPolicy: RestartPolicySchema.optional()
|
|
1268
|
+
healthCheck: HealthCheckSchema.optional()
|
|
1269
|
+
// restartPolicy: RestartPolicySchema.optional(),
|
|
1277
1270
|
});
|
|
1278
1271
|
var InstanceSchema = z23.union([
|
|
1279
1272
|
LocalFileSchema.transform((code) => ({
|
|
@@ -1284,13 +1277,13 @@ var InstanceSchema = z23.union([
|
|
|
1284
1277
|
var InstancesSchema = z23.record(ResourceIdSchema, InstanceSchema).optional().describe("Define the instances in your stack.");
|
|
1285
1278
|
var InstanceDefaultSchema = z23.object({
|
|
1286
1279
|
image: ImageSchema.default("public.ecr.aws/aws-cli/aws-cli:amd64"),
|
|
1287
|
-
|
|
1288
|
-
|
|
1280
|
+
cpu: CpuSchema.default(0.25),
|
|
1281
|
+
memorySize: MemorySizeSchema2.default("512 MB"),
|
|
1289
1282
|
architecture: ArchitectureSchema3.default("arm64"),
|
|
1290
1283
|
environment: EnvironmentSchema2.optional(),
|
|
1291
1284
|
permissions: PermissionsSchema2.optional(),
|
|
1292
1285
|
healthCheck: HealthCheckSchema.optional(),
|
|
1293
|
-
restartPolicy: RestartPolicySchema.default({ enabled: true }),
|
|
1286
|
+
// restartPolicy: RestartPolicySchema.default({ enabled: true }),
|
|
1294
1287
|
log: LogSchema2.default(true).transform((log25) => ({
|
|
1295
1288
|
retention: log25.retention ?? days3(7)
|
|
1296
1289
|
}))
|
|
@@ -3010,7 +3003,7 @@ var zipFiles = (files) => {
|
|
|
3010
3003
|
|
|
3011
3004
|
// src/feature/function/util.ts
|
|
3012
3005
|
import { toDays as toDays4, toSeconds } from "@awsless/duration";
|
|
3013
|
-
import { toMebibytes } from "@awsless/size";
|
|
3006
|
+
import { toMebibytes as toMebibytes2 } from "@awsless/size";
|
|
3014
3007
|
import { pascalCase } from "change-case";
|
|
3015
3008
|
|
|
3016
3009
|
// src/util/cache.ts
|
|
@@ -3051,12 +3044,6 @@ var listAllFiles = async (list3) => {
|
|
|
3051
3044
|
return files;
|
|
3052
3045
|
};
|
|
3053
3046
|
|
|
3054
|
-
// src/util/id.ts
|
|
3055
|
-
import { createHash as createHash3 } from "crypto";
|
|
3056
|
-
var shortId = (ns) => {
|
|
3057
|
-
return createHash3("md5").update(ns).digest("hex").substring(0, 10);
|
|
3058
|
-
};
|
|
3059
|
-
|
|
3060
3047
|
// src/util/temp.ts
|
|
3061
3048
|
import { mkdir as mkdir3, readdir as readdir2, rm as rm2 } from "fs/promises";
|
|
3062
3049
|
import { join as join8 } from "path";
|
|
@@ -3298,7 +3285,7 @@ var createLambdaFunction = (parentGroup, ctx, ns, id, local) => {
|
|
|
3298
3285
|
runtime: props.runtime,
|
|
3299
3286
|
handler: props.handler,
|
|
3300
3287
|
timeout: toSeconds(props.timeout),
|
|
3301
|
-
memorySize:
|
|
3288
|
+
memorySize: toMebibytes2(props.memorySize),
|
|
3302
3289
|
architectures: [props.architecture],
|
|
3303
3290
|
timeouts: {
|
|
3304
3291
|
create: "30s",
|
|
@@ -3732,17 +3719,18 @@ import type { Mock } from 'vitest'
|
|
|
3732
3719
|
type Func = (...args: any[]) => any
|
|
3733
3720
|
|
|
3734
3721
|
type Invoke<N extends string, F extends Func> = unknown extends Parameters<F>[0] ? InvokeWithoutPayload<N, F> : InvokeWithPayload<N, F>
|
|
3722
|
+
type Options = Omit<InvokeOptions, 'name' | 'payload' | 'type'>
|
|
3735
3723
|
|
|
3736
3724
|
type InvokeWithPayload<Name extends string, F extends Func> = {
|
|
3737
3725
|
readonly name: Name
|
|
3738
|
-
readonly cached: (payload: Parameters<F>[0], options?:
|
|
3739
|
-
(payload: Parameters<F>[0], options?:
|
|
3726
|
+
readonly cached: (payload: Parameters<F>[0], options?: Options) => InvokeResponse<F>
|
|
3727
|
+
(payload: Parameters<F>[0], options?: Options): InvokeResponse<F>
|
|
3740
3728
|
}
|
|
3741
3729
|
|
|
3742
3730
|
type InvokeWithoutPayload<Name extends string, F extends Func> = {
|
|
3743
3731
|
readonly name: Name
|
|
3744
|
-
readonly cached: (payload?: Parameters<F>[0], options?:
|
|
3745
|
-
(payload?: Parameters<F>[0], options?:
|
|
3732
|
+
readonly cached: (payload?: Parameters<F>[0], options?: Options) => InvokeResponse<F>
|
|
3733
|
+
(payload?: Parameters<F>[0], options?: Options): InvokeResponse<F>
|
|
3746
3734
|
}
|
|
3747
3735
|
|
|
3748
3736
|
type Response<F extends Func> = PartialDeep<Awaited<InvokeResponse<F>>, { recurseIntoArrays: true }>
|
|
@@ -4290,7 +4278,7 @@ import { fileURLToPath } from "node:url";
|
|
|
4290
4278
|
// src/feature/function/prebuild.ts
|
|
4291
4279
|
import { days as days4, seconds as seconds6, toDays as toDays5, toSeconds as toSeconds4 } from "@awsless/duration";
|
|
4292
4280
|
import { $ as $12, Future as Future2, resolveInputs as resolveInputs2 } from "@awsless/formation";
|
|
4293
|
-
import { mebibytes as mebibytes2, toMebibytes as
|
|
4281
|
+
import { mebibytes as mebibytes2, toMebibytes as toMebibytes3 } from "@awsless/size";
|
|
4294
4282
|
import { pascalCase as pascalCase2 } from "change-case";
|
|
4295
4283
|
var createPrebuildLambdaFunction = (group, ctx, ns, id, props) => {
|
|
4296
4284
|
let name;
|
|
@@ -4382,7 +4370,7 @@ var createPrebuildLambdaFunction = (group, ctx, ns, id, props) => {
|
|
|
4382
4370
|
runtime: props.runtime,
|
|
4383
4371
|
handler: props.handler,
|
|
4384
4372
|
timeout: toSeconds4(props.timeout ?? seconds6(10)),
|
|
4385
|
-
memorySize:
|
|
4373
|
+
memorySize: toMebibytes3(props.memorySize ?? mebibytes2(128)),
|
|
4386
4374
|
architectures: [props.architecture ?? "arm64"],
|
|
4387
4375
|
layers: props.layers?.map((id2) => ctx.shared.entry("layer", "arn", id2)),
|
|
4388
4376
|
s3Bucket: code.bucket,
|
|
@@ -5057,7 +5045,7 @@ var execCommand = async ({ cwd, env, command }) => {
|
|
|
5057
5045
|
};
|
|
5058
5046
|
|
|
5059
5047
|
// src/feature/site/index.ts
|
|
5060
|
-
import { createHash as
|
|
5048
|
+
import { createHash as createHash3 } from "crypto";
|
|
5061
5049
|
import { Future as Future3 } from "@awsless/formation";
|
|
5062
5050
|
var siteFeature = defineFeature({
|
|
5063
5051
|
name: "site",
|
|
@@ -5362,7 +5350,7 @@ var siteFeature = defineFeature({
|
|
|
5362
5350
|
version: new Future3((resolve) => {
|
|
5363
5351
|
$combine(...versions).then((versions2) => {
|
|
5364
5352
|
const combined = versions2.filter((v) => !!v).sort().join(",");
|
|
5365
|
-
const version =
|
|
5353
|
+
const version = createHash3("sha1").update(combined).digest("hex");
|
|
5366
5354
|
resolve(version);
|
|
5367
5355
|
});
|
|
5368
5356
|
})
|
|
@@ -5748,21 +5736,26 @@ import { camelCase as camelCase7 } from "change-case";
|
|
|
5748
5736
|
import { relative as relative6 } from "path";
|
|
5749
5737
|
import { $ as $18 } from "@awsless/formation";
|
|
5750
5738
|
var typeGenCode6 = `
|
|
5739
|
+
import { Duration } from '@awsless/duration'
|
|
5751
5740
|
import { InvokeOptions } from '@awsless/lambda'
|
|
5752
5741
|
import type { Mock } from 'vitest'
|
|
5753
5742
|
|
|
5754
5743
|
type Func = (...args: any[]) => any
|
|
5755
5744
|
|
|
5745
|
+
type Options = Omit<InvokeOptions, 'name' | 'payload' | 'type'> & {
|
|
5746
|
+
schedule?: Duration | Date
|
|
5747
|
+
}
|
|
5748
|
+
|
|
5756
5749
|
type Invoke<N extends string, F extends Func> = unknown extends Parameters<F>[0] ? InvokeWithoutPayload<N, F> : InvokeWithPayload<N, F>
|
|
5757
5750
|
|
|
5758
5751
|
type InvokeWithPayload<Name extends string, F extends Func> = {
|
|
5759
5752
|
readonly name: Name
|
|
5760
|
-
(payload: Parameters<F>[0], options?:
|
|
5753
|
+
(payload: Parameters<F>[0], options?: Options): Promise<void>
|
|
5761
5754
|
}
|
|
5762
5755
|
|
|
5763
5756
|
type InvokeWithoutPayload<Name extends string, F extends Func> = {
|
|
5764
5757
|
readonly name: Name
|
|
5765
|
-
(payload?: Parameters<F>[0], options?:
|
|
5758
|
+
(payload?: Parameters<F>[0], options?: Options): Promise<void>
|
|
5766
5759
|
}
|
|
5767
5760
|
|
|
5768
5761
|
type MockHandle<F extends Func> = (payload: Parameters<F>[0]) => void | Promise<void> | Promise<Promise<void>>
|
|
@@ -6001,7 +5994,9 @@ var vpcFeature = defineFeature({
|
|
|
6001
5994
|
tags: {
|
|
6002
5995
|
Name: ctx.app.name
|
|
6003
5996
|
},
|
|
6004
|
-
cidrBlock: "10.0.0.0/16"
|
|
5997
|
+
cidrBlock: "10.0.0.0/16",
|
|
5998
|
+
enableDnsSupport: true,
|
|
5999
|
+
enableDnsHostnames: true
|
|
6005
6000
|
});
|
|
6006
6001
|
const privateRouteTable = new $20.aws.route.Table(group, "private", {
|
|
6007
6002
|
vpcId: vpc.id,
|
|
@@ -6803,26 +6798,28 @@ import { $ as $26, Group as Group26 } from "@awsless/formation";
|
|
|
6803
6798
|
// src/feature/instance/util.ts
|
|
6804
6799
|
import { toDays as toDays8, toSeconds as toSeconds10 } from "@awsless/duration";
|
|
6805
6800
|
import { $ as $25, Future as Future4, Group as Group25, resolveInputs as resolveInputs3 } from "@awsless/formation";
|
|
6801
|
+
import { toMebibytes as toMebibytes4 } from "@awsless/size";
|
|
6806
6802
|
import { generateFileHash as generateFileHash2 } from "@awsless/ts-file-cache";
|
|
6807
6803
|
import { constantCase as constantCase14, pascalCase as pascalCase3 } from "change-case";
|
|
6808
6804
|
import deepmerge4 from "deepmerge";
|
|
6805
|
+
import { join as join15 } from "path";
|
|
6809
6806
|
|
|
6810
6807
|
// src/feature/instance/build/executable.ts
|
|
6811
|
-
import {
|
|
6812
|
-
import { createHash as createHash5 } from "crypto";
|
|
6808
|
+
import { createHash as createHash4 } from "crypto";
|
|
6813
6809
|
import { readFile as readFile4 } from "fs/promises";
|
|
6814
6810
|
import { join as join14 } from "path";
|
|
6811
|
+
import { exec as exec2 } from "promisify-child-process";
|
|
6815
6812
|
var buildExecutable = async (input, outputPath) => {
|
|
6816
6813
|
const filePath = join14(outputPath, "program");
|
|
6817
6814
|
const args = ["build", input, "--compile", "--target", "bun-linux-x64-modern", "--outfile", filePath];
|
|
6818
6815
|
try {
|
|
6819
|
-
|
|
6816
|
+
await exec2(`bun ${args.join(" ")}`);
|
|
6820
6817
|
} catch (error) {
|
|
6821
|
-
throw new Error(`Executable build failed: ${error instanceof Error ? error.message :
|
|
6818
|
+
throw new Error(`Executable build failed: ${error instanceof Error ? error.message : JSON.stringify(error)}`);
|
|
6822
6819
|
}
|
|
6823
6820
|
const file = await readFile4(filePath);
|
|
6824
6821
|
return {
|
|
6825
|
-
hash:
|
|
6822
|
+
hash: createHash4("sha1").update(file).digest("hex"),
|
|
6826
6823
|
file
|
|
6827
6824
|
};
|
|
6828
6825
|
};
|
|
@@ -6856,9 +6853,9 @@ var createFargateTask = (parentGroup, ctx, ns, id, local) => {
|
|
|
6856
6853
|
});
|
|
6857
6854
|
const code = new $25.aws.s3.BucketObject(group, "code", {
|
|
6858
6855
|
bucket: ctx.shared.get("instance", "bucket-name"),
|
|
6859
|
-
key:
|
|
6856
|
+
key: name,
|
|
6860
6857
|
source: relativePath(getBuildPath("instance", name, "program")),
|
|
6861
|
-
sourceHash: $
|
|
6858
|
+
sourceHash: $file(getBuildPath("instance", name, "HASH"))
|
|
6862
6859
|
});
|
|
6863
6860
|
const executionRole = new $25.aws.iam.Role(group, "execution-role", {
|
|
6864
6861
|
name: shortId(`${shortName}:execution-role`),
|
|
@@ -6935,15 +6932,12 @@ var createFargateTask = (parentGroup, ctx, ns, id, local) => {
|
|
|
6935
6932
|
);
|
|
6936
6933
|
})
|
|
6937
6934
|
});
|
|
6938
|
-
const addPermission = (...permissions) => {
|
|
6939
|
-
statements.push(...permissions);
|
|
6940
|
-
policy.$.attachDependencies(permissions);
|
|
6941
|
-
};
|
|
6942
6935
|
ctx.onPermission((statement) => {
|
|
6943
|
-
|
|
6936
|
+
statements.push(statement);
|
|
6937
|
+
policy.$.attachDependencies(statement);
|
|
6944
6938
|
});
|
|
6945
6939
|
let logGroup;
|
|
6946
|
-
if (props.log.retention.value > 0n) {
|
|
6940
|
+
if (props.log.retention && props.log.retention.value > 0n) {
|
|
6947
6941
|
logGroup = new $25.aws.cloudwatch.LogGroup(group, "log", {
|
|
6948
6942
|
name: `/aws/ecs/${name}`,
|
|
6949
6943
|
retentionInDays: toDays8(props.log.retention)
|
|
@@ -6962,7 +6956,8 @@ var createFargateTask = (parentGroup, ctx, ns, id, local) => {
|
|
|
6962
6956
|
const tags = {
|
|
6963
6957
|
APP: ctx.appConfig.name,
|
|
6964
6958
|
APP_ID: ctx.appId,
|
|
6965
|
-
STACK: ctx.stackConfig.name
|
|
6959
|
+
STACK: ctx.stackConfig.name,
|
|
6960
|
+
CODE_HASH: code.sourceHash.pipe((v) => v)
|
|
6966
6961
|
};
|
|
6967
6962
|
const variables = {};
|
|
6968
6963
|
const task2 = new $25.aws.ecs.TaskDefinition(
|
|
@@ -6970,17 +6965,19 @@ var createFargateTask = (parentGroup, ctx, ns, id, local) => {
|
|
|
6970
6965
|
"task",
|
|
6971
6966
|
{
|
|
6972
6967
|
family: name,
|
|
6968
|
+
// family: 'test',
|
|
6973
6969
|
networkMode: "awsvpc",
|
|
6974
|
-
cpu: props.
|
|
6975
|
-
memory: props.memorySize.toString(),
|
|
6970
|
+
cpu: props.cpu,
|
|
6971
|
+
memory: toMebibytes4(props.memorySize).toString(),
|
|
6976
6972
|
requiresCompatibilities: ["FARGATE"],
|
|
6977
6973
|
executionRoleArn: executionRole.arn,
|
|
6978
6974
|
taskRoleArn: role.arn,
|
|
6979
|
-
trackLatest: true,
|
|
6980
6975
|
runtimePlatform: {
|
|
6981
6976
|
cpuArchitecture: constantCase14(props.architecture),
|
|
6982
6977
|
operatingSystemFamily: "LINUX"
|
|
6983
6978
|
},
|
|
6979
|
+
// trackLatest: false,
|
|
6980
|
+
// skipDestroy: true,
|
|
6984
6981
|
containerDefinitions: new Future4(async (resolve) => {
|
|
6985
6982
|
const data = await resolveInputs3(variables);
|
|
6986
6983
|
const { s3Bucket, s3Key } = await resolveInputs3({
|
|
@@ -6991,13 +6988,17 @@ var createFargateTask = (parentGroup, ctx, ns, id, local) => {
|
|
|
6991
6988
|
JSON.stringify([
|
|
6992
6989
|
{
|
|
6993
6990
|
name: `container-${id}`,
|
|
6991
|
+
essential: true,
|
|
6994
6992
|
image: props.image,
|
|
6995
6993
|
protocol: "tcp",
|
|
6996
6994
|
workingDirectory: "/usr/app",
|
|
6997
6995
|
entryPoint: ["sh", "-c"],
|
|
6998
6996
|
command: [
|
|
6999
|
-
|
|
7000
|
-
|
|
6997
|
+
[
|
|
6998
|
+
`aws s3 cp s3://${s3Bucket}/${s3Key} /usr/app/program`,
|
|
6999
|
+
`chmod +x /usr/app/program`,
|
|
7000
|
+
`/usr/app/program`
|
|
7001
|
+
].join(" && ")
|
|
7001
7002
|
],
|
|
7002
7003
|
environment: Object.entries(data).map(([name2, value]) => ({
|
|
7003
7004
|
name: name2,
|
|
@@ -7010,25 +7011,11 @@ var createFargateTask = (parentGroup, ctx, ns, id, local) => {
|
|
|
7010
7011
|
appProtocol: "http",
|
|
7011
7012
|
containerPort: 80,
|
|
7012
7013
|
hostPort: 80
|
|
7013
|
-
},
|
|
7014
|
-
{
|
|
7015
|
-
name: "https",
|
|
7016
|
-
protocol: "tcp",
|
|
7017
|
-
appProtocol: "http",
|
|
7018
|
-
containerPort: 443,
|
|
7019
|
-
hostPort: 443
|
|
7020
7014
|
}
|
|
7021
7015
|
],
|
|
7022
|
-
|
|
7023
|
-
|
|
7024
|
-
|
|
7025
|
-
...props.restartPolicy.ignoredExitCodes && {
|
|
7026
|
-
ignoredExitCodes: props.restartPolicy.ignoredExitCodes
|
|
7027
|
-
},
|
|
7028
|
-
...props.restartPolicy.restartAttemptPeriod && {
|
|
7029
|
-
restartAttemptPeriod: props.restartPolicy.restartAttemptPeriod
|
|
7030
|
-
}
|
|
7031
|
-
}
|
|
7016
|
+
restartPolicy: {
|
|
7017
|
+
enabled: true,
|
|
7018
|
+
restartAttemptPeriod: 60
|
|
7032
7019
|
},
|
|
7033
7020
|
...logGroup && {
|
|
7034
7021
|
logConfiguration: {
|
|
@@ -7043,7 +7030,10 @@ var createFargateTask = (parentGroup, ctx, ns, id, local) => {
|
|
|
7043
7030
|
}
|
|
7044
7031
|
},
|
|
7045
7032
|
healthCheck: props.healthCheck ? {
|
|
7046
|
-
command:
|
|
7033
|
+
command: [
|
|
7034
|
+
"CMD-SHELL",
|
|
7035
|
+
`curl -f http://${join15("localhost", props.healthCheck.path)} || exit 1`
|
|
7036
|
+
],
|
|
7047
7037
|
interval: toSeconds10(props.healthCheck.interval),
|
|
7048
7038
|
retries: props.healthCheck.retries,
|
|
7049
7039
|
startPeriod: toSeconds10(props.healthCheck.startPeriod),
|
|
@@ -7059,6 +7049,7 @@ var createFargateTask = (parentGroup, ctx, ns, id, local) => {
|
|
|
7059
7049
|
dependsOn: [code]
|
|
7060
7050
|
}
|
|
7061
7051
|
);
|
|
7052
|
+
return;
|
|
7062
7053
|
const securityGroup = new $25.aws.security.Group(group, "security-group", {
|
|
7063
7054
|
name,
|
|
7064
7055
|
description: "Security group for the instance",
|
|
@@ -7074,15 +7065,6 @@ var createFargateTask = (parentGroup, ctx, ns, id, local) => {
|
|
|
7074
7065
|
cidrIpv4: "0.0.0.0/0",
|
|
7075
7066
|
tags
|
|
7076
7067
|
});
|
|
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
7068
|
new $25.aws.vpc.SecurityGroupEgressRule(group, "egress-rule", {
|
|
7087
7069
|
securityGroupId: securityGroup.id,
|
|
7088
7070
|
description: `Allow all outbound traffic from the ${name} instance`,
|
|
@@ -7090,9 +7072,25 @@ var createFargateTask = (parentGroup, ctx, ns, id, local) => {
|
|
|
7090
7072
|
cidrIpv4: "0.0.0.0/0",
|
|
7091
7073
|
tags
|
|
7092
7074
|
});
|
|
7075
|
+
const discoveryService = new $25.aws.service.DiscoveryService(group, `service-discovery`, {
|
|
7076
|
+
name: shortId(`${ctx.stack.name}:${id}`),
|
|
7077
|
+
description: `Service discovery for the ${name} instance`,
|
|
7078
|
+
dnsConfig: {
|
|
7079
|
+
namespaceId: ctx.shared.get("instance", "namespace-id"),
|
|
7080
|
+
routingPolicy: "MULTIVALUE",
|
|
7081
|
+
dnsRecords: [
|
|
7082
|
+
{
|
|
7083
|
+
type: "A",
|
|
7084
|
+
ttl: 300
|
|
7085
|
+
}
|
|
7086
|
+
]
|
|
7087
|
+
},
|
|
7088
|
+
forceDestroy: true,
|
|
7089
|
+
tags
|
|
7090
|
+
});
|
|
7093
7091
|
const service = new $25.aws.ecs.Service(group, "service", {
|
|
7094
|
-
cluster: ctx.shared.get("instance", "cluster-arn"),
|
|
7095
7092
|
name,
|
|
7093
|
+
cluster: ctx.shared.get("instance", "cluster-arn"),
|
|
7096
7094
|
taskDefinition: task2.arn,
|
|
7097
7095
|
desiredCount: 1,
|
|
7098
7096
|
launchType: "FARGATE",
|
|
@@ -7102,16 +7100,19 @@ var createFargateTask = (parentGroup, ctx, ns, id, local) => {
|
|
|
7102
7100
|
assignPublicIp: true
|
|
7103
7101
|
},
|
|
7104
7102
|
forceNewDeployment: true,
|
|
7105
|
-
|
|
7106
|
-
|
|
7107
|
-
|
|
7108
|
-
|
|
7109
|
-
// forceDelete: true,
|
|
7103
|
+
forceDelete: true,
|
|
7104
|
+
serviceRegistries: {
|
|
7105
|
+
registryArn: discoveryService.arn
|
|
7106
|
+
},
|
|
7110
7107
|
// deploymentCircuitBreaker: {
|
|
7111
7108
|
// enable: true,
|
|
7112
7109
|
// rollback: true,
|
|
7113
7110
|
// },
|
|
7114
7111
|
// deploymentController: { type: 'ECS' },
|
|
7112
|
+
triggers: {
|
|
7113
|
+
redeployment: (/* @__PURE__ */ new Date()).toISOString()
|
|
7114
|
+
},
|
|
7115
|
+
tags
|
|
7115
7116
|
// The internal url (dnsName) doesn't work for ldambda's
|
|
7116
7117
|
// https://github.com/aws/containers-roadmap/issues/1960
|
|
7117
7118
|
// serviceConnectConfiguration: {
|
|
@@ -7146,6 +7147,20 @@ var createFargateTask = (parentGroup, ctx, ns, id, local) => {
|
|
|
7146
7147
|
// src/feature/instance/index.ts
|
|
7147
7148
|
var instanceFeature = defineFeature({
|
|
7148
7149
|
name: "instance",
|
|
7150
|
+
async onTypeGen(ctx) {
|
|
7151
|
+
const gen = new TypeFile("@awsless/awsless");
|
|
7152
|
+
const resources2 = new TypeObject(1);
|
|
7153
|
+
for (const stack of ctx.stackConfigs) {
|
|
7154
|
+
const list3 = new TypeObject(2);
|
|
7155
|
+
for (const name of Object.keys(stack.instances ?? {})) {
|
|
7156
|
+
const endpoint = `http://${shortId(`${stack.name}:${name}`)}.${ctx.appConfig.name}`;
|
|
7157
|
+
list3.addType(name, `'${endpoint}'`);
|
|
7158
|
+
}
|
|
7159
|
+
resources2.addType(stack.name, list3);
|
|
7160
|
+
}
|
|
7161
|
+
gen.addInterface("InstanceResources", resources2);
|
|
7162
|
+
await ctx.write("instance.d.ts", gen, true);
|
|
7163
|
+
},
|
|
7149
7164
|
onBefore(ctx) {
|
|
7150
7165
|
const group = new Group26(ctx.base, "instance", "asset");
|
|
7151
7166
|
const bucket = new $26.aws.s3.Bucket(group, "bucket", {
|
|
@@ -7177,6 +7192,7 @@ var instanceFeature = defineFeature({
|
|
|
7177
7192
|
description: `Private DNS namespace for ${ctx.app.name}`
|
|
7178
7193
|
});
|
|
7179
7194
|
ctx.shared.set("instance", "namespace", namespace.name);
|
|
7195
|
+
ctx.shared.set("instance", "namespace-id", namespace.id);
|
|
7180
7196
|
},
|
|
7181
7197
|
onStack(ctx) {
|
|
7182
7198
|
for (const [id, props] of Object.entries(ctx.stackConfig.instances ?? {})) {
|
|
@@ -8084,13 +8100,13 @@ import wildstring4 from "wildstring";
|
|
|
8084
8100
|
import { log as log15 } from "@awsless/clui";
|
|
8085
8101
|
import chalk4 from "chalk";
|
|
8086
8102
|
import { mkdir as mkdir4, readFile as readFile6, writeFile as writeFile3 } from "fs/promises";
|
|
8087
|
-
import { join as
|
|
8103
|
+
import { join as join18 } from "path";
|
|
8088
8104
|
import wildstring3 from "wildstring";
|
|
8089
8105
|
|
|
8090
8106
|
// src/build/__fingerprint.ts
|
|
8091
|
-
import { createHash as
|
|
8107
|
+
import { createHash as createHash5 } from "crypto";
|
|
8092
8108
|
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
|
|
8109
|
+
import { basename as basename4, dirname as dirname10, extname as extname3, join as join16 } from "path";
|
|
8094
8110
|
import parseStaticImports from "parse-static-imports";
|
|
8095
8111
|
var extensions = ["js", "mjs", "jsx", "ts", "mts", "tsx"];
|
|
8096
8112
|
var generateFileHashes = async (file, hashes) => {
|
|
@@ -8099,7 +8115,7 @@ var generateFileHashes = async (file, hashes) => {
|
|
|
8099
8115
|
}
|
|
8100
8116
|
const code = await readModuleFile(file);
|
|
8101
8117
|
const deps = await findDependencies(file, code);
|
|
8102
|
-
const hash =
|
|
8118
|
+
const hash = createHash5("sha1").update(code).digest();
|
|
8103
8119
|
hashes.set(file, hash);
|
|
8104
8120
|
for (const dep of deps) {
|
|
8105
8121
|
if (dep.startsWith("/")) {
|
|
@@ -8112,11 +8128,11 @@ var fingerprintFromDirectory = async (dir) => {
|
|
|
8112
8128
|
const files = await readdir4(dir, { recursive: true });
|
|
8113
8129
|
for (const file of files) {
|
|
8114
8130
|
if (extensions.includes(extname3(file).substring(1)) && file.at(0) !== "_") {
|
|
8115
|
-
await generateFileHashes(
|
|
8131
|
+
await generateFileHashes(join16(dir, file), hashes);
|
|
8116
8132
|
}
|
|
8117
8133
|
}
|
|
8118
8134
|
const merge2 = Buffer.concat(Array.from(hashes.values()).sort());
|
|
8119
|
-
return
|
|
8135
|
+
return createHash5("sha1").update(merge2).digest("hex");
|
|
8120
8136
|
};
|
|
8121
8137
|
var readModuleFile = (file) => {
|
|
8122
8138
|
if (file.endsWith(".js")) {
|
|
@@ -8126,7 +8142,7 @@ var readModuleFile = (file) => {
|
|
|
8126
8142
|
return readFiles([
|
|
8127
8143
|
file,
|
|
8128
8144
|
...extensions.map((exp) => `${file}.${exp}`),
|
|
8129
|
-
...extensions.map((exp) =>
|
|
8145
|
+
...extensions.map((exp) => join16(file, `/index.${exp}`))
|
|
8130
8146
|
]);
|
|
8131
8147
|
}
|
|
8132
8148
|
return readFile5(file, "utf8");
|
|
@@ -8146,7 +8162,7 @@ var readFiles = async (files) => {
|
|
|
8146
8162
|
};
|
|
8147
8163
|
var findDependencies = async (file, code) => {
|
|
8148
8164
|
const imports = await parseStaticImports(code);
|
|
8149
|
-
return imports.map((entry) => entry.moduleName).filter(Boolean).map((value) => value?.startsWith(".") ?
|
|
8165
|
+
return imports.map((entry) => entry.moduleName).filter(Boolean).map((value) => value?.startsWith(".") ? join16(dirname10(file), value) : value);
|
|
8150
8166
|
};
|
|
8151
8167
|
|
|
8152
8168
|
// src/test/reporter.ts
|
|
@@ -8226,7 +8242,7 @@ var CustomReporter = class {
|
|
|
8226
8242
|
import commonjs2 from "@rollup/plugin-commonjs";
|
|
8227
8243
|
import json2 from "@rollup/plugin-json";
|
|
8228
8244
|
import nodeResolve2 from "@rollup/plugin-node-resolve";
|
|
8229
|
-
import { dirname as dirname11, join as
|
|
8245
|
+
import { dirname as dirname11, join as join17 } from "path";
|
|
8230
8246
|
import { swc as swc2 } from "rollup-plugin-swc3";
|
|
8231
8247
|
import { fileURLToPath as fileURLToPath4 } from "url";
|
|
8232
8248
|
import { configDefaults } from "vitest/config";
|
|
@@ -8248,7 +8264,7 @@ var startTest = async (props) => {
|
|
|
8248
8264
|
reporters: props.reporter,
|
|
8249
8265
|
setupFiles: [
|
|
8250
8266
|
//
|
|
8251
|
-
|
|
8267
|
+
join17(__dirname4, "test-global-setup.js")
|
|
8252
8268
|
]
|
|
8253
8269
|
// globalSetup: [
|
|
8254
8270
|
// //
|
|
@@ -8338,7 +8354,7 @@ var logTestErrors = (event) => {
|
|
|
8338
8354
|
var runTest = async (stack, dir, filters, opts) => {
|
|
8339
8355
|
await mkdir4(directories.test, { recursive: true });
|
|
8340
8356
|
const fingerprint = await fingerprintFromDirectory(dir);
|
|
8341
|
-
const file =
|
|
8357
|
+
const file = join18(directories.test, `${stack}.json`);
|
|
8342
8358
|
const exists = await fileExist(file);
|
|
8343
8359
|
if (exists && !process.env.NO_CACHE) {
|
|
8344
8360
|
const raw = await readFile6(file, { encoding: "utf8" });
|
|
@@ -8676,7 +8692,7 @@ import { log as log18 } from "@awsless/clui";
|
|
|
8676
8692
|
|
|
8677
8693
|
// src/type-gen/generate.ts
|
|
8678
8694
|
import { mkdir as mkdir5, writeFile as writeFile4 } from "fs/promises";
|
|
8679
|
-
import { dirname as dirname12, join as
|
|
8695
|
+
import { dirname as dirname12, join as join19, relative as relative7 } from "path";
|
|
8680
8696
|
var generateTypes = async (props) => {
|
|
8681
8697
|
const files = [];
|
|
8682
8698
|
await Promise.all(
|
|
@@ -8685,7 +8701,7 @@ var generateTypes = async (props) => {
|
|
|
8685
8701
|
...props,
|
|
8686
8702
|
async write(file, data, include = false) {
|
|
8687
8703
|
const code = data?.toString("utf8");
|
|
8688
|
-
const path =
|
|
8704
|
+
const path = join19(directories.types, file);
|
|
8689
8705
|
if (code) {
|
|
8690
8706
|
if (include) {
|
|
8691
8707
|
files.push(relative7(directories.root, path));
|
|
@@ -8699,7 +8715,7 @@ var generateTypes = async (props) => {
|
|
|
8699
8715
|
);
|
|
8700
8716
|
if (files.length) {
|
|
8701
8717
|
const code = files.map((file) => `/// <reference path='${file}' />`).join("\n");
|
|
8702
|
-
await writeFile4(
|
|
8718
|
+
await writeFile4(join19(directories.root, `awsless.d.ts`), code);
|
|
8703
8719
|
}
|
|
8704
8720
|
};
|
|
8705
8721
|
|