sst 2.1.8 → 2.1.10

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,11 +1,12 @@
1
1
  import { Construct } from "constructs";
2
2
  import { SSTConstruct } from "./Construct.js";
3
- import { Function } from "./Function.js";
3
+ import { Function, NodeJSProps } from "./Function.js";
4
4
  import { Duration } from "./util/duration.js";
5
5
  import { Permissions } from "./util/permission.js";
6
6
  import { FunctionBindingProps } from "./util/functionBinding.js";
7
7
  import { IVpc } from "aws-cdk-lib/aws-ec2";
8
8
  export type JobMemorySize = "3 GB" | "7 GB" | "15 GB" | "145 GB";
9
+ export type JobNodeJSProps = NodeJSProps;
9
10
  export interface JobProps {
10
11
  /**
11
12
  * Path to the entry point and handler function. Of the format:
@@ -47,6 +48,10 @@ export interface JobProps {
47
48
  *```
48
49
  */
49
50
  timeout?: Duration;
51
+ /**
52
+ * Used to configure nodejs function properties
53
+ */
54
+ nodejs?: JobNodeJSProps;
50
55
  /**
51
56
  * Can be used to disable Live Lambda Development when using `sst start`. Useful for things like Custom Resources that need to execute during deployment.
52
57
  *
@@ -249,8 +249,10 @@ export declare class SsrSite extends Construct implements SSTConstruct {
249
249
  protected buildDistributionDomainNames(): string[];
250
250
  private buildDistributionDefaultBehaviorForRegional;
251
251
  private buildDistributionDefaultBehaviorForEdge;
252
+ private buildBehaviorFunctionAssociations;
252
253
  protected buildDistributionStaticFileBehaviors(origin: S3Origin): Record<string, BehaviorOptions>;
253
254
  protected createCloudFrontServerCachePolicy(): CachePolicy;
255
+ protected createCloudFrontServerOriginRequestPolicy(): import("aws-cdk-lib/aws-cloudfront").IOriginRequestPolicy;
254
256
  private createCloudFrontInvalidation;
255
257
  protected validateCustomDomainSettings(): void;
256
258
  protected lookupHostedZone(): IHostedZone | undefined;
@@ -12,7 +12,7 @@ import { Effect, Policy, PolicyStatement } from "aws-cdk-lib/aws-iam";
12
12
  import { Function, Code, Runtime, FunctionUrlAuthType, } from "aws-cdk-lib/aws-lambda";
13
13
  import { HostedZone, ARecord, AaaaRecord, RecordTarget, } from "aws-cdk-lib/aws-route53";
14
14
  import { Asset } from "aws-cdk-lib/aws-s3-assets";
15
- import { Distribution, ViewerProtocolPolicy, AllowedMethods, CachedMethods, LambdaEdgeEventType, CachePolicy, CacheQueryStringBehavior, CacheHeaderBehavior, CacheCookieBehavior, } from "aws-cdk-lib/aws-cloudfront";
15
+ import { Distribution, ViewerProtocolPolicy, AllowedMethods, CachedMethods, LambdaEdgeEventType, CachePolicy, CacheQueryStringBehavior, CacheHeaderBehavior, CacheCookieBehavior, OriginRequestPolicy, Function as CfFunction, FunctionCode as CfFunctionCode, FunctionEventType as CfFunctionEventType, } from "aws-cdk-lib/aws-cloudfront";
16
16
  import { AwsCliLayer } from "aws-cdk-lib/lambda-layer-awscli";
17
17
  import { S3Origin, HttpOrigin } from "aws-cdk-lib/aws-cloudfront-origins";
18
18
  import { CloudFrontTarget } from "aws-cdk-lib/aws-route53-targets";
@@ -484,11 +484,13 @@ export class SsrSite extends Construct {
484
484
  });
485
485
  return {
486
486
  viewerProtocolPolicy: ViewerProtocolPolicy.REDIRECT_TO_HTTPS,
487
+ functionAssociations: this.buildBehaviorFunctionAssociations(),
487
488
  origin: new HttpOrigin(Fn.parseDomainName(fnUrl.url)),
488
489
  allowedMethods: AllowedMethods.ALLOW_ALL,
489
490
  cachedMethods: CachedMethods.CACHE_GET_HEAD_OPTIONS,
490
491
  compress: true,
491
492
  cachePolicy: cdk?.serverCachePolicy ?? this.createCloudFrontServerCachePolicy(),
493
+ originRequestPolicy: this.createCloudFrontServerOriginRequestPolicy(),
492
494
  ...(cfDistributionProps.defaultBehavior || {}),
493
495
  };
494
496
  }
@@ -497,11 +499,13 @@ export class SsrSite extends Construct {
497
499
  const cfDistributionProps = cdk?.distribution || {};
498
500
  return {
499
501
  viewerProtocolPolicy: ViewerProtocolPolicy.REDIRECT_TO_HTTPS,
502
+ functionAssociations: this.buildBehaviorFunctionAssociations(),
500
503
  origin,
501
504
  allowedMethods: AllowedMethods.ALLOW_ALL,
502
505
  cachedMethods: CachedMethods.CACHE_GET_HEAD_OPTIONS,
503
506
  compress: true,
504
507
  cachePolicy: cdk?.serverCachePolicy ?? this.createCloudFrontServerCachePolicy(),
508
+ originRequestPolicy: this.createCloudFrontServerOriginRequestPolicy(),
505
509
  ...(cfDistributionProps.defaultBehavior || {}),
506
510
  // concatenate edgeLambdas
507
511
  edgeLambdas: [
@@ -514,6 +518,21 @@ export class SsrSite extends Construct {
514
518
  ],
515
519
  };
516
520
  }
521
+ buildBehaviorFunctionAssociations() {
522
+ return [
523
+ {
524
+ eventType: CfFunctionEventType.VIEWER_REQUEST,
525
+ function: new CfFunction(this, "CloudFrontFunction", {
526
+ code: CfFunctionCode.fromInline(`
527
+ function handler(event) {
528
+ var request = event.request;
529
+ request.headers["x-forwarded-host"] = request.headers.host;
530
+ return request;
531
+ }`),
532
+ }),
533
+ },
534
+ ];
535
+ }
517
536
  buildDistributionStaticFileBehaviors(origin) {
518
537
  const { cdk } = this.props;
519
538
  // Create additional behaviours for statics
@@ -551,6 +570,10 @@ export class SsrSite extends Construct {
551
570
  comment: "SST server response cache policy",
552
571
  });
553
572
  }
573
+ createCloudFrontServerOriginRequestPolicy() {
574
+ // CloudFront's Managed-AllViewerExceptHostHeader policy
575
+ return OriginRequestPolicy.fromOriginRequestPolicyId(this, "ServerOriginRequestPolicy", "b689b0a8-53d0-40ab-baf2-68738e2966ac");
576
+ }
554
577
  createCloudFrontInvalidation() {
555
578
  const stack = Stack.of(this);
556
579
  const policy = new Policy(this, "CloudFrontInvalidatorPolicy", {
@@ -17,7 +17,8 @@ const defaultHttpFields = [
17
17
  // caller info
18
18
  `"ip":"$context.identity.sourceIp"`,
19
19
  `"userAgent":"$context.identity.userAgent"`,
20
- `"cognitoIdentityId":"$context.identity.cognitoIdentityId"`,
20
+ // `cognitoIdentityId` is not supported in us-west-2 region
21
+ //`"cognitoIdentityId":"$context.identity.cognitoIdentityId"`,
21
22
  ];
22
23
  const defaultWebSocketFields = [
23
24
  // request info
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "sst",
3
- "version": "2.1.8",
3
+ "version": "2.1.10",
4
4
  "bin": {
5
5
  "sst": "cli/sst.js"
6
6
  },
@@ -133,7 +133,10 @@ export const usePythonHandler = Context.memo(async () => {
133
133
  */
134
134
  return {
135
135
  type: "success",
136
- handler: path.relative(src, path.resolve(input.props.handler)),
136
+ handler: path
137
+ .relative(src, path.resolve(input.props.handler))
138
+ .split(path.sep)
139
+ .join(path.posix.sep),
137
140
  };
138
141
  },
139
142
  });
package/sst.mjs CHANGED
@@ -5487,7 +5487,7 @@ var init_python = __esm({
5487
5487
  });
5488
5488
  return {
5489
5489
  type: "success",
5490
- handler: path14.relative(src, path14.resolve(input.props.handler))
5490
+ handler: path14.relative(src, path14.resolve(input.props.handler)).split(path14.sep).join(path14.posix.sep)
5491
5491
  };
5492
5492
  }
5493
5493
  });