sst 2.22.8 → 2.22.9

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,6 +1,6 @@
1
1
  import { Construct, IConstruct } from "constructs";
2
2
  import { Role } from "aws-cdk-lib/aws-iam";
3
- import { IVersion } from "aws-cdk-lib/aws-lambda";
3
+ import { IVersion, IFunction as CdkIFunction } from "aws-cdk-lib/aws-lambda";
4
4
  import { SSTConstruct } from "./Construct.js";
5
5
  import { NodeJSProps } from "./Function.js";
6
6
  import { Size } from "./util/size.js";
@@ -21,7 +21,8 @@ export interface EdgeFunctionProps {
21
21
  export declare class EdgeFunction extends Construct {
22
22
  role: Role;
23
23
  functionArn: string;
24
- private function;
24
+ function: CdkIFunction;
25
+ private functionCR;
25
26
  private assetReplacer;
26
27
  private assetReplacerPolicy;
27
28
  private scope;
@@ -24,6 +24,7 @@ export class EdgeFunction extends Construct {
24
24
  role;
25
25
  functionArn;
26
26
  function;
27
+ functionCR;
27
28
  assetReplacer;
28
29
  assetReplacerPolicy;
29
30
  scope;
@@ -57,7 +58,11 @@ export class EdgeFunction extends Construct {
57
58
  const { fn, fnArn } = this.createFunctionInUsEast1(assetBucket, assetKey, lambdaBucket);
58
59
  const { versionId } = this.createVersionInUsEast1(fn, fnArn);
59
60
  fn.node.addDependency(assetReplacer);
60
- this.function = fn;
61
+ this.function = CdkFunction.fromFunctionAttributes(this.scope, "ICdkFunction", {
62
+ functionArn: fnArn,
63
+ role: this.role,
64
+ });
65
+ this.functionCR = fn;
61
66
  this.functionArn = fnArn;
62
67
  this.versionId = versionId;
63
68
  this.assetReplacer = assetReplacer;
@@ -343,7 +348,7 @@ export class EdgeFunction extends Construct {
343
348
  return { fn, fnArn: fn.getAttString("FunctionArn") };
344
349
  }
345
350
  updateFunctionInUsEast1(assetBucket, assetKey) {
346
- const cfnLambda = this.function.node.defaultChild;
351
+ const cfnLambda = this.functionCR.node.defaultChild;
347
352
  cfnLambda.addPropertyOverride("FunctionParams.Code", {
348
353
  S3Bucket: assetBucket,
349
354
  S3Key: assetKey,
@@ -273,7 +273,6 @@ export declare abstract class SsrSite extends Construct implements SSTConstruct
273
273
  protected doNotDeploy: boolean;
274
274
  protected buildConfig: SsrBuildConfig;
275
275
  protected deferredTaskCallbacks: (() => void)[];
276
- private serverLambdaCdkFunctionForEdge?;
277
276
  protected serverLambdaForEdge?: EdgeFunction;
278
277
  protected serverLambdaForRegional?: SsrFunction;
279
278
  private serverLambdaForDev?;
@@ -297,7 +296,7 @@ export declare abstract class SsrSite extends Construct implements SSTConstruct
297
296
  * The internally created CDK resources.
298
297
  */
299
298
  get cdk(): {
300
- function: ICdkFunction | SsrFunction | undefined;
299
+ function: ICdkFunction | undefined;
301
300
  bucket: Bucket;
302
301
  distribution: Distribution;
303
302
  hostedZone: IHostedZone | undefined;
@@ -48,7 +48,6 @@ export class SsrSite extends Construct {
48
48
  doNotDeploy;
49
49
  buildConfig;
50
50
  deferredTaskCallbacks = [];
51
- serverLambdaCdkFunctionForEdge;
52
51
  serverLambdaForEdge;
53
52
  serverLambdaForRegional;
54
53
  serverLambdaForDev;
@@ -89,10 +88,6 @@ export class SsrSite extends Construct {
89
88
  // Create Server functions
90
89
  if (this.props.edge) {
91
90
  this.serverLambdaForEdge = this.createFunctionForEdge();
92
- this.serverLambdaCdkFunctionForEdge = CdkFunction.fromFunctionAttributes(this, "IEdgeFunction", {
93
- functionArn: this.serverLambdaForEdge.functionArn,
94
- role: this.serverLambdaForEdge.role,
95
- });
96
91
  }
97
92
  else {
98
93
  this.serverLambdaForRegional = this.createFunctionForRegional();
@@ -168,7 +163,8 @@ export class SsrSite extends Construct {
168
163
  if (this.doNotDeploy)
169
164
  return;
170
165
  return {
171
- function: this.serverLambdaCdkFunctionForEdge || this.serverLambdaForRegional,
166
+ function: this.serverLambdaForEdge?.function ||
167
+ this.serverLambdaForRegional?.function,
172
168
  bucket: this.bucket,
173
169
  distribution: this.distribution,
174
170
  hostedZone: this.hostedZone,
@@ -188,7 +184,7 @@ export class SsrSite extends Construct {
188
184
  * ```
189
185
  */
190
186
  attachPermissions(permissions) {
191
- const server = this.serverLambdaCdkFunctionForEdge ||
187
+ const server = this.serverLambdaForEdge ||
192
188
  this.serverLambdaForRegional ||
193
189
  this.serverLambdaForDev;
194
190
  attachPermissionsToRole(server?.role, permissions);
@@ -206,7 +202,7 @@ export class SsrSite extends Construct {
206
202
  edge: this.props.edge,
207
203
  server: (this.serverLambdaForDev ||
208
204
  this.serverLambdaForRegional ||
209
- this.serverLambdaCdkFunctionForEdge)?.functionArn,
205
+ this.serverLambdaForEdge)?.functionArn,
210
206
  secrets: (this.props.bind || [])
211
207
  .filter((c) => c instanceof Secret)
212
208
  .map((c) => c.name),
@@ -480,12 +476,12 @@ export class SsrSite extends Construct {
480
476
  return ssrFn;
481
477
  }
482
478
  grantServerS3Permissions() {
483
- const server = this.serverLambdaCdkFunctionForEdge || this.serverLambdaForRegional;
479
+ const server = this.serverLambdaForEdge || this.serverLambdaForRegional;
484
480
  this.bucket.grantReadWrite(server.role);
485
481
  }
486
482
  grantServerCloudFrontPermissions() {
487
483
  const stack = Stack.of(this);
488
- const server = this.serverLambdaCdkFunctionForEdge || this.serverLambdaForRegional;
484
+ const server = this.serverLambdaForEdge || this.serverLambdaForRegional;
489
485
  const policy = new Policy(this, "ServerFunctionInvalidatorPolicy", {
490
486
  statements: [
491
487
  new PolicyStatement({
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "sideEffects": false,
3
3
  "name": "sst",
4
- "version": "2.22.8",
4
+ "version": "2.22.9",
5
5
  "bin": {
6
6
  "sst": "cli/sst.js"
7
7
  },