sst 2.34.7 → 2.35.0

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.
@@ -110,7 +110,7 @@ export declare class App extends CDKApp {
110
110
  * @example
111
111
  * ```js
112
112
  * app.setDefaultFunctionProps({
113
- * runtime: "nodejs12.x",
113
+ * runtime: "nodejs16.x",
114
114
  * timeout: 30
115
115
  * })
116
116
  * ```
package/constructs/App.js CHANGED
@@ -117,7 +117,7 @@ export class App extends CDKApp {
117
117
  * @example
118
118
  * ```js
119
119
  * app.setDefaultFunctionProps({
120
- * runtime: "nodejs12.x",
120
+ * runtime: "nodejs16.x",
121
121
  * timeout: 30
122
122
  * })
123
123
  * ```
@@ -127,6 +127,7 @@ export declare class Distribution extends Construct {
127
127
  version?: string;
128
128
  paths?: string[];
129
129
  wait?: boolean;
130
+ dependsOn?: IConstruct[];
130
131
  }): CustomResource;
131
132
  private validateCloudFrontDistributionSettings;
132
133
  private validateCustomDomainSettings;
@@ -71,7 +71,7 @@ export class Distribution extends Construct {
71
71
  };
72
72
  }
73
73
  createInvalidation(props) {
74
- const { version, paths, wait } = props ?? {};
74
+ const { version, paths, wait, dependsOn } = props ?? {};
75
75
  const stack = Stack.of(this);
76
76
  const policy = new Policy(this.scope, "CloudFrontInvalidatorPolicy", {
77
77
  statements: [
@@ -100,6 +100,7 @@ export class Distribution extends Construct {
100
100
  },
101
101
  });
102
102
  resource.node.addDependency(policy);
103
+ dependsOn?.forEach((c) => resource.node.addDependency(c));
103
104
  return resource;
104
105
  }
105
106
  validateCloudFrontDistributionSettings() {
@@ -1,6 +1,7 @@
1
1
  import fs from "fs";
2
2
  import url from "url";
3
3
  import path from "path";
4
+ import zlib from "zlib";
4
5
  import crypto from "crypto";
5
6
  import spawn from "cross-spawn";
6
7
  import { Construct } from "constructs";
@@ -107,19 +108,34 @@ export class EdgeFunction extends Construct {
107
108
  },
108
109
  });
109
110
  // Build function
110
- const bundle = await useRuntimeHandlers().build(this.node.addr, "deploy");
111
+ const result = await useRuntimeHandlers().build(this.node.addr, "deploy");
111
112
  // create wrapper that calls the handler
112
- if (bundle.type === "error")
113
+ if (result.type === "error")
113
114
  throw new Error([
114
115
  `There was a problem bundling the SSR function for the "${this.scope.node.id}" Site.`,
115
- ...bundle.errors,
116
+ ...result.errors,
116
117
  ].join("\n"));
118
+ // upload sourcemap
119
+ const stack = Stack.of(this);
120
+ if (result.sourcemap) {
121
+ const data = await fs.promises.readFile(result.sourcemap);
122
+ await fs.promises.writeFile(result.sourcemap, zlib.gzipSync(data));
123
+ const asset = new Asset(this, "Sourcemap", {
124
+ path: result.sourcemap,
125
+ });
126
+ await fs.promises.rm(result.sourcemap);
127
+ useFunctions().sourcemaps.add(stack.stackName, {
128
+ srcBucket: asset.bucket,
129
+ srcKey: asset.s3ObjectKey,
130
+ tarKey: this.functionArn,
131
+ });
132
+ }
117
133
  const asset = new Asset(this.scope, `FunctionAsset`, {
118
- path: bundle.out,
134
+ path: result.out,
119
135
  });
120
136
  // Get handler filename
121
137
  const isESM = (nodejs?.format || "esm") === "esm";
122
- const parsed = path.parse(bundle.handler);
138
+ const parsed = path.parse(result.handler);
123
139
  const handlerFilename = `${parsed.dir}/${parsed.name}${isESM ? ".mjs" : ".cjs"}`;
124
140
  return { asset, handlerFilename };
125
141
  }
