@awsless/awsless 0.0.567 → 0.0.568
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 +48 -74
- package/dist/build-json-schema.js +5 -4
- package/dist/stack.json +1 -1
- package/package.json +12 -12
- package/dist/prebuild/icon/HASH +0 -1
- package/dist/prebuild/icon/bundle.zip +0 -0
- package/dist/prebuild/image/HASH +0 -1
- package/dist/prebuild/image/bundle.zip +0 -0
- package/dist/prebuild/rpc/HASH +0 -1
- package/dist/prebuild/rpc/bundle.zip +0 -0
package/dist/bin.js
CHANGED
|
@@ -1078,7 +1078,7 @@ var QueueDefaultSchema = z19.object({
|
|
|
1078
1078
|
maxBatchingWindow: MaxBatchingWindow.optional()
|
|
1079
1079
|
}).default({});
|
|
1080
1080
|
var QueueSchema = z19.object({
|
|
1081
|
-
consumer: FunctionSchema.describe("The consuming lambda function properties."),
|
|
1081
|
+
consumer: FunctionSchema.describe("The consuming lambda function properties.").optional(),
|
|
1082
1082
|
retentionPeriod: RetentionPeriodSchema.optional(),
|
|
1083
1083
|
visibilityTimeout: VisibilityTimeoutSchema.optional(),
|
|
1084
1084
|
deliveryDelay: DeliveryDelaySchema.optional(),
|
|
@@ -1211,6 +1211,7 @@ var HealthCheckSchema = z23.object({
|
|
|
1211
1211
|
)
|
|
1212
1212
|
}).describe("The health check command and associated configuration parameters for the container.");
|
|
1213
1213
|
var EnvironmentSchema2 = z23.record(z23.string(), z23.string()).optional().describe("Environment variable key-value pairs.");
|
|
1214
|
+
var ArchitectureSchema3 = z23.enum(["x86_64", "arm64"]).describe("The instruction set architecture that the instance supports.");
|
|
1214
1215
|
var ActionSchema2 = z23.string();
|
|
1215
1216
|
var ActionsSchema2 = z23.union([ActionSchema2.transform((v) => [v]), ActionSchema2.array()]);
|
|
1216
1217
|
var ArnSchema2 = z23.string().startsWith("arn:");
|
|
@@ -1262,7 +1263,7 @@ var ISchema = z23.object({
|
|
|
1262
1263
|
log: LogSchema2.optional(),
|
|
1263
1264
|
cpu: CpuSchema.optional(),
|
|
1264
1265
|
memorySize: MemorySizeSchema2.optional(),
|
|
1265
|
-
|
|
1266
|
+
architecture: ArchitectureSchema3.optional(),
|
|
1266
1267
|
environment: EnvironmentSchema2.optional(),
|
|
1267
1268
|
permissions: PermissionsSchema2.optional(),
|
|
1268
1269
|
healthCheck: HealthCheckSchema.optional()
|
|
@@ -1276,10 +1277,10 @@ var InstanceSchema = z23.union([
|
|
|
1276
1277
|
]);
|
|
1277
1278
|
var InstancesSchema = z23.record(ResourceIdSchema, InstanceSchema).optional().describe("Define the instances in your stack.");
|
|
1278
1279
|
var InstanceDefaultSchema = z23.object({
|
|
1279
|
-
image: ImageSchema.
|
|
1280
|
+
image: ImageSchema.optional(),
|
|
1280
1281
|
cpu: CpuSchema.default(0.25),
|
|
1281
1282
|
memorySize: MemorySizeSchema2.default("512 MB"),
|
|
1282
|
-
|
|
1283
|
+
architecture: ArchitectureSchema3.default("arm64"),
|
|
1283
1284
|
environment: EnvironmentSchema2.optional(),
|
|
1284
1285
|
permissions: PermissionsSchema2.optional(),
|
|
1285
1286
|
healthCheck: HealthCheckSchema.optional(),
|
|
@@ -4163,7 +4164,7 @@ var queueFeature = defineFeature({
|
|
|
4163
4164
|
resourceType: "queue",
|
|
4164
4165
|
resourceName: name
|
|
4165
4166
|
});
|
|
4166
|
-
if ("file" in props.consumer.code) {
|
|
4167
|
+
if (props.consumer && "file" in props.consumer.code) {
|
|
4167
4168
|
const relFile = relative4(directories.types, props.consumer.code.file);
|
|
4168
4169
|
gen.addImport(varName, relFile);
|
|
4169
4170
|
mock.addType(name, `MockBuilder<typeof ${varName}>`);
|
|
@@ -4206,34 +4207,36 @@ var queueFeature = defineFeature({
|
|
|
4206
4207
|
})
|
|
4207
4208
|
)
|
|
4208
4209
|
});
|
|
4209
|
-
|
|
4210
|
-
|
|
4211
|
-
|
|
4212
|
-
|
|
4213
|
-
|
|
4214
|
-
|
|
4215
|
-
|
|
4216
|
-
|
|
4217
|
-
|
|
4218
|
-
|
|
4219
|
-
|
|
4220
|
-
|
|
4210
|
+
if (local.consumer) {
|
|
4211
|
+
const lambdaConsumer = createLambdaFunction(group, ctx, `queue`, id, local.consumer);
|
|
4212
|
+
lambdaConsumer.setEnvironment("LOG_VIEWABLE_ERROR", "1");
|
|
4213
|
+
new $10.aws.lambda.EventSourceMapping(
|
|
4214
|
+
group,
|
|
4215
|
+
"event",
|
|
4216
|
+
{
|
|
4217
|
+
functionName: lambdaConsumer.lambda.functionName,
|
|
4218
|
+
eventSourceArn: queue2.arn,
|
|
4219
|
+
batchSize: props.batchSize,
|
|
4220
|
+
maximumBatchingWindowInSeconds: props.maxBatchingWindow && toSeconds3(props.maxBatchingWindow),
|
|
4221
|
+
scalingConfig: {
|
|
4222
|
+
maximumConcurrency: props.maxConcurrency
|
|
4223
|
+
}
|
|
4224
|
+
},
|
|
4225
|
+
{
|
|
4226
|
+
dependsOn: [lambdaConsumer.policy]
|
|
4221
4227
|
}
|
|
4222
|
-
|
|
4223
|
-
{
|
|
4224
|
-
|
|
4225
|
-
|
|
4226
|
-
|
|
4227
|
-
|
|
4228
|
-
actions: ["sqs:ReceiveMessage", "sqs:DeleteMessage", "sqs:GetQueueAttributes"],
|
|
4229
|
-
resources: [queue2.arn]
|
|
4230
|
-
});
|
|
4228
|
+
);
|
|
4229
|
+
lambdaConsumer.addPermission({
|
|
4230
|
+
actions: ["sqs:ReceiveMessage", "sqs:DeleteMessage", "sqs:GetQueueAttributes"],
|
|
4231
|
+
resources: [queue2.arn]
|
|
4232
|
+
});
|
|
4233
|
+
}
|
|
4231
4234
|
ctx.addEnv(`QUEUE_${constantCase6(ctx.stack.name)}_${constantCase6(id)}_URL`, queue2.url);
|
|
4232
4235
|
ctx.addStackPermission({
|
|
4233
4236
|
actions: [
|
|
4234
|
-
//
|
|
4235
4237
|
"sqs:SendMessage",
|
|
4236
4238
|
"sqs:ReceiveMessage",
|
|
4239
|
+
"sqs:DeleteMessage",
|
|
4237
4240
|
"sqs:GetQueueUrl",
|
|
4238
4241
|
"sqs:GetQueueAttributes"
|
|
4239
4242
|
],
|
|
@@ -6928,7 +6931,7 @@ import { toDays as toDays8, toSeconds as toSeconds10 } from "@awsless/duration";
|
|
|
6928
6931
|
import { $ as $25, Future as Future4, Group as Group25, resolveInputs as resolveInputs3 } from "@awsless/formation";
|
|
6929
6932
|
import { toMebibytes as toMebibytes4 } from "@awsless/size";
|
|
6930
6933
|
import { generateFileHash as generateFileHash2 } from "@awsless/ts-file-cache";
|
|
6931
|
-
import { pascalCase as pascalCase3 } from "change-case";
|
|
6934
|
+
import { constantCase as constantCase14, pascalCase as pascalCase3 } from "change-case";
|
|
6932
6935
|
import deepmerge4 from "deepmerge";
|
|
6933
6936
|
import { join as join16 } from "path";
|
|
6934
6937
|
|
|
@@ -6937,9 +6940,10 @@ import { createHash as createHash4 } from "crypto";
|
|
|
6937
6940
|
import { readFile as readFile4 } from "fs/promises";
|
|
6938
6941
|
import { join as join15 } from "path";
|
|
6939
6942
|
import { exec as exec2 } from "promisify-child-process";
|
|
6940
|
-
var buildExecutable = async (input, outputPath) => {
|
|
6943
|
+
var buildExecutable = async (input, outputPath, architecture) => {
|
|
6941
6944
|
const filePath = join15(outputPath, "program");
|
|
6942
|
-
const
|
|
6945
|
+
const target = architecture === "x86_64" ? "bun-linux-x64-modern" : "bun-linux-arm64-modern";
|
|
6946
|
+
const args = ["build", input, "--compile", "--target", target, "--outfile", filePath];
|
|
6943
6947
|
try {
|
|
6944
6948
|
await exec2(`bun ${args.join(" ")}`);
|
|
6945
6949
|
} catch (error) {
|
|
@@ -6963,11 +6967,12 @@ var createFargateTask = (parentGroup, ctx, ns, id, local) => {
|
|
|
6963
6967
|
});
|
|
6964
6968
|
const shortName = shortId(`${ctx.app.name}:${ctx.stack.name}:${ns}:${id}:${ctx.appId}`);
|
|
6965
6969
|
const props = deepmerge4(ctx.appConfig.defaults.instance, local);
|
|
6970
|
+
const image2 = props.image || (props.architecture === "arm64" ? "public.ecr.aws/aws-cli/aws-cli:arm64" : "public.ecr.aws/aws-cli/aws-cli:amd64");
|
|
6966
6971
|
ctx.registerBuild("instance", name, async (build3, { workspace }) => {
|
|
6967
6972
|
const fingerprint = await generateFileHash2(workspace, local.code.file);
|
|
6968
6973
|
return build3(fingerprint, async (write) => {
|
|
6969
6974
|
const temp = await createTempFolder(`instance--${name}`);
|
|
6970
|
-
const executable = await buildExecutable(local.code.file, temp.path);
|
|
6975
|
+
const executable = await buildExecutable(local.code.file, temp.path, props.architecture);
|
|
6971
6976
|
await Promise.all([
|
|
6972
6977
|
//
|
|
6973
6978
|
write("HASH", executable.hash),
|
|
@@ -7086,7 +7091,6 @@ var createFargateTask = (parentGroup, ctx, ns, id, local) => {
|
|
|
7086
7091
|
APP: ctx.appConfig.name,
|
|
7087
7092
|
APP_ID: ctx.appId,
|
|
7088
7093
|
STACK: ctx.stackConfig.name
|
|
7089
|
-
// CODE_HASH: code.sourceHash.pipe<string>(v => v!),
|
|
7090
7094
|
};
|
|
7091
7095
|
const variables = {};
|
|
7092
7096
|
const task2 = new $25.aws.ecs.TaskDefinition(
|
|
@@ -7101,7 +7105,7 @@ var createFargateTask = (parentGroup, ctx, ns, id, local) => {
|
|
|
7101
7105
|
executionRoleArn: executionRole.arn,
|
|
7102
7106
|
taskRoleArn: role.arn,
|
|
7103
7107
|
runtimePlatform: {
|
|
7104
|
-
cpuArchitecture:
|
|
7108
|
+
cpuArchitecture: constantCase14(props.architecture),
|
|
7105
7109
|
operatingSystemFamily: "LINUX"
|
|
7106
7110
|
},
|
|
7107
7111
|
trackLatest: true,
|
|
@@ -7116,7 +7120,7 @@ var createFargateTask = (parentGroup, ctx, ns, id, local) => {
|
|
|
7116
7120
|
{
|
|
7117
7121
|
name: `container-${id}`,
|
|
7118
7122
|
essential: true,
|
|
7119
|
-
image:
|
|
7123
|
+
image: image2,
|
|
7120
7124
|
protocol: "tcp",
|
|
7121
7125
|
workingDirectory: "/usr/app",
|
|
7122
7126
|
entryPoint: ["sh", "-c"],
|
|
@@ -7208,22 +7212,6 @@ var createFargateTask = (parentGroup, ctx, ns, id, local) => {
|
|
|
7208
7212
|
cidrIpv4: "0.0.0.0/0",
|
|
7209
7213
|
tags
|
|
7210
7214
|
});
|
|
7211
|
-
const discoveryService = new $25.aws.service.DiscoveryService(group, `service-discovery`, {
|
|
7212
|
-
name: shortId(`${ctx.stack.name}:${id}`),
|
|
7213
|
-
description: `Service discovery for the ${name} instance`,
|
|
7214
|
-
dnsConfig: {
|
|
7215
|
-
namespaceId: ctx.shared.get("instance", "namespace-id"),
|
|
7216
|
-
routingPolicy: "MULTIVALUE",
|
|
7217
|
-
dnsRecords: [
|
|
7218
|
-
{
|
|
7219
|
-
type: "A",
|
|
7220
|
-
ttl: 300
|
|
7221
|
-
}
|
|
7222
|
-
]
|
|
7223
|
-
},
|
|
7224
|
-
forceDestroy: true,
|
|
7225
|
-
tags
|
|
7226
|
-
});
|
|
7227
7215
|
const service = new $25.aws.ecs.Service(group, "service", {
|
|
7228
7216
|
name,
|
|
7229
7217
|
cluster: ctx.shared.get("instance", "cluster-arn"),
|
|
@@ -7234,34 +7222,20 @@ var createFargateTask = (parentGroup, ctx, ns, id, local) => {
|
|
|
7234
7222
|
subnets: ctx.shared.get("vpc", "public-subnets"),
|
|
7235
7223
|
securityGroups: [securityGroup.id],
|
|
7236
7224
|
assignPublicIp: true
|
|
7225
|
+
// https://stackoverflow.com/questions/76398247/cannotpullcontainererror-pull-image-manifest-has-been-retried-5-times-failed
|
|
7237
7226
|
},
|
|
7238
7227
|
forceNewDeployment: true,
|
|
7239
7228
|
forceDelete: true,
|
|
7240
|
-
serviceRegistries: {
|
|
7241
|
-
registryArn: discoveryService.arn
|
|
7242
|
-
},
|
|
7243
7229
|
// deploymentCircuitBreaker: {
|
|
7244
7230
|
// enable: true,
|
|
7245
7231
|
// rollback: true,
|
|
7246
7232
|
// },
|
|
7247
7233
|
// deploymentController: { type: 'ECS' },
|
|
7248
7234
|
tags
|
|
7249
|
-
|
|
7250
|
-
|
|
7251
|
-
|
|
7252
|
-
|
|
7253
|
-
// namespace: ctx.shared.get('instance', 'namespace'),
|
|
7254
|
-
// service: [
|
|
7255
|
-
// {
|
|
7256
|
-
// clientAlias: {
|
|
7257
|
-
// port: 80,
|
|
7258
|
-
// dnsName: `${id}.${ctx.app.name}.internal`,
|
|
7259
|
-
// },
|
|
7260
|
-
// discoveryName: name,
|
|
7261
|
-
// portName: 'http',
|
|
7262
|
-
// },
|
|
7263
|
-
// ],
|
|
7264
|
-
// },
|
|
7235
|
+
});
|
|
7236
|
+
ctx.onEnv((name2, value) => {
|
|
7237
|
+
variables[name2] = value;
|
|
7238
|
+
task2.$.attachDependencies(value);
|
|
7265
7239
|
});
|
|
7266
7240
|
variables.APP = ctx.appConfig.name;
|
|
7267
7241
|
variables.APP_ID = ctx.appId;
|
|
@@ -7337,7 +7311,7 @@ var instanceFeature = defineFeature({
|
|
|
7337
7311
|
|
|
7338
7312
|
// src/feature/metric/index.ts
|
|
7339
7313
|
import { $ as $27, Group as Group27 } from "@awsless/formation";
|
|
7340
|
-
import { kebabCase as kebabCase8, constantCase as
|
|
7314
|
+
import { kebabCase as kebabCase8, constantCase as constantCase15 } from "change-case";
|
|
7341
7315
|
import { toSeconds as toSeconds11 } from "@awsless/duration";
|
|
7342
7316
|
var typeGenCode9 = `
|
|
7343
7317
|
import { type PutDataProps, putData, batchPutData } from '@awsless/cloudwatch'
|
|
@@ -7405,7 +7379,7 @@ var metricFeature = defineFeature({
|
|
|
7405
7379
|
});
|
|
7406
7380
|
for (const [id, props] of Object.entries(ctx.stackConfig.metrics ?? {})) {
|
|
7407
7381
|
const group = new Group27(ctx.stack, "metric", id);
|
|
7408
|
-
ctx.addEnv(`METRIC_${
|
|
7382
|
+
ctx.addEnv(`METRIC_${constantCase15(id)}`, props.type);
|
|
7409
7383
|
for (const alarmId in props.alarms ?? []) {
|
|
7410
7384
|
const alarmGroup = new Group27(group, "alarm", alarmId);
|
|
7411
7385
|
const alarmName = kebabCase8(`${id}-${alarmId}`);
|
|
@@ -8922,7 +8896,7 @@ var auth = (program2) => {
|
|
|
8922
8896
|
|
|
8923
8897
|
// src/cli/command/bind.ts
|
|
8924
8898
|
import { log as log18 } from "@awsless/clui";
|
|
8925
|
-
import { constantCase as
|
|
8899
|
+
import { constantCase as constantCase16 } from "change-case";
|
|
8926
8900
|
import { spawn } from "child_process";
|
|
8927
8901
|
var bind = (program2) => {
|
|
8928
8902
|
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) => {
|
|
@@ -8951,10 +8925,10 @@ var bind = (program2) => {
|
|
|
8951
8925
|
const configList = opts.config ?? [];
|
|
8952
8926
|
const configs = {};
|
|
8953
8927
|
for (const name of configList) {
|
|
8954
|
-
configs[`CONFIG_${
|
|
8928
|
+
configs[`CONFIG_${constantCase16(name)}`] = name;
|
|
8955
8929
|
}
|
|
8956
8930
|
if (configList.length ?? 0 > 0) {
|
|
8957
|
-
log18.note("Bind Config", configList.map((v) => color.label(
|
|
8931
|
+
log18.note("Bind Config", configList.map((v) => color.label(constantCase16(v))).join("\n"));
|
|
8958
8932
|
}
|
|
8959
8933
|
if (commands9.length === 0) {
|
|
8960
8934
|
return "No command to execute.";
|
|
@@ -470,7 +470,7 @@ var QueueDefaultSchema = z16.object({
|
|
|
470
470
|
maxBatchingWindow: MaxBatchingWindow.optional()
|
|
471
471
|
}).default({});
|
|
472
472
|
var QueueSchema = z16.object({
|
|
473
|
-
consumer: FunctionSchema.describe("The consuming lambda function properties."),
|
|
473
|
+
consumer: FunctionSchema.describe("The consuming lambda function properties.").optional(),
|
|
474
474
|
retentionPeriod: RetentionPeriodSchema.optional(),
|
|
475
475
|
visibilityTimeout: VisibilityTimeoutSchema.optional(),
|
|
476
476
|
deliveryDelay: DeliveryDelaySchema.optional(),
|
|
@@ -603,6 +603,7 @@ var HealthCheckSchema = z20.object({
|
|
|
603
603
|
)
|
|
604
604
|
}).describe("The health check command and associated configuration parameters for the container.");
|
|
605
605
|
var EnvironmentSchema2 = z20.record(z20.string(), z20.string()).optional().describe("Environment variable key-value pairs.");
|
|
606
|
+
var ArchitectureSchema3 = z20.enum(["x86_64", "arm64"]).describe("The instruction set architecture that the instance supports.");
|
|
606
607
|
var ActionSchema2 = z20.string();
|
|
607
608
|
var ActionsSchema2 = z20.union([ActionSchema2.transform((v) => [v]), ActionSchema2.array()]);
|
|
608
609
|
var ArnSchema2 = z20.string().startsWith("arn:");
|
|
@@ -654,7 +655,7 @@ var ISchema = z20.object({
|
|
|
654
655
|
log: LogSchema2.optional(),
|
|
655
656
|
cpu: CpuSchema.optional(),
|
|
656
657
|
memorySize: MemorySizeSchema2.optional(),
|
|
657
|
-
|
|
658
|
+
architecture: ArchitectureSchema3.optional(),
|
|
658
659
|
environment: EnvironmentSchema2.optional(),
|
|
659
660
|
permissions: PermissionsSchema2.optional(),
|
|
660
661
|
healthCheck: HealthCheckSchema.optional()
|
|
@@ -668,10 +669,10 @@ var InstanceSchema = z20.union([
|
|
|
668
669
|
]);
|
|
669
670
|
var InstancesSchema = z20.record(ResourceIdSchema, InstanceSchema).optional().describe("Define the instances in your stack.");
|
|
670
671
|
var InstanceDefaultSchema = z20.object({
|
|
671
|
-
image: ImageSchema.
|
|
672
|
+
image: ImageSchema.optional(),
|
|
672
673
|
cpu: CpuSchema.default(0.25),
|
|
673
674
|
memorySize: MemorySizeSchema2.default("512 MB"),
|
|
674
|
-
|
|
675
|
+
architecture: ArchitectureSchema3.default("arm64"),
|
|
675
676
|
environment: EnvironmentSchema2.optional(),
|
|
676
677
|
permissions: PermissionsSchema2.optional(),
|
|
677
678
|
healthCheck: HealthCheckSchema.optional(),
|