sst 2.23.3 → 2.23.4

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.
@@ -1,5 +1,6 @@
1
- const PACKAGE_MATCH = ["aws-cdk", "@aws-cdk"];
1
+ import { VisibleError } from "../../error.js";
2
2
  const FIELDS = ["dependencies", "devDependencies"];
3
+ const SST_PKGS = ["sst", "astro-sst", "svelte-kit-sst", "solid-start-sst"];
3
4
  export const update = (program) => program.command("update [version]", "Update your SST and CDK packages", (yargs) => yargs.positional("version", {
4
5
  type: "string",
5
6
  describe: "Optionally specify a version to update to",
@@ -9,7 +10,42 @@ export const update = (program) => program.command("update [version]", "Update y
9
10
  const { fetch } = await import("undici");
10
11
  const { useProject } = await import("../../project.js");
11
12
  const { Colors } = await import("../colors.js");
12
- async function find(dir) {
13
+ const project = useProject();
14
+ const files = await findAllPackageJson(project.paths.root);
15
+ const metadata = await fetch(`https://registry.npmjs.org/sst/${args.version || "latest"}`).then((resp) => resp.json());
16
+ const allChanges = new Map();
17
+ const allOldPackages = new Map();
18
+ // Update all package.json files
19
+ await Promise.all(files.map(updatePackageJson));
20
+ // Print status
21
+ if (allOldPackages.size > 0) {
22
+ for (const [file, pkgs] of allOldPackages.entries()) {
23
+ Colors.line(Colors.danger(`✖ `), Colors.bold.dim(path.relative(project.paths.root, file)));
24
+ for (const [pkg, version] of pkgs) {
25
+ Colors.line(Colors.dim(` ${pkg}@${version}`));
26
+ }
27
+ }
28
+ Colors.gap();
29
+ throw new VisibleError("We've detected AWS CDK v1 dependencies in your package.json. SST requires CDK v2. Please update to CDK v2 dependencies, and then execute `sst update`. For guidance, refer to the official AWS CDK migration documentation — https://docs.aws.amazon.com/cdk/v2/guide/migrating-v2.html#migrating-v2-v1-upgrade");
30
+ }
31
+ // Print status
32
+ if (allChanges.size === 0) {
33
+ Colors.line(Colors.success(`✔ `), `Already using v${metadata.version}`);
34
+ return;
35
+ }
36
+ for (const [file, pkgs] of allChanges.entries()) {
37
+ Colors.line(Colors.success(`✔ `), Colors.bold.dim(path.relative(project.paths.root, file)));
38
+ for (const [pkg, version] of pkgs) {
39
+ Colors.line(Colors.dim(` ${pkg}@${version}`));
40
+ }
41
+ }
42
+ Colors.gap();
43
+ Colors.line(`${Colors.primary(`➜`)} ${Colors.warning("Make sure to run: npm install (or pnpm install, or yarn)")}`);
44
+ process.exit(0);
45
+ /////////////
46
+ // Helpers
47
+ /////////////
48
+ async function findAllPackageJson(dir) {
13
49
  const children = await fs.readdir(dir);
14
50
  const tasks = children.map(async (item) => {
15
51
  if (item === "node_modules")
@@ -22,69 +58,53 @@ export const update = (program) => program.command("update [version]", "Update y
22
58
  return [full];
23
59
  const stat = await fs.stat(full);
24
60
  if (stat.isDirectory())
25
- return find(full);
61
+ return findAllPackageJson(full);
26
62
  return [];
27
63
  });
28
64
  return (await Promise.all(tasks)).flat();
29
65
  }
30
- const project = useProject();
31
- const files = await find(project.paths.root);
32
- const metadata = await fetch(`https://registry.npmjs.org/sst/${args.version || "latest"}`).then((resp) => resp.json());
33
- const results = new Map();
34
- const tasks = files.map(async (file) => {
66
+ async function updatePackageJson(file) {
67
+ const changes = new Set();
68
+ const oldPackages = new Set();
35
69
  const data = await fs.readFile(file).then((x) => x.toString());
36
- // Note: preserve ending new line characters in package.json
37
- const tailingNewline = data.match(/\r?\n$/)?.[0];
38
70
  const json = JSON.parse(data);
71
+ // Update versions
39
72
  for (const field of FIELDS) {
40
73
  const deps = json[field];
41
74
  for (const [pkg, existing] of Object.entries(deps || {})) {
42
75
  const desired = (() => {
43
- if ([
44
- "sst",
45
- "astro-sst",
46
- "svelte-kit-sst",
47
- "solid-start-sst",
48
- ].includes(pkg)) {
76
+ if (SST_PKGS.includes(pkg)) {
49
77
  return metadata.version;
50
78
  }
51
79
  else if (pkg === "constructs") {
52
80
  return metadata.dependencies.constructs;
53
81
  }
54
- else if (pkg.startsWith("aws-cdk") ||
55
- pkg.startsWith("@aws-cdk")) {
56
- return pkg.endsWith("alpha")
57
- ? metadata.dependencies["@aws-cdk/aws-apigatewayv2-alpha"]
58
- : metadata.dependencies["aws-cdk-lib"];
82
+ else if (pkg === "aws-cdk-lib") {
83
+ return metadata.dependencies["aws-cdk-lib"];
84
+ }
85
+ else if (pkg.startsWith("@aws-cdk/aws-")) {
86
+ if (!pkg.endsWith("-alpha")) {
87
+ oldPackages.add([pkg, existing]);
88
+ return;
89
+ }
90
+ return metadata.dependencies["@aws-cdk/aws-apigatewayv2-alpha"];
59
91
  }
60
92
  })();
61
93
  if (!desired || existing === desired)
62
94
  continue;
63
- let arr = results.get(file);
64
- if (!arr) {
65
- arr = new Set();
66
- results.set(file, arr);
67
- }
68
- arr.add([pkg, desired]);
95
+ changes.add([pkg, desired]);
69
96
  deps[pkg] = desired;
70
97
  }
71
98
  }
72
- if (results.has(file)) {
99
+ // Write to package.json
100
+ if (changes.size > 0) {
101
+ // note: preserve ending new line characters in package.json
102
+ const tailingNewline = data.match(/\r?\n$/)?.[0];
73
103
  await fs.writeFile(file, `${JSON.stringify(json, null, 2)}${tailingNewline ?? ""}`);
104
+ allChanges.set(file, changes);
74
105
  }
75
- });
76
- await Promise.all(tasks);
77
- if (results.size === 0) {
78
- Colors.line(Colors.success(`✔ `), `Already using v${metadata.version}`);
79
- return;
80
- }
81
- for (const [file, pkgs] of results.entries()) {
82
- Colors.line(Colors.success(`✔ `), Colors.bold.dim(path.relative(project.paths.root, file)));
83
- for (const [pkg, version] of pkgs) {
84
- Colors.line(Colors.dim(` ${pkg}@${version}`));
106
+ if (oldPackages.size > 0) {
107
+ allOldPackages.set(file, oldPackages);
85
108
  }
86
109
  }
87
- Colors.gap();
88
- Colors.line(`${Colors.primary(`➜`)} ${Colors.warning("Make sure to run: npm install (or pnpm install, or yarn)")}`);
89
- process.exit(0);
90
110
  });
@@ -18,7 +18,7 @@ import { createAppContext } from "./context.js";
18
18
  import { useWarning } from "./util/warning.js";
19
19
  import { Architecture, AssetCode, Code, Function as CDKFunction, FunctionUrlAuthType, Handler as CDKHandler, LayerVersion, Runtime as CDKRuntime, Tracing, } from "aws-cdk-lib/aws-lambda";
20
20
  import { RetentionDays } from "aws-cdk-lib/aws-logs";
21
- import { Token, Size as CDKSize, Duration as CDKDuration, } from "aws-cdk-lib/core";
21
+ import { Token, Size as CDKSize, Duration as CDKDuration, IgnoreMode, } from "aws-cdk-lib/core";
22
22
  import { Effect, PolicyStatement } from "aws-cdk-lib/aws-iam";
23
23
  import { StringParameter } from "aws-cdk-lib/aws-ssm";
24
24
  import { Platform } from "aws-cdk-lib/aws-ecr-assets";
@@ -202,6 +202,8 @@ export class Function extends CDKFunction {
202
202
  ...(props.container?.file
203
203
  ? { file: props.container.file }
204
204
  : {}),
205
+ exclude: [".sst"],
206
+ ignoreMode: IgnoreMode.GLOB,
205
207
  }),
206
208
  handler: CDKHandler.FROM_IMAGE,
207
209
  runtime: CDKRuntime.FROM_IMAGE,
package/constructs/Job.js CHANGED
@@ -2,7 +2,7 @@ import url from "url";
2
2
  import path from "path";
3
3
  import fs from "fs/promises";
4
4
  import { Construct } from "constructs";
5
- import { Duration as CdkDuration } from "aws-cdk-lib/core";
5
+ import { Duration as CdkDuration, IgnoreMode } from "aws-cdk-lib/core";
6
6
  import { Platform } from "aws-cdk-lib/aws-ecr-assets";
7
7
  import { PolicyStatement, Effect } from "aws-cdk-lib/aws-iam";
8
8
  import { AssetCode, Code, Runtime, Function as CdkFunction, } from "aws-cdk-lib/aws-lambda";
@@ -213,6 +213,8 @@ export class Job extends Construct {
213
213
  ? Platform.custom("linux/arm64")
214
214
  : Platform.custom("linux/amd64"),
215
215
  file: container?.file,
216
+ exclude: [".sst"],
217
+ ignoreMode: IgnoreMode.GLOB,
216
218
  });
217
219
  image.repository?.grantPull(this.job.role);
218
220
  const project = this.job.node.defaultChild;
@@ -3,7 +3,7 @@ import { DistributionDomainProps } from "./Distribution.js";
3
3
  import { SSTConstruct } from "./Construct.js";
4
4
  import { Permissions } from "./util/permission.js";
5
5
  import { FunctionBindingProps } from "./util/functionBinding.js";
6
- import { ISecurityGroup, IVpc, SubnetSelection } from "aws-cdk-lib/aws-ec2";
6
+ import { IVpc } from "aws-cdk-lib/aws-ec2";
7
7
  import { Cluster, ContainerDefinitionOptions } from "aws-cdk-lib/aws-ecs";
8
8
  import { RetentionDays } from "aws-cdk-lib/aws-logs";
9
9
  declare const supportedCpus: {
@@ -275,40 +275,6 @@ export interface ServiceProps {
275
275
  * ```
276
276
  */
277
277
  vpc?: IVpc;
278
- /**
279
- * Where to place the network interfaces within the VPC.
280
- * @default All private subnets.
281
- * @example
282
- * ```js
283
- * import { SubnetType } from "aws-cdk-lib/aws-ec2";
284
- *
285
- * {
286
- * cdk: {
287
- * vpc,
288
- * vpcSubnets: { subnetType: SubnetType.PRIVATE_WITH_EGRESS }
289
- * }
290
- * }
291
- * ```
292
- */
293
- vpcSubnets?: SubnetSelection;
294
- /**
295
- * The list of security groups to associate with the Job's network interfaces.
296
- * @default A new security group is created.
297
- * @example
298
- * ```js
299
- * import { SecurityGroup } from "aws-cdk-lib/aws-ec2";
300
- *
301
- * {
302
- * cdk: {
303
- * vpc,
304
- * securityGroups: [
305
- * new SecurityGroup(stack, "MyJobSG", { vpc })
306
- * ]
307
- * }
308
- * }
309
- * ```
310
- */
311
- securityGroups?: ISecurityGroup[];
312
278
  };
313
279
  }
314
280
  type ServiceNormalizedProps = ServiceProps & {
@@ -6,7 +6,7 @@ import { execAsync } from "../util/process.js";
6
6
  import { existsAsync } from "../util/fs.js";
7
7
  import { Colors } from "../cli/colors.js";
8
8
  import { Construct } from "constructs";
9
- import { Duration as CdkDuration } from "aws-cdk-lib/core";
9
+ import { Duration as CdkDuration, IgnoreMode } from "aws-cdk-lib/core";
10
10
  import { Role, Effect, PolicyStatement, AccountPrincipal, ServicePrincipal, CompositePrincipal, } from "aws-cdk-lib/aws-iam";
11
11
  import { ViewerProtocolPolicy, AllowedMethods, CachedMethods, CachePolicy, CacheQueryStringBehavior, CacheHeaderBehavior, CacheCookieBehavior, OriginProtocolPolicy, OriginRequestPolicy, } from "aws-cdk-lib/aws-cloudfront";
12
12
  import { HttpOrigin } from "aws-cdk-lib/aws-cloudfront-origins";
@@ -20,7 +20,7 @@ import { bindEnvironment, bindPermissions, getParameterPath, getReferencedSecret
20
20
  import { useProject } from "../project.js";
21
21
  import { Vpc, } from "aws-cdk-lib/aws-ec2";
22
22
  import { AwsLogDriver, Cluster, FargateTaskDefinition, ContainerImage, FargateService, } from "aws-cdk-lib/aws-ecs";
23
- import { LogGroup, RetentionDays } from "aws-cdk-lib/aws-logs";
23
+ import { LogGroup, LogRetention, RetentionDays } from "aws-cdk-lib/aws-logs";
24
24
  import { Platform } from "aws-cdk-lib/aws-ecr-assets";
25
25
  import { ApplicationLoadBalancer, } from "aws-cdk-lib/aws-elasticloadbalancingv2";
26
26
  import { createAppContext } from "./context.js";
@@ -360,16 +360,19 @@ export class Service extends Construct {
360
360
  const { cdk } = this.props;
361
361
  return (cdk?.vpc ??
362
362
  new Vpc(this, "Vpc", {
363
- natGateways: 0,
363
+ natGateways: 1,
364
364
  }));
365
365
  }
366
366
  createService(vpc) {
367
367
  const { cpu, memory, port, logRetention, cdk } = this.props;
368
368
  const app = this.node.root;
369
369
  const clusterName = app.logicalPrefixedName(this.node.id);
370
- const logGroup = new LogGroup(this, "LogGroup", {
370
+ const logGroup = new LogRetention(this, "LogRetention", {
371
371
  logGroupName: `/sst/service/${clusterName}`,
372
372
  retention: RetentionDays[logRetention.toUpperCase()],
373
+ logRetentionRetryOptions: {
374
+ maxRetries: 100,
375
+ },
373
376
  });
374
377
  const cluster = new Cluster(this, "Cluster", {
375
378
  clusterName,
@@ -382,7 +385,7 @@ export class Service extends Construct {
382
385
  });
383
386
  const container = taskDefinition.addContainer("Container", {
384
387
  logging: new AwsLogDriver({
385
- logGroup,
388
+ logGroup: LogGroup.fromLogGroupArn(this, "LogGroup", logGroup.logGroupArn),
386
389
  streamPrefix: "service",
387
390
  }),
388
391
  portMappings: [{ containerPort: port }],
@@ -580,6 +583,8 @@ export class Service extends Construct {
580
583
  const image = ContainerImage.fromAsset(this.props.path, {
581
584
  platform: Platform.LINUX_AMD64,
582
585
  file: dockerfile,
586
+ exclude: [".sst"],
587
+ ignoreMode: IgnoreMode.GLOB,
583
588
  });
584
589
  const cfnTask = taskDefinition.node.defaultChild;
585
590
  cfnTask.addPropertyOverride("ContainerDefinitions.0.Image", image.bind(this, container).imageName);
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "sideEffects": false,
3
3
  "name": "sst",
4
- "version": "2.23.3",
4
+ "version": "2.23.4",
5
5
  "bin": {
6
6
  "sst": "cli/sst.js"
7
7
  },
package/sst.mjs CHANGED
@@ -8852,7 +8852,9 @@ function secrets(program2) {
8852
8852
  }
8853
8853
 
8854
8854
  // src/cli/commands/update.ts
8855
+ init_error();
8855
8856
  var FIELDS = ["dependencies", "devDependencies"];
8857
+ var SST_PKGS = ["sst", "astro-sst", "svelte-kit-sst", "solid-start-sst"];
8856
8858
  var update = (program2) => program2.command(
8857
8859
  "update [version]",
8858
8860
  "Update your SST and CDK packages",
@@ -8866,9 +8868,52 @@ var update = (program2) => program2.command(
8866
8868
  const { fetch } = await import("undici");
8867
8869
  const { useProject: useProject2 } = await Promise.resolve().then(() => (init_project(), project_exports));
8868
8870
  const { Colors: Colors2 } = await Promise.resolve().then(() => (init_colors(), colors_exports));
8869
- async function find2(dir) {
8871
+ const project = useProject2();
8872
+ const files = await findAllPackageJson(project.paths.root);
8873
+ const metadata3 = await fetch(
8874
+ `https://registry.npmjs.org/sst/${args.version || "latest"}`
8875
+ ).then((resp) => resp.json());
8876
+ const allChanges = /* @__PURE__ */ new Map();
8877
+ const allOldPackages = /* @__PURE__ */ new Map();
8878
+ await Promise.all(files.map(updatePackageJson));
8879
+ if (allOldPackages.size > 0) {
8880
+ for (const [file, pkgs] of allOldPackages.entries()) {
8881
+ Colors2.line(
8882
+ Colors2.danger(`\u2716 `),
8883
+ Colors2.bold.dim(path22.relative(project.paths.root, file))
8884
+ );
8885
+ for (const [pkg, version2] of pkgs) {
8886
+ Colors2.line(Colors2.dim(` ${pkg}@${version2}`));
8887
+ }
8888
+ }
8889
+ Colors2.gap();
8890
+ throw new VisibleError(
8891
+ "We've detected AWS CDK v1 dependencies in your package.json. SST requires CDK v2. Please update to CDK v2 dependencies, and then execute `sst update`. For guidance, refer to the official AWS CDK migration documentation \u2014 https://docs.aws.amazon.com/cdk/v2/guide/migrating-v2.html#migrating-v2-v1-upgrade"
8892
+ );
8893
+ }
8894
+ if (allChanges.size === 0) {
8895
+ Colors2.line(Colors2.success(`\u2714 `), `Already using v${metadata3.version}`);
8896
+ return;
8897
+ }
8898
+ for (const [file, pkgs] of allChanges.entries()) {
8899
+ Colors2.line(
8900
+ Colors2.success(`\u2714 `),
8901
+ Colors2.bold.dim(path22.relative(project.paths.root, file))
8902
+ );
8903
+ for (const [pkg, version2] of pkgs) {
8904
+ Colors2.line(Colors2.dim(` ${pkg}@${version2}`));
8905
+ }
8906
+ }
8907
+ Colors2.gap();
8908
+ Colors2.line(
8909
+ `${Colors2.primary(`\u279C`)} ${Colors2.warning(
8910
+ "Make sure to run: npm install (or pnpm install, or yarn)"
8911
+ )}`
8912
+ );
8913
+ process.exit(0);
8914
+ async function findAllPackageJson(dir) {
8870
8915
  const children = await fs19.readdir(dir);
8871
- const tasks2 = children.map(async (item) => {
8916
+ const tasks = children.map(async (item) => {
8872
8917
  if (item === "node_modules")
8873
8918
  return [];
8874
8919
  if (/(^|\/)\.[^\/\.]/g.test(item))
@@ -8878,77 +8923,52 @@ var update = (program2) => program2.command(
8878
8923
  return [full];
8879
8924
  const stat = await fs19.stat(full);
8880
8925
  if (stat.isDirectory())
8881
- return find2(full);
8926
+ return findAllPackageJson(full);
8882
8927
  return [];
8883
8928
  });
8884
- return (await Promise.all(tasks2)).flat();
8929
+ return (await Promise.all(tasks)).flat();
8885
8930
  }
8886
- const project = useProject2();
8887
- const files = await find2(project.paths.root);
8888
- const metadata3 = await fetch(
8889
- `https://registry.npmjs.org/sst/${args.version || "latest"}`
8890
- ).then((resp) => resp.json());
8891
- const results = /* @__PURE__ */ new Map();
8892
- const tasks = files.map(async (file) => {
8931
+ async function updatePackageJson(file) {
8932
+ const changes = /* @__PURE__ */ new Set();
8933
+ const oldPackages = /* @__PURE__ */ new Set();
8893
8934
  const data2 = await fs19.readFile(file).then((x) => x.toString());
8894
- const tailingNewline = data2.match(/\r?\n$/)?.[0];
8895
8935
  const json = JSON.parse(data2);
8896
8936
  for (const field of FIELDS) {
8897
8937
  const deps = json[field];
8898
8938
  for (const [pkg, existing] of Object.entries(deps || {})) {
8899
8939
  const desired = (() => {
8900
- if ([
8901
- "sst",
8902
- "astro-sst",
8903
- "svelte-kit-sst",
8904
- "solid-start-sst"
8905
- ].includes(pkg)) {
8940
+ if (SST_PKGS.includes(pkg)) {
8906
8941
  return metadata3.version;
8907
8942
  } else if (pkg === "constructs") {
8908
8943
  return metadata3.dependencies.constructs;
8909
- } else if (pkg.startsWith("aws-cdk") || pkg.startsWith("@aws-cdk")) {
8910
- return pkg.endsWith("alpha") ? metadata3.dependencies["@aws-cdk/aws-apigatewayv2-alpha"] : metadata3.dependencies["aws-cdk-lib"];
8944
+ } else if (pkg === "aws-cdk-lib") {
8945
+ return metadata3.dependencies["aws-cdk-lib"];
8946
+ } else if (pkg.startsWith("@aws-cdk/aws-")) {
8947
+ if (!pkg.endsWith("-alpha")) {
8948
+ oldPackages.add([pkg, existing]);
8949
+ return;
8950
+ }
8951
+ return metadata3.dependencies["@aws-cdk/aws-apigatewayv2-alpha"];
8911
8952
  }
8912
8953
  })();
8913
8954
  if (!desired || existing === desired)
8914
8955
  continue;
8915
- let arr = results.get(file);
8916
- if (!arr) {
8917
- arr = /* @__PURE__ */ new Set();
8918
- results.set(file, arr);
8919
- }
8920
- arr.add([pkg, desired]);
8956
+ changes.add([pkg, desired]);
8921
8957
  deps[pkg] = desired;
8922
8958
  }
8923
8959
  }
8924
- if (results.has(file)) {
8960
+ if (changes.size > 0) {
8961
+ const tailingNewline = data2.match(/\r?\n$/)?.[0];
8925
8962
  await fs19.writeFile(
8926
8963
  file,
8927
8964
  `${JSON.stringify(json, null, 2)}${tailingNewline ?? ""}`
8928
8965
  );
8966
+ allChanges.set(file, changes);
8929
8967
  }
8930
- });
8931
- await Promise.all(tasks);
8932
- if (results.size === 0) {
8933
- Colors2.line(Colors2.success(`\u2714 `), `Already using v${metadata3.version}`);
8934
- return;
8935
- }
8936
- for (const [file, pkgs] of results.entries()) {
8937
- Colors2.line(
8938
- Colors2.success(`\u2714 `),
8939
- Colors2.bold.dim(path22.relative(project.paths.root, file))
8940
- );
8941
- for (const [pkg, version2] of pkgs) {
8942
- Colors2.line(Colors2.dim(` ${pkg}@${version2}`));
8968
+ if (oldPackages.size > 0) {
8969
+ allOldPackages.set(file, oldPackages);
8943
8970
  }
8944
8971
  }
8945
- Colors2.gap();
8946
- Colors2.line(
8947
- `${Colors2.primary(`\u279C`)} ${Colors2.warning(
8948
- "Make sure to run: npm install (or pnpm install, or yarn)"
8949
- )}`
8950
- );
8951
- process.exit(0);
8952
8972
  }
8953
8973
  );
8954
8974