sst 2.28.0 → 2.28.3

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.
@@ -288,7 +288,7 @@ export async function useLocalServer(opts) {
288
288
  id: invocation.id,
289
289
  error: evt.properties.errorType,
290
290
  message: evt.properties.errorMessage,
291
- stack: evt.properties.trace.map((t) => ({
291
+ stack: (evt.properties.trace || []).map((t) => ({
292
292
  raw: t,
293
293
  })),
294
294
  });
@@ -201,7 +201,7 @@ export interface ApiProps<Authorizers extends Record<string, ApiAuthorizer> = Re
201
201
  */
202
202
  cors?: boolean | ApiCorsProps;
203
203
  /**
204
- * Enable CloudWatch access logs for this API
204
+ * Enable CloudWatch access logs for this API. Defaults to true.
205
205
  *
206
206
  * @default true
207
207
  *
@@ -11,6 +11,7 @@ export interface AstroSiteProps extends SsrSiteProps {
11
11
  * - "?" matches exactly 1 character.
12
12
  *
13
13
  * Matched routes will be handled directly by the server function.
14
+ * @deprecated Define `serverRoutes` in `astro.config.mjs` instead.
14
15
  * @default true
15
16
  * @example
16
17
  * ```js
@@ -25,17 +26,6 @@ export interface AstroSiteProps extends SsrSiteProps {
25
26
  * ```
26
27
  */
27
28
  serverRoutes?: string[];
28
- /**
29
- * Supports [streaming](https://docs.astro.build/en/guides/server-side-rendering/#using-streaming-to-improve-page-performance) responses.
30
- * @default true
31
- * @example
32
- * ```js
33
- * regional: {
34
- * streaming: false,
35
- * }
36
- * ```
37
- */
38
- streaming?: boolean;
39
29
  };
40
30
  }
41
31
  type AstroSiteNormalizedProps = AstroSiteProps & SsrSiteNormalizedProps;
