sst 2.0.3 → 2.0.5

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.
@@ -164,7 +164,7 @@ export interface ApiAccessLogProps extends apigV2AccessLog.AccessLogProps {
164
164
  }
165
165
  export interface ApiProps<Authorizers extends Record<string, ApiAuthorizer> = Record<string, ApiAuthorizer>, AuthorizerKeys = keyof Authorizers> {
166
166
  /**
167
- * Define the routes for the API. Can be a function, proxy to another API, or point to an ALB
167
+ * Define the routes for the API. Can be a function, proxy to another API, or point to an load balancer
168
168
  *
169
169
  * @example
170
170
  *
@@ -393,7 +393,7 @@ export interface ApiProps<Authorizers extends Record<string, ApiAuthorizer> = Re
393
393
  httpStages?: Omit<apig.HttpStageProps, "httpApi">[];
394
394
  };
395
395
  }
396
- export type ApiRouteProps<AuthorizerKeys> = FunctionInlineDefinition | ApiFunctionRouteProps<AuthorizerKeys> | ApiHttpRouteProps<AuthorizerKeys> | ApiAlbRouteProps<AuthorizerKeys> | ApiGraphQLRouteProps<AuthorizerKeys>;
396
+ export type ApiRouteProps<AuthorizerKeys> = FunctionInlineDefinition | ApiFunctionRouteProps<AuthorizerKeys> | ApiHttpRouteProps<AuthorizerKeys> | ApiAlbRouteProps<AuthorizerKeys> | ApiNlbRouteProps<AuthorizerKeys> | ApiGraphQLRouteProps<AuthorizerKeys>;
397
397
  interface ApiBaseRouteProps<AuthorizerKeys = string> {
398
398
  authorizer?: "none" | "iam" | (string extends AuthorizerKeys ? Omit<AuthorizerKeys, "none" | "iam"> : AuthorizerKeys);
399
399
  authorizationScopes?: string[];
@@ -485,6 +485,31 @@ export interface ApiAlbRouteProps<AuthorizersKeys> extends ApiBaseRouteProps<Aut
485
485
  integration?: apigIntegrations.HttpAlbIntegrationProps;
486
486
  };
487
487
  }
488
+ /**
489
+ * Specify a route handler that forwards to an NLB
490
+ *
491
+ * @example
492
+ * ```js
493
+ * api.addRoutes(stack, {
494
+ * "GET /notes/{id}": {
495
+ * type: "nlb",
496
+ * cdk: {
497
+ * nlbListener: listener,
498
+ * }
499
+ * }
500
+ * });
501
+ * ```
502
+ */
503
+ export interface ApiNlbRouteProps<AuthorizersKeys> extends ApiBaseRouteProps<AuthorizersKeys> {
504
+ type: "nlb";
505
+ cdk: {
506
+ /**
507
+ * The listener to the application load balancer used for the integration.
508
+ */
509
+ nlbListener: elb.INetworkListener;
510
+ integration?: apigIntegrations.HttpNlbIntegrationProps;
511
+ };
512
+ }
488
513
  /**
489
514
  * Specify a route handler that handles GraphQL queries using Pothos
490
515
  *
@@ -706,7 +731,7 @@ export declare class Api<Authorizers extends Record<string, ApiAuthorizer> = Rec
706
731
  output: string | undefined;
707
732
  commands: string[] | undefined;
708
733
  } | {
709
- type: "lambda_function" | "url" | "alb";
734
+ type: "lambda_function" | "url" | "alb" | "nlb";
710
735
  route: string;
711
736
  fn?: undefined;
712
737
  schema?: undefined;
@@ -731,6 +756,7 @@ export declare class Api<Authorizers extends Record<string, ApiAuthorizer> = Rec
731
756
  private addRoute;
732
757
  private createHttpIntegration;
733
758
  private createAlbIntegration;
759
+ private createNlbIntegration;
734
760
  protected createGraphQLIntegration(scope: Construct, routeKey: string, routeProps: ApiGraphQLRouteProps<keyof Authorizers>, postfixName: string): apig.HttpRouteIntegration;
735
761
  protected createCdkFunctionIntegration(scope: Construct, routeKey: string, routeProps: ApiFunctionRouteProps<keyof Authorizers>, postfixName: string): apig.HttpRouteIntegration;
736
762
  protected createFunctionIntegration(scope: Construct, routeKey: string, routeProps: ApiFunctionRouteProps<keyof Authorizers>, postfixName: string): apig.HttpRouteIntegration;
package/constructs/Api.js CHANGED
@@ -444,6 +444,12 @@ export class Api extends Construct {
444
444
  this.createAlbIntegration(scope, routeKey, routeValue, postfixName),
445
445
  ];
446
446
  }
447
+ if (routeValue.type === "nlb") {
448
+ return [
449
+ routeValue,
450
+ this.createNlbIntegration(scope, routeKey, routeValue, postfixName),
451
+ ];
452
+ }
447
453
  if (routeValue.type === "url") {
448
454
  return [
449
455
  routeValue,
@@ -470,7 +476,7 @@ export class Api extends Construct {
470
476
  }
471
477
  if ("handler" in routeValue)
472
478
  throw new Error(`Function definition must be nested under the "function" key in the route props for "${routeKey}". ie. { function: { handler: "myfunc.handler" } }`);
473
- throw new Error(`Invalid route type for "${routeKey}". Must be one of: alb, url, function`);
479
+ throw new Error(`Invalid route type for "${routeKey}". Must be one of: alb, nlb, url, or function`);
474
480
  })();
475
481
  const { authorizationType, authorizer, authorizationScopes } = this.buildRouteAuth(routeProps);
476
482
  const route = new apig.HttpRoute(scope, `Route_${postfixName}`, {
@@ -520,6 +526,18 @@ export class Api extends Construct {
520
526
  };
521
527
  return integration;
522
528
  }
529
+ createNlbIntegration(scope, routeKey, routeProps, postfixName) {
530
+ ///////////////////
531
+ // Create integration
532
+ ///////////////////
533
+ const integration = new apigIntegrations.HttpNlbIntegration(`Integration_${postfixName}`, routeProps.cdk?.nlbListener, routeProps.cdk?.integration);
534
+ // Store route
535
+ this.routesData[routeKey] = {
536
+ type: "nlb",
537
+ nlb: routeProps.cdk?.nlbListener,
538
+ };
539
+ return integration;
540
+ }
523
541
  createGraphQLIntegration(scope, routeKey, routeProps, postfixName) {
524
542
  const result = this.createFunctionIntegration(scope, routeKey, {
525
543
  ...routeProps,
@@ -468,6 +468,11 @@ export class SsrSite extends Construct {
468
468
  }
469
469
  else {
470
470
  domainNames.push(customDomain.domainName);
471
+ if (customDomain.alternateNames) {
472
+ if (!customDomain.cdk?.certificate)
473
+ throw new Error("Certificates for alternate domains cannot be automatically created. Please specify certificate to use");
474
+ domainNames.push(...customDomain.alternateNames);
475
+ }
471
476
  }
472
477
  return domainNames;
473
478
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "sst",
3
- "version": "2.0.3",
3
+ "version": "2.0.5",
4
4
  "bin": {
5
5
  "sst": "cli/sst.js"
6
6
  },
@@ -33,10 +33,10 @@ export const usePythonHandler = Context.memo(async () => {
33
33
  },
34
34
  canHandle: (input) => input.startsWith("python"),
35
35
  startWorker: async (input) => {
36
- const src = "services";
36
+ const src = await findAbove(input.handler, "requirements.txt");
37
37
  const parsed = path.parse(path.relative(src, input.handler));
38
38
  const target = [...parsed.dir.split(path.sep), parsed.name].join(".");
39
- const proc = spawn(os.platform() === "win32" ? "python.exe" : "python3.6".split(".")[0], [
39
+ const proc = spawn(os.platform() === "win32" ? "python.exe" : "python3", [
40
40
  "-u",
41
41
  url.fileURLToPath(new URL("../../support/python-runtime/runtime.py", import.meta.url)),
42
42
  target,
@@ -51,7 +51,7 @@ export const usePythonHandler = Context.memo(async () => {
51
51
  AWS_LAMBDA_RUNTIME_API: `localhost:${server.port}/${input.workerID}`,
52
52
  },
53
53
  shell: true,
54
- cwd: path.join(process.cwd(), src),
54
+ cwd: src,
55
55
  });
56
56
  proc.on("exit", () => workers.exited(input.workerID));
57
57
  proc.stdout.on("data", (data) => {
package/sst.mjs CHANGED
@@ -5013,11 +5013,11 @@ var init_python = __esm({
5013
5013
  },
5014
5014
  canHandle: (input) => input.startsWith("python"),
5015
5015
  startWorker: async (input) => {
5016
- const src = "services";
5016
+ const src = await findAbove(input.handler, "requirements.txt");
5017
5017
  const parsed = path12.parse(path12.relative(src, input.handler));
5018
5018
  const target = [...parsed.dir.split(path12.sep), parsed.name].join(".");
5019
5019
  const proc = spawn4(
5020
- os3.platform() === "win32" ? "python.exe" : "python3.6".split(".")[0],
5020
+ os3.platform() === "win32" ? "python.exe" : "python3",
5021
5021
  [
5022
5022
  "-u",
5023
5023
  url6.fileURLToPath(
@@ -5036,7 +5036,7 @@ var init_python = __esm({
5036
5036
  AWS_LAMBDA_RUNTIME_API: `localhost:${server.port}/${input.workerID}`
5037
5037
  },
5038
5038
  shell: true,
5039
- cwd: path12.join(process.cwd(), src)
5039
+ cwd: src
5040
5040
  }
5041
5041
  );
5042
5042
  proc.on("exit", () => workers.exited(input.workerID));