@@ -14,7 +14,6 @@ import { IBucket } from "aws-cdk-lib/aws-s3";
14
14
  declare const supportedRuntimes: {
15
15
  container: CDKRuntime;
16
16
  rust: CDKRuntime;
17
- "nodejs12.x": CDKRuntime;
18
17
  "nodejs14.x": CDKRuntime;
19
18
  "nodejs16.x": CDKRuntime;
20
19
  "nodejs18.x": CDKRuntime;
@@ -123,12 +122,12 @@ export interface FunctionProps extends Omit<FunctionOptions, "functionName" | "m
123
122
  handler?: string;
124
123
  /**
125
124
  * The runtime environment for the function.
126
- * @default "nodejs16.x"
125
+ * @default "nodejs18.x"
127
126
  * @example
128
127
  * ```js
129
128
  * new Function(stack, "Function", {
130
129
  * handler: "function.handler",
131
- * runtime: "nodejs18.x",
130
+ * runtime: "nodejs16.x",
132
131
  * })
133
132
  *```
134
133
  */
@@ -703,7 +702,7 @@ export declare class Function extends CDKFunction implements SSTConstruct {
703
702
  type: "Function";
704
703
  data: {
705
704
  arn: string;
706
- runtime: "container" | "rust" | "nodejs12.x" | "nodejs14.x" | "nodejs16.x" | "nodejs18.x" | "python3.7" | "python3.8" | "python3.9" | "python3.10" | "python3.11" | "dotnetcore3.1" | "dotnet6" | "java8" | "java11" | "java17" | "go1.x" | "go" | undefined;
705
+ runtime: "container" | "rust" | "nodejs14.x" | "nodejs16.x" | "nodejs18.x" | "python3.7" | "python3.8" | "python3.9" | "python3.10" | "python3.11" | "dotnetcore3.1" | "dotnet6" | "java8" | "java11" | "java17" | "go1.x" | "go" | undefined;
707
706
  handler: string | undefined;
708
707
  localId: string;
709
708
  secrets: string[];
@@ -31,7 +31,6 @@ const __dirname = url.fileURLToPath(new URL(".", import.meta.url));
31
31
  const supportedRuntimes = {
32
32
  container: CDKRuntime.FROM_IMAGE,
33
33
  rust: CDKRuntime.PROVIDED_AL2,
34
- "nodejs12.x": CDKRuntime.NODEJS_12_X,
35
34
  "nodejs14.x": CDKRuntime.NODEJS_14_X,
36
35
  "nodejs16.x": CDKRuntime.NODEJS_16_X,
37
36
  "nodejs18.x": CDKRuntime.NODEJS_18_X,
@@ -80,7 +79,7 @@ export class Function extends CDKFunction {
80
79
  .forEach((per) => {
81
80
  props = Function.mergeProps(per, props);
82
81
  });
83
- props.runtime = props.runtime || "nodejs16.x";
82
+ props.runtime = props.runtime || "nodejs18.x";
84
83
  if (props.runtime === "go1.x")
85
84
  useWarning().add("go.deprecated");
86
85
  // Set defaults
@@ -126,7 +125,7 @@ export class Function extends CDKFunction {
126
125
  });
127
126
  }
128
127
  // Handle local development (ie. sst start)
129
- // - set runtime to nodejs12.x for non-Node runtimes (b/c the stub is in Node)
128
+ // - set runtime to nodejs for non-Node runtimes (b/c the stub is in Node)
130
129
  // - set retry to 0. When the debugger is disconnected, the Cron construct
131
130
  // will still try to periodically invoke the Lambda, and the requests would
132
131
  // fail and retry. So when launching `sst start`, a couple of retry requests
package/constructs/Job.js CHANGED
@@ -399,6 +399,6 @@ export class Job extends Construct {
399
399
  }
400
400
  convertJobRuntimeToFunctionRuntime() {
401
401
  const { runtime } = this.props;
402
- return runtime === "container" ? "container" : "nodejs16.x";
402
+ return runtime === "container" ? "container" : "nodejs18.x";
403
403
  }
404
404
  }
@@ -149,14 +149,7 @@ export declare class NextjsSite extends SsrSite {
149
149
  function: {
150
150
  layers: import("aws-cdk-lib/aws-lambda").ILayerVersion[] | undefined;
151
151
  handler: string;
152
- bundle?: string | undefined; /**
153
- * OpenNext version for building the Next.js site.
154
- * @default Latest OpenNext version
155
- * @example
156
- * ```js
157
- * openNextVersion: "2.2.4",
158
- * ```
159
- */
152
+ bundle?: string | undefined;
160
153
  runtime?: "nodejs14.x" | "nodejs16.x" | "nodejs18.x" | undefined;
161
154
  timeout?: number | `${number} second` | `${number} seconds` | `${number} minute` | `${number} minutes` | `${number} hour` | `${number} hours` | `${number} day` | `${number} days` | undefined;
162
155
  memorySize?: number | `${number} MB` | `${number} GB` | undefined;
@@ -208,6 +201,16 @@ export declare class NextjsSite extends SsrSite {
208
201
  timeout?: number | `${number} second` | `${number} seconds` | `${number} minute` | `${number} minutes` | `${number} hour` | `${number} hours` | `${number} day` | `${number} days` | undefined;
209
202
  memorySize?: number | `${number} MB` | `${number} GB` | undefined;
210
203
  permissions?: import("./index.js").Permissions | undefined;
204
+ /**
205
+ * How the logs are stored in CloudWatch
206
+ * - "combined" - Logs from all routes are stored in the same log group.
207
+ * - "per-route" - Logs from each route are stored in a separate log group.
208
+ * @default "combined"
209
+ * @example
210
+ * ```js
211
+ * logging: "per-route",
212
+ * ```
213
+ */
211
214
  environment?: Record<string, string> | undefined;
212
215
  bind?: import("./Construct.js").SSTConstruct[] | undefined;
213
216
  nodejs?: import("./Function.js").NodeJSProps | undefined;
@@ -253,14 +256,7 @@ export declare class NextjsSite extends SsrSite {
253
256
  function: {
254
257
  layers: import("aws-cdk-lib/aws-lambda").ILayerVersion[] | undefined;
255
258
  handler: string;
256
- bundle?: string | undefined; /**
257
- * OpenNext version for building the Next.js site.
258
- * @default Latest OpenNext version
259
- * @example
260
- * ```js
261
- * openNextVersion: "2.2.4",
262
- * ```
263
- */
259
+ bundle?: string | undefined;
264
260
  runtime?: "nodejs14.x" | "nodejs16.x" | "nodejs18.x" | undefined;
265
261
  timeout?: number | `${number} second` | `${number} seconds` | `${number} minute` | `${number} minutes` | `${number} hour` | `${number} hours` | `${number} day` | `${number} days` | undefined;
266
262
  memorySize?: number | `${number} MB` | `${number} GB` | undefined;
@@ -312,6 +308,16 @@ export declare class NextjsSite extends SsrSite {
312
308
  timeout?: number | `${number} second` | `${number} seconds` | `${number} minute` | `${number} minutes` | `${number} hour` | `${number} hours` | `${number} day` | `${number} days` | undefined;
313
309
  memorySize?: number | `${number} MB` | `${number} GB` | undefined;
314
310
  permissions?: import("./index.js").Permissions | undefined;
311
+ /**
312
+ * How the logs are stored in CloudWatch
313
+ * - "combined" - Logs from all routes are stored in the same log group.
314
+ * - "per-route" - Logs from each route are stored in a separate log group.
315
+ * @default "combined"
316
+ * @example
317
+ * ```js
318
+ * logging: "per-route",
319
+ * ```
320
+ */
315
321
  environment?: Record<string, string> | undefined;
316
322
  bind?: import("./Construct.js").SSTConstruct[] | undefined;
317
323
  nodejs?: import("./Function.js").NodeJSProps | undefined;
@@ -210,7 +210,9 @@ export class Service extends Construct {
210
210
  this.updateContainerImage(dockerfile, taskDefinition, container);
211
211
  }
212
212
  // Invalidate CloudFront
213
- this.distribution?.createInvalidation();
213
+ this.distribution?.createInvalidation({
214
+ wait: this.props.waitForInvalidation,
215
+ });
214
216
  });
215
217
  app.registerTypes(this);
216
218
  }
@@ -1,5 +1,7 @@
1
1
  import url from "url";
2
2
  import path from "path";
3
+ import zlib from "zlib";
4
+ import fs from "fs/promises";
3
5
  import spawn from "cross-spawn";
4
6
  import { Construct } from "constructs";
5
7
  import { Effect, Policy, PolicyStatement, } from "aws-cdk-lib/aws-iam";
@@ -16,6 +18,7 @@ import { attachPermissionsToRole } from "./util/permission.js";
16
18
  import { toCdkSize } from "./util/size.js";
17
19
  import { toCdkDuration } from "./util/duration.js";
18
20
  import { useDeferredTasks } from "./deferred_task.js";
21
+ import { Asset } from "aws-cdk-lib/aws-s3-assets";
19
22
  const __dirname = path.dirname(url.fileURLToPath(import.meta.url));
20
23
  /////////////////////
21
24
  // Construct
@@ -170,15 +173,30 @@ export class SsrFunction extends Construct {
170
173
  nodejs: this.props.nodejs,
171
174
  copyFiles: this.props.copyFiles,
172
175
  });
173
- // Build function
174
- const bundle = await useRuntimeHandlers().build(this.node.addr, "deploy");
176
+ // build function
177
+ const result = await useRuntimeHandlers().build(this.node.addr, "deploy");
175
178
  // create wrapper that calls the handler
176
- if (bundle.type === "error")
179
+ if (result.type === "error")
177
180
  throw new Error([
178
181
  `There was a problem bundling the SSR function for the "${this.node.id}" Site.`,
179
- ...bundle.errors,
182
+ ...result.errors,
180
183
  ].join("\n"));
181
- return AssetCode.fromAsset(bundle.out);
184
+ // upload sourcemap
185
+ const stack = Stack.of(this);
186
+ if (result.sourcemap) {
187
+ const data = await fs.readFile(result.sourcemap);
188
+ await fs.writeFile(result.sourcemap, zlib.gzipSync(data));
189
+ const asset = new Asset(this, "Sourcemap", {
190
+ path: result.sourcemap,
191
+ });
192
+ await fs.rm(result.sourcemap);
193
+ useFunctions().sourcemaps.add(stack.stackName, {
194
+ srcBucket: asset.bucket,
195
+ srcKey: asset.s3ObjectKey,
196
+ tarKey: this.functionArn,
197
+ });
198
+ }
199
+ return AssetCode.fromAsset(result.out);
182
200
  }
183
201
  async buildAssetFromBundle(bundle) {
184
202
  // Note: cannot point the bundle to the `.open-next/server-function`
@@ -757,6 +757,7 @@ function handler(event) {
757
757
  version: invalidationBuildId,
758
758
  paths: invalidationPaths,
759
759
  wait: invalidation.wait,
760
+ dependsOn: s3DeployCRs,
760
761
  });
761
762
  }
762
763
  }
@@ -75,6 +75,8 @@ export class StaticSite extends Construct {
75
75
  // Invalidate CloudFront
76
76
  this.distribution.createInvalidation({
77
77
  version: this.generateInvalidationId(assets),
78
+ wait: this.props.waitForInvalidation,
79
+ dependsOn: [s3deployCR],
78
80
  });
79
81
  });