@@ -19,28 +19,7 @@ export class AstroSite extends SsrSite {
19
19
  super(scope, id, {
20
20
  ...props,
21
21
  typesPath: props?.typesPath ?? "src",
22
- fileOptions: props?.fileOptions ?? [
23
- {
24
- exclude: "*",
25
- include: "*.css",
26
- cacheControl: "public,max-age=0,s-maxage=31536000,must-revalidate",
27
- contentType: "text/css; charset=UTF-8",
28
- },
29
- {
30
- exclude: "*",
31
- include: "*.js",
32
- cacheControl: "public,max-age=0,s-maxage=31536000,must-revalidate",
33
- contentType: "application/javascript; charset=UTF-8",
34
- },
35
- {
36
- exclude: "*",
37
- include: "*.html",
38
- cacheControl: "public,max-age=0,s-maxage=31536000,must-revalidate",
39
- contentType: "text/html; charset=UTF-8",
40
- },
41
- ],
42
22
  regional: {
43
- streaming: props?.regional?.streaming ?? true,
44
23
  ...props?.regional,
45
24
  },
46
25
  });
@@ -158,7 +137,7 @@ export class AstroSite extends SsrSite {
158
137
  type: "function",
159
138
  constructId: "ServerFunction",
160
139
  function: serverConfig,
161
- streaming: regional?.streaming,
140
+ streaming: buildMeta.responseMode === "stream",
162
141
  };
163
142
  plan.origins.fallthroughServer = {
164
143
  type: "group",
@@ -175,19 +154,33 @@ export class AstroSite extends SsrSite {
175
154
  cacheType: "static",
176
155
  pattern: `${buildMeta.clientBuildVersionedSubDir}/*`,
177
156
  origin: "staticsServer",
178
- }, ...(regional?.serverRoutes ?? []).map((route) => ({
157
+ }, ...(buildMeta.serverRoutes ?? regional?.serverRoutes ?? []).map((route) => ({
179
158
  cacheType: "server",
180
159
  pattern: route,
181
160
  origin: "regionalServer",
182
161
  })));
183
- const notFoundRoute = buildMeta.routes.find(({ route, type }) => route.match(/^\/404\/?$/) && type === "page");
184
- if (notFoundRoute) {
185
- plan.errorResponses?.push({
186
- httpStatus: 404,
187
- responsePagePath: "/404.html",
188
- responseHttpStatus: 404,
189
- });
190
- }
162
+ buildMeta.routes
163
+ .filter(({ type, route }) => type === "page" && /^\/\d{3}\/?$/.test(route))
164
+ .forEach(({ route, prerender }) => {
165
+ switch (route) {
166
+ case "/404":
167
+ case "/404/":
168
+ plan.errorResponses?.push({
169
+ httpStatus: 404,
170
+ responsePagePath: prerender ? "/404.html" : "/404",
171
+ responseHttpStatus: 404,
172
+ });
173
+ break;
174
+ case "/500":
175
+ case "/500/":
176
+ plan.errorResponses?.push({
177
+ httpStatus: 500,
178
+ responsePagePath: prerender ? "/500.html" : "/500",
179
+ responseHttpStatus: 500,
180
+ });
181
+ break;
182
+ }
183
+ });
191
184
  }
192
185
  return this.validatePlan(plan);
193
186
  }
@@ -270,7 +270,7 @@ export interface FunctionProps extends Omit<FunctionOptions, "functionName" | "m
270
270
  *
271
271
  * Note that, if a Layer is created in a stack (say `stackA`) and is referenced in another stack (say `stackB`), SST automatically creates an SSM parameter in `stackA` with the Layer's ARN. And in `stackB`, SST reads the ARN from the SSM parameter, and then imports the Layer.
272
272
  *
273
- * This is to get around the limitation that a Lambda Layer ARN cannot be referenced across stacks via a stack export. The Layer ARN contains a version number that is incremented everytime the Layer is modified. When you refer to a Layer's ARN across stacks, a CloudFormation export is created. However, CloudFormation does not allow an exported value to be updated. Once exported, if you try to deploy the updated layer, the CloudFormation update will fail. You can read more about this issue here - https://github.com/sst/sst/issues/549.
273
+ * This is to get around the limitation that a Lambda Layer ARN cannot be referenced across stacks via a stack export. The Layer ARN contains a version number that is incremented everytime the Layer is modified. When you refer to a Layer's ARN across stacks, a CloudFormation export is created. However, CloudFormation does not allow an exported value to be updated. Once exported, if you try to deploy the updated layer, the CloudFormation update will fail. You can read more about this issue here - https://github.com/sst/sst/issues/549.
274
274
  *
275
275
  * @default no layers
276
276
  *
@@ -282,6 +282,21 @@ export interface FunctionProps extends Omit<FunctionOptions, "functionName" | "m
282
282
  * ```
283
283
  */
284
284
  layers?: (string | ILayerVersion)[];
285
+ /**
286
+ * Disable sending function logs to CloudWatch Logs.
287
+ *
288
+ * Note that, logs will still appear locally when running `sst dev`.
289
+ * @default false
290
+ * @example
291
+ * ```js
292
+ * new Function(stack, "Function", {
293
+ * handler: "src/function.handler",
294
+ * disableCloudWatchLogs: true
295
+ * })
296
+ * ```
297
+ *
298
+ */
299
+ disableCloudWatchLogs?: boolean;
285
300
  /**
286
301
  * The duration function logs are kept in CloudWatch Logs.
287
302
  *
@@ -662,6 +677,7 @@ export declare class Function extends CDKFunction implements SSTConstruct {
662
677
  /** @internal */
663
678
  getFunctionBinding(): FunctionBindingProps;
664
679
  private createUrl;
680
+ private disableCloudWatchLogs;
665
681
  private isNodeRuntime;
666
682
  static validateHandlerSet(id: string, props: FunctionProps): void;
667
683
  static validateVpcSettings(id: string, props: FunctionProps): void;
@@ -294,7 +294,6 @@ export class Function extends CDKFunction {
294
294
  removeInEdge: true,
295
295
  });
296
296
  }
297
- // Attach permissions
298
297
  this.attachPermissions(props.permissions || []);
299
298
  // Add config
300
299
  this.addEnvironment("SST_APP", app.name, { removeInEdge: true });
@@ -303,6 +302,7 @@ export class Function extends CDKFunction {
303
302
  removeInEdge: true,
304
303
  });
305
304
  this.bind(props.bind || []);
305
+ this.disableCloudWatchLogs();
306
306
  this.createUrl();
307
307
  this._isLiveDevEnabled = isLiveDevEnabled;
308
308
  useFunctions().add(this.node.addr, props);
@@ -415,6 +415,22 @@ export class Function extends CDKFunction {
415
415
  cors: functionUrlCors.buildCorsConfig(cors),
416
416
  });
417
417
  }
418
+ disableCloudWatchLogs() {
419
+ const disableCloudWatchLogs = this.props.disableCloudWatchLogs ?? false;
420
+ if (!disableCloudWatchLogs)
421
+ return;
422
+ this.attachPermissions([
423
+ new PolicyStatement({
424
+ effect: Effect.DENY,
425
+ actions: [
426
+ "logs:CreateLogGroup",
427
+ "logs:CreateLogStream",
428
+ "logs:PutLogEvents",
429
+ ],
430
+ resources: ["*"],
431
+ }),
432
+ ]);
433
+ }
418
434
  isNodeRuntime() {
419
435
  const { runtime } = this.props;
420
436
  return runtime.startsWith("nodejs");
@@ -248,7 +248,7 @@ export interface SsrSiteProps {
248
248
  * from the server rendering Lambda.
249
249
  */
250
250
  responseHeadersPolicy?: IResponseHeadersPolicy;
251
- server?: Pick<CdkFunctionProps, "vpc" | "vpcSubnets" | "securityGroups" | "allowAllOutbound" | "allowPublicSubnet" | "architecture" | "logRetention"> & Pick<FunctionProps, "copyFiles">;
251
+ server?: Pick<CdkFunctionProps, "layers" | "vpc" | "vpcSubnets" | "securityGroups" | "allowAllOutbound" | "allowPublicSubnet" | "architecture" | "logRetention"> & Pick<FunctionProps, "copyFiles">;
252
252
  };
253
253
  /**
254
254
  * Pass in a list of file options to customize cache control and content type specific files.
@@ -195,7 +195,7 @@ export class SsrSite extends Construct {
195
195
  bind,
196
196
  environment,
197
197
  permissions,
198
- // note: do not need to set vpc settings b/c this function is not being used
198
+ // note: do not need to set vpc and layers settings b/c this function is not being used
199
199
  });
200
200
  }
201
201
  function createWarmer() {
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "sideEffects": false,
3
3
  "name": "sst",
4
- "version": "2.28.0",
4
+ "version": "2.28.3",
5
5
  "bin": {
6
6
  "sst": "cli/sst.js"
7
7
  },
@@ -119,7 +119,7 @@
119
119
  "@types/ws": "^8.5.3",
120
120
  "@types/yargs": "^17.0.13",
121
121
  "archiver": "^5.3.1",
122
- "astro-sst": "2.28.0",
122
+ "astro-sst": "2.28.3",
123
123
  "tsx": "^3.12.1",
124
124
  "typescript": "^5.2.2",
125
125
  "vitest": "^0.33.0"
@@ -35794,7 +35794,7 @@ var require_DeleteParameterCommand = __commonJS({
35794
35794
  return smithy_client_1.Command;
35795
35795
  } });
35796
35796
  var Aws_json1_1_1 = require_Aws_json1_1();
35797
- var DeleteParameterCommand2 = class _DeleteParameterCommand extends smithy_client_1.Command {
35797
+ var DeleteParameterCommand = class _DeleteParameterCommand extends smithy_client_1.Command {
35798
35798
  static getEndpointParameterInstructions() {
35799
35799
  return {
35800
35800
  UseFIPS: { type: "builtInParams", name: "useFipsEndpoint" },
@@ -35831,7 +35831,7 @@ var require_DeleteParameterCommand = __commonJS({
35831
35831
  return (0, Aws_json1_1_1.de_DeleteParameterCommand)(output, context);
35832
35832
  }
35833
35833
  };
35834
- exports.DeleteParameterCommand = DeleteParameterCommand2;
35834
+ exports.DeleteParameterCommand = DeleteParameterCommand;
35835
35835
  }
35836
35836
  });
35837
35837
 
@@ -35848,7 +35848,7 @@ var require_DeleteParametersCommand = __commonJS({
35848
35848
  return smithy_client_1.Command;
35849
35849
  } });
35850
35850
  var Aws_json1_1_1 = require_Aws_json1_1();
35851
- var DeleteParametersCommand = class _DeleteParametersCommand extends smithy_client_1.Command {
35851
+ var DeleteParametersCommand2 = class _DeleteParametersCommand extends smithy_client_1.Command {
35852
35852
  static getEndpointParameterInstructions() {
35853
35853
  return {
35854
35854
  UseFIPS: { type: "builtInParams", name: "useFipsEndpoint" },
@@ -35885,7 +35885,7 @@ var require_DeleteParametersCommand = __commonJS({
35885
35885
  return (0, Aws_json1_1_1.de_DeleteParametersCommand)(output, context);
35886
35886
  }
35887
35887
  };
35888
- exports.DeleteParametersCommand = DeleteParametersCommand;
35888
+ exports.DeleteParametersCommand = DeleteParametersCommand2;
35889
35889
  }
35890
35890
  });
35891
35891
 
@@ -179506,18 +179506,11 @@ async function AuthKeys(cfnRequest) {
179506
179506
  }
179507
179507
  break;
179508
179508
  case "Delete":
179509
- await Promise.all([
179510
- client.send(
179511
- new import_client_ssm.DeleteParameterCommand({
179512
- Name: privatePath
179513
- })
179514
- ),
179515
- client.send(
179516
- new import_client_ssm.DeleteParameterCommand({
179517
- Name: publicPath
179518
- })
179519
- )
179520
- ]);
179509
+ await client.send(
179510
+ new import_client_ssm.DeleteParametersCommand({
179511
+ Names: [publicPath, privatePath]
179512
+ })
179513
+ );
179521
179514
  break;
179522
179515
  default:
179523
179516
  throw new Error("Unsupported request type");