sst 2.0.16 → 2.0.18
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/bootstrap.js +6 -4
- package/cli/commands/secrets/set.js +3 -1
- package/package.json +1 -1
- package/runtime/handlers/python.js +1 -0
- package/sst.mjs +34 -21
- package/stacks/app-metadata.js +4 -6
- package/stacks/metadata.js +8 -11
package/bootstrap.js
CHANGED
|
@@ -3,7 +3,7 @@ import path from "path";
|
|
|
3
3
|
import { bold, dim } from "colorette";
|
|
4
4
|
import { spawn } from "child_process";
|
|
5
5
|
import { DescribeStacksCommand, CloudFormationClient, } from "@aws-sdk/client-cloudformation";
|
|
6
|
-
import { Tags, Stack, RemovalPolicy, App, CfnOutput } from "aws-cdk-lib";
|
|
6
|
+
import { Duration, Tags, Stack, RemovalPolicy, App, CfnOutput, } from "aws-cdk-lib";
|
|
7
7
|
import { Function, Runtime, Code } from "aws-cdk-lib/aws-lambda";
|
|
8
8
|
import { SqsEventSource } from "aws-cdk-lib/aws-lambda-event-sources";
|
|
9
9
|
import { PolicyStatement } from "aws-cdk-lib/aws-iam";
|
|
@@ -21,7 +21,7 @@ import { Stacks } from "./stacks/index.js";
|
|
|
21
21
|
const STACK_NAME = "SSTBootstrap";
|
|
22
22
|
const OUTPUT_VERSION = "Version";
|
|
23
23
|
const OUTPUT_BUCKET = "BucketName";
|
|
24
|
-
const LATEST_VERSION = "
|
|
24
|
+
const LATEST_VERSION = "7";
|
|
25
25
|
const __dirname = url.fileURLToPath(new URL(".", import.meta.url));
|
|
26
26
|
export const useBootstrap = Context.memo(async () => {
|
|
27
27
|
Logger.debug("Initializing bootstrap context");
|
|
@@ -80,7 +80,6 @@ async function loadCDKStatus() {
|
|
|
80
80
|
throw e;
|
|
81
81
|
}
|
|
82
82
|
}
|
|
83
|
-
return false;
|
|
84
83
|
}
|
|
85
84
|
export async function bootstrapSST(tags) {
|
|
86
85
|
// Create bootstrap stack
|
|
@@ -127,7 +126,10 @@ export async function bootstrapSST(tags) {
|
|
|
127
126
|
}),
|
|
128
127
|
],
|
|
129
128
|
});
|
|
130
|
-
const queue = new Queue(stack, "MetadataQueue"
|
|
129
|
+
const queue = new Queue(stack, "MetadataQueue", {
|
|
130
|
+
visibilityTimeout: Duration.seconds(30),
|
|
131
|
+
retentionPeriod: Duration.minutes(2),
|
|
132
|
+
});
|
|
131
133
|
fn.addEventSource(new SqsEventSource(queue));
|
|
132
134
|
const rule = new Rule(stack, "MetadataRule", {
|
|
133
135
|
eventPattern: {
|
|
@@ -25,5 +25,7 @@ export const set = (program) => program.command("set <name> <value>", "Set the v
|
|
|
25
25
|
setting.succeed();
|
|
26
26
|
const restarting = createSpinner(` Restarting all functions using ${blue(args.name)}...`).start();
|
|
27
27
|
const count = await Config.restart(args.name);
|
|
28
|
-
restarting.succeed(
|
|
28
|
+
restarting.succeed(count === 1
|
|
29
|
+
? ` Restarted ${count} function`
|
|
30
|
+
: ` Restarted ${count} functions`);
|
|
29
31
|
});
|
package/package.json
CHANGED
|
@@ -78,6 +78,7 @@ export const usePythonHandler = Context.memo(async () => {
|
|
|
78
78
|
const src = await findAbove(input.props.handler, "requirements.txt");
|
|
79
79
|
await fs.cp(src, input.out, {
|
|
80
80
|
recursive: true,
|
|
81
|
+
filter: (src) => !src.includes(".sst"),
|
|
81
82
|
});
|
|
82
83
|
if (input.props.python?.installCommands) {
|
|
83
84
|
for (const cmd of input.props.python.installCommands) {
|
package/sst.mjs
CHANGED
|
@@ -2488,8 +2488,8 @@ var init_workers = __esm({
|
|
|
2488
2488
|
import { IoTClient, DescribeEndpointCommand } from "@aws-sdk/client-iot";
|
|
2489
2489
|
import iot from "aws-iot-device-sdk";
|
|
2490
2490
|
function encode(input) {
|
|
2491
|
-
const
|
|
2492
|
-
const parts =
|
|
2491
|
+
const json = JSON.stringify(input);
|
|
2492
|
+
const parts = json.match(/.{1,100000}/g);
|
|
2493
2493
|
if (!parts)
|
|
2494
2494
|
return [];
|
|
2495
2495
|
const id = Math.random().toString();
|
|
@@ -2627,7 +2627,14 @@ import {
|
|
|
2627
2627
|
DescribeStacksCommand,
|
|
2628
2628
|
CloudFormationClient
|
|
2629
2629
|
} from "@aws-sdk/client-cloudformation";
|
|
2630
|
-
import {
|
|
2630
|
+
import {
|
|
2631
|
+
Duration,
|
|
2632
|
+
Tags,
|
|
2633
|
+
Stack,
|
|
2634
|
+
RemovalPolicy,
|
|
2635
|
+
App,
|
|
2636
|
+
CfnOutput
|
|
2637
|
+
} from "aws-cdk-lib";
|
|
2631
2638
|
import { Function, Runtime, Code } from "aws-cdk-lib/aws-lambda";
|
|
2632
2639
|
import { SqsEventSource } from "aws-cdk-lib/aws-lambda-event-sources";
|
|
2633
2640
|
import { PolicyStatement } from "aws-cdk-lib/aws-iam";
|
|
@@ -2665,7 +2672,6 @@ async function loadCDKStatus() {
|
|
|
2665
2672
|
throw e;
|
|
2666
2673
|
}
|
|
2667
2674
|
}
|
|
2668
|
-
return false;
|
|
2669
2675
|
}
|
|
2670
2676
|
async function bootstrapSST(tags) {
|
|
2671
2677
|
const project = useProject();
|
|
@@ -2710,7 +2716,10 @@ async function bootstrapSST(tags) {
|
|
|
2710
2716
|
})
|
|
2711
2717
|
]
|
|
2712
2718
|
});
|
|
2713
|
-
const queue = new Queue(stack, "MetadataQueue"
|
|
2719
|
+
const queue = new Queue(stack, "MetadataQueue", {
|
|
2720
|
+
visibilityTimeout: Duration.seconds(30),
|
|
2721
|
+
retentionPeriod: Duration.minutes(2)
|
|
2722
|
+
});
|
|
2714
2723
|
fn.addEventSource(new SqsEventSource(queue));
|
|
2715
2724
|
const rule = new Rule(stack, "MetadataRule", {
|
|
2716
2725
|
eventPattern: {
|
|
@@ -2836,7 +2845,7 @@ var init_bootstrap = __esm({
|
|
|
2836
2845
|
STACK_NAME = "SSTBootstrap";
|
|
2837
2846
|
OUTPUT_VERSION = "Version";
|
|
2838
2847
|
OUTPUT_BUCKET = "BucketName";
|
|
2839
|
-
LATEST_VERSION = "
|
|
2848
|
+
LATEST_VERSION = "7";
|
|
2840
2849
|
__dirname = url3.fileURLToPath(new URL(".", import.meta.url));
|
|
2841
2850
|
useBootstrap = Context.memo(async () => {
|
|
2842
2851
|
Logger.debug("Initializing bootstrap context");
|
|
@@ -2875,7 +2884,6 @@ import {
|
|
|
2875
2884
|
PutObjectCommand,
|
|
2876
2885
|
DeleteObjectCommand
|
|
2877
2886
|
} from "@aws-sdk/client-s3";
|
|
2878
|
-
import { json } from "stream/consumers";
|
|
2879
2887
|
async function metadata() {
|
|
2880
2888
|
Logger.debug("Fetching app metadata");
|
|
2881
2889
|
const [project, credentials, bootstrap2] = await Promise.all([
|
|
@@ -2893,8 +2901,9 @@ async function metadata() {
|
|
|
2893
2901
|
Key: useS3Key(),
|
|
2894
2902
|
Bucket: bootstrap2.bucket
|
|
2895
2903
|
})
|
|
2896
|
-
)
|
|
2897
|
-
|
|
2904
|
+
);
|
|
2905
|
+
const body = await result.Body.transformToString();
|
|
2906
|
+
return JSON.parse(body);
|
|
2898
2907
|
} catch (ex) {
|
|
2899
2908
|
Logger.debug("Fetching app metadata: not found");
|
|
2900
2909
|
}
|
|
@@ -4468,7 +4477,6 @@ import {
|
|
|
4468
4477
|
GetObjectCommand as GetObjectCommand2,
|
|
4469
4478
|
ListObjectsV2Command
|
|
4470
4479
|
} from "@aws-sdk/client-s3";
|
|
4471
|
-
import { json as json2 } from "stream/consumers";
|
|
4472
4480
|
async function metadata2() {
|
|
4473
4481
|
Logger.debug("Fetching all metadata");
|
|
4474
4482
|
const project = useProject();
|
|
@@ -4496,8 +4504,9 @@ async function metadata2() {
|
|
|
4496
4504
|
Key: obj.Key,
|
|
4497
4505
|
Bucket: bootstrap2.bucket
|
|
4498
4506
|
})
|
|
4499
|
-
)
|
|
4500
|
-
|
|
4507
|
+
);
|
|
4508
|
+
const body = await result2.Body.transformToString();
|
|
4509
|
+
return [stackID, JSON.parse(body)];
|
|
4501
4510
|
}) || []
|
|
4502
4511
|
)
|
|
4503
4512
|
);
|
|
@@ -4522,8 +4531,9 @@ async function metadataForStack(stackID) {
|
|
|
4522
4531
|
Key: key,
|
|
4523
4532
|
Bucket: bootstrap2.bucket
|
|
4524
4533
|
})
|
|
4525
|
-
)
|
|
4526
|
-
|
|
4534
|
+
);
|
|
4535
|
+
const body = await result.Body.transformToString();
|
|
4536
|
+
return JSON.parse(body);
|
|
4527
4537
|
} catch (ex) {
|
|
4528
4538
|
console.error(ex);
|
|
4529
4539
|
return [];
|
|
@@ -4865,14 +4875,14 @@ var init_node = __esm({
|
|
|
4865
4875
|
}
|
|
4866
4876
|
if (input.mode === "deploy" && nodejs.install) {
|
|
4867
4877
|
const src = await find2(parsed.dir, "package.json");
|
|
4868
|
-
const
|
|
4878
|
+
const json = JSON.parse(
|
|
4869
4879
|
await fs10.readFile(path10.join(src, "package.json")).then((x) => x.toString())
|
|
4870
4880
|
);
|
|
4871
4881
|
fs10.writeFile(
|
|
4872
4882
|
path10.join(input.out, "package.json"),
|
|
4873
4883
|
JSON.stringify({
|
|
4874
4884
|
dependencies: Object.fromEntries(
|
|
4875
|
-
nodejs.install?.map((x) => [x,
|
|
4885
|
+
nodejs.install?.map((x) => [x, json.dependencies?.[x] || "*"])
|
|
4876
4886
|
)
|
|
4877
4887
|
})
|
|
4878
4888
|
);
|
|
@@ -5132,7 +5142,8 @@ var init_python = __esm({
|
|
|
5132
5142
|
};
|
|
5133
5143
|
const src = await findAbove(input.props.handler, "requirements.txt");
|
|
5134
5144
|
await fs12.cp(src, input.out, {
|
|
5135
|
-
recursive: true
|
|
5145
|
+
recursive: true,
|
|
5146
|
+
filter: (src2) => !src2.includes(".sst")
|
|
5136
5147
|
});
|
|
5137
5148
|
if (input.props.python?.installCommands) {
|
|
5138
5149
|
for (const cmd of input.props.python.installCommands) {
|
|
@@ -6260,7 +6271,7 @@ var init_config = __esm({
|
|
|
6260
6271
|
});
|
|
6261
6272
|
|
|
6262
6273
|
// src/cli/sst.ts
|
|
6263
|
-
import { blue as blue3, red
|
|
6274
|
+
import { blue as blue3, red } from "colorette";
|
|
6264
6275
|
|
|
6265
6276
|
// src/cli/program.ts
|
|
6266
6277
|
import yargs from "yargs";
|
|
@@ -6927,7 +6938,7 @@ var get = (program2) => program2.command(
|
|
|
6927
6938
|
describe: "Get the fallback value"
|
|
6928
6939
|
}),
|
|
6929
6940
|
async (args) => {
|
|
6930
|
-
const { red:
|
|
6941
|
+
const { red: red2 } = await import("colorette");
|
|
6931
6942
|
const { Config: Config2 } = await Promise.resolve().then(() => (init_config(), config_exports));
|
|
6932
6943
|
const { Colors: Colors2 } = await Promise.resolve().then(() => (init_colors(), colors_exports));
|
|
6933
6944
|
try {
|
|
@@ -7058,7 +7069,9 @@ var set = (program2) => program2.command(
|
|
|
7058
7069
|
` Restarting all functions using ${blue4(args.name)}...`
|
|
7059
7070
|
).start();
|
|
7060
7071
|
const count = await Config2.restart(args.name);
|
|
7061
|
-
restarting.succeed(
|
|
7072
|
+
restarting.succeed(
|
|
7073
|
+
count === 1 ? ` Restarted ${count} function` : ` Restarted ${count} functions`
|
|
7074
|
+
);
|
|
7062
7075
|
}
|
|
7063
7076
|
);
|
|
7064
7077
|
|
|
@@ -7428,7 +7441,7 @@ process.on("uncaughtException", (err) => {
|
|
|
7428
7441
|
if (spinner.isSpinning)
|
|
7429
7442
|
spinner.fail(spinner.text);
|
|
7430
7443
|
}
|
|
7431
|
-
console.log(
|
|
7444
|
+
console.log(red("Error:"), err.message);
|
|
7432
7445
|
if (!(err instanceof VisibleError)) {
|
|
7433
7446
|
console.log();
|
|
7434
7447
|
console.trace(err.stack);
|
package/stacks/app-metadata.js
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { useBootstrap } from "../bootstrap.js";
|
|
2
2
|
import { useAWSCredentials } from "../credentials.js";
|
|
3
3
|
import { S3Client, GetObjectCommand, PutObjectCommand, DeleteObjectCommand, } from "@aws-sdk/client-s3";
|
|
4
|
-
import { json } from "stream/consumers";
|
|
5
4
|
import { Context } from "../context/context.js";
|
|
6
5
|
import { Logger } from "../logger.js";
|
|
7
6
|
import { useProject } from "../project.js";
|
|
@@ -17,13 +16,12 @@ async function metadata() {
|
|
|
17
16
|
credentials,
|
|
18
17
|
});
|
|
19
18
|
try {
|
|
20
|
-
const result = await s3
|
|
21
|
-
.send(new GetObjectCommand({
|
|
19
|
+
const result = await s3.send(new GetObjectCommand({
|
|
22
20
|
Key: useS3Key(),
|
|
23
21
|
Bucket: bootstrap.bucket,
|
|
24
|
-
}))
|
|
25
|
-
|
|
26
|
-
return
|
|
22
|
+
}));
|
|
23
|
+
const body = await result.Body.transformToString();
|
|
24
|
+
return JSON.parse(body);
|
|
27
25
|
}
|
|
28
26
|
catch (ex) {
|
|
29
27
|
Logger.debug("Fetching app metadata: not found");
|
package/stacks/metadata.js
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { useBootstrap } from "../bootstrap.js";
|
|
2
2
|
import { useAWSCredentials, useAWSCredentialsProvider, } from "../credentials.js";
|
|
3
3
|
import { S3Client, GetObjectCommand, ListObjectsV2Command, } from "@aws-sdk/client-s3";
|
|
4
|
-
import { json } from "stream/consumers";
|
|
5
4
|
import { useCache } from "../cache.js";
|
|
6
5
|
import { Context } from "../context/context.js";
|
|
7
6
|
import { useBus } from "../bus.js";
|
|
@@ -25,13 +24,12 @@ export async function metadata() {
|
|
|
25
24
|
}));
|
|
26
25
|
const result = Object.fromEntries(await Promise.all(list.Contents?.map(async (obj) => {
|
|
27
26
|
const stackID = obj.Key?.split("/").pop();
|
|
28
|
-
const result = await s3
|
|
29
|
-
.send(new GetObjectCommand({
|
|
27
|
+
const result = await s3.send(new GetObjectCommand({
|
|
30
28
|
Key: obj.Key,
|
|
31
29
|
Bucket: bootstrap.bucket,
|
|
32
|
-
}))
|
|
33
|
-
|
|
34
|
-
return [stackID,
|
|
30
|
+
}));
|
|
31
|
+
const body = await result.Body.transformToString();
|
|
32
|
+
return [stackID, JSON.parse(body)];
|
|
35
33
|
}) || []));
|
|
36
34
|
Logger.debug("Fetched metadata from", list.KeyCount, "stacks");
|
|
37
35
|
return result;
|
|
@@ -49,13 +47,12 @@ export async function metadataForStack(stackID) {
|
|
|
49
47
|
const key = `stackMetadata/app.${project.config.name}/stage.${project.config.stage}/stack.${stackID}.json`;
|
|
50
48
|
Logger.debug("Getting metadata", key, "from", bootstrap.bucket);
|
|
51
49
|
try {
|
|
52
|
-
const result = await s3
|
|
53
|
-
.send(new GetObjectCommand({
|
|
50
|
+
const result = await s3.send(new GetObjectCommand({
|
|
54
51
|
Key: key,
|
|
55
52
|
Bucket: bootstrap.bucket,
|
|
56
|
-
}))
|
|
57
|
-
|
|
58
|
-
return
|
|
53
|
+
}));
|
|
54
|
+
const body = await result.Body.transformToString();
|
|
55
|
+
return JSON.parse(body);
|
|
59
56
|
}
|
|
60
57
|
catch (ex) {
|
|
61
58
|
console.error(ex);
|