80
82
  app.registerTypes(this);
@@ -83,7 +83,7 @@ export interface NextjsSiteProps {
83
83
  * })
84
84
  *```
85
85
  */
86
- runtime?: "nodejs12.x" | "nodejs14.x" | "nodejs16.x" | "nodejs18.x";
86
+ runtime?: "nodejs14.x" | "nodejs16.x" | "nodejs18.x";
87
87
  };
88
88
  };
89
89
  /**
@@ -1039,13 +1039,13 @@ export class NextjsSite extends Construct {
1039
1039
  return replaceValues;
1040
1040
  }
1041
1041
  normalizeRuntime(runtime) {
1042
- if (runtime === "nodejs12.x") {
1043
- return lambda.Runtime.NODEJS_12_X;
1044
- }
1045
- else if (runtime === "nodejs14.x") {
1042
+ if (runtime === "nodejs14.x") {
1046
1043
  return lambda.Runtime.NODEJS_14_X;
1047
1044
  }
1048
- return lambda.Runtime.NODEJS_16_X;
1045
+ else if (runtime === "nodejs16.x") {
1046
+ return lambda.Runtime.NODEJS_16_X;
1047
+ }
1048
+ return lambda.Runtime.NODEJS_18_X;
1049
1049
  }
1050
1050
  }
1051
1051
  export const useSites = createAppContext(() => {
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "sideEffects": false,
3
3
  "name": "sst",
4
- "version": "2.34.7",
4
+ "version": "2.35.0",
5
5
  "bin": {
6
6
  "sst": "cli/sst.js"
7
7
  },
@@ -120,7 +120,7 @@
120
120
  "@types/ws": "^8.5.3",
121
121
  "@types/yargs": "^17.0.13",
122
122
  "archiver": "^5.3.1",
123
- "astro-sst": "2.34.7",
123
+ "astro-sst": "2.35.0",
124
124
  "async": "^3.2.4",
125
125
  "tsx": "^3.12.1",
126
126
  "typescript": "^5.2.2",