sst 2.0.35 → 2.0.37

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.
Files changed (60) hide show
  1. package/bootstrap.js +1 -1
  2. package/constructs/Api.d.ts +2 -10
  3. package/constructs/Api.js +2 -2
  4. package/constructs/ApiGatewayV1Api.d.ts +2 -10
  5. package/constructs/ApiGatewayV1Api.js +2 -2
  6. package/constructs/App.d.ts +0 -2
  7. package/constructs/App.js +3 -7
  8. package/constructs/AppSyncApi.d.ts +2 -10
  9. package/constructs/AppSyncApi.js +2 -2
  10. package/constructs/Auth.js +10 -7
  11. package/constructs/Bucket.d.ts +2 -12
  12. package/constructs/Bucket.js +2 -2
  13. package/constructs/EventBus.d.ts +2 -12
  14. package/constructs/EventBus.js +2 -2
  15. package/constructs/Function.d.ts +3 -12
  16. package/constructs/Function.js +10 -6
  17. package/constructs/Job.d.ts +3 -13
  18. package/constructs/Job.js +9 -7
  19. package/constructs/KinesisStream.d.ts +2 -12
  20. package/constructs/KinesisStream.js +2 -2
  21. package/constructs/NextjsSite.js +19 -30
  22. package/constructs/Parameter.d.ts +2 -10
  23. package/constructs/Parameter.js +2 -2
  24. package/constructs/Queue.d.ts +2 -12
  25. package/constructs/Queue.js +2 -2
  26. package/constructs/RDS.d.ts +2 -22
  27. package/constructs/RDS.js +7 -7
  28. package/constructs/Secret.js +2 -4
  29. package/constructs/SsrSite.js +14 -9
  30. package/constructs/StaticSite.js +14 -9
  31. package/constructs/Table.d.ts +2 -12
  32. package/constructs/Table.js +2 -2
  33. package/constructs/Topic.d.ts +2 -12
  34. package/constructs/Topic.js +2 -2
  35. package/constructs/WebSocketApi.d.ts +2 -10
  36. package/constructs/WebSocketApi.js +2 -2
  37. package/constructs/deprecated/NextjsSite.js +4 -4
  38. package/constructs/util/functionBinding.d.ts +14 -3
  39. package/constructs/util/functionBinding.js +45 -11
  40. package/node/api/index.js +5 -5
  41. package/node/auth/auth.js +9 -53
  42. package/node/bucket/index.js +2 -2
  43. package/node/config/index.js +4 -56
  44. package/node/event-bus/index.js +2 -2
  45. package/node/function/index.js +2 -2
  46. package/node/job/index.js +2 -2
  47. package/node/kinesis-stream/index.js +2 -2
  48. package/node/queue/index.js +2 -2
  49. package/node/rds/index.js +2 -2
  50. package/node/site/index.js +6 -52
  51. package/node/table/index.js +2 -2
  52. package/node/topic/index.js +2 -2
  53. package/node/util/index.d.ts +1 -6
  54. package/node/util/index.js +122 -26
  55. package/package.json +1 -1
  56. package/runtime/handlers/node.js +2 -0
  57. package/runtime/server.js +1 -5
  58. package/sst.mjs +6 -6
  59. package/support/bridge/bridge.mjs +23 -23
  60. /package/support/{ssr-site-function-stub → sls-nextjs-site-function-stub}/index.js +0 -0
package/bootstrap.js CHANGED
@@ -105,7 +105,7 @@ export async function bootstrapSST(tags) {
105
105
  const fn = new Function(stack, "MetadataHandler", {
106
106
  code: Code.fromAsset(path.resolve(__dirname, "support/bootstrap-metadata-function")),
107
107
  handler: "index.handler",
108
- runtime: app.region?.startsWith("us-gov-")
108
+ runtime: project.config.region?.startsWith("us-gov-")
109
109
  ? Runtime.NODEJS_16_X
110
110
  : Runtime.NODEJS_18_X,
111
111
  environment: {
@@ -8,6 +8,7 @@ import * as lambda from "aws-cdk-lib/aws-lambda";
8
8
  import * as logs from "aws-cdk-lib/aws-logs";
9
9
  import { SSTConstruct } from "./Construct.js";
10
10
  import { Function as Fn, FunctionProps, FunctionInlineDefinition, FunctionDefinition } from "./Function.js";
11
+ import { FunctionBindingProps } from "./util/functionBinding.js";
11
12
  import { Duration } from "./util/duration.js";
12
13
  import { Permissions } from "./util/permission.js";
13
14
  import * as apigV2Cors from "./util/apiGatewayV2Cors.js";
@@ -741,16 +742,7 @@ export declare class Api<Authorizers extends Record<string, ApiAuthorizer> = Rec
741
742
  };
742
743
  };
743
744
  /** @internal */
744
- getFunctionBinding(): {
745
- clientPackage: string;
746
- variables: {
747
- url: {
748
- environment: string;
749
- parameter: string;
750
- };
751
- };
752
- permissions: {};
753
- };
745
+ getFunctionBinding(): FunctionBindingProps;
754
746
  private createHttpApi;
755
747
  private addAuthorizers;
756
748
  private addRoute;
package/constructs/Api.js CHANGED
@@ -244,8 +244,8 @@ export class Api extends Construct {
244
244
  clientPackage: "api",
245
245
  variables: {
246
246
  url: {
247
- environment: this.customDomainUrl || this.url,
248
- parameter: this.customDomainUrl || this.url,
247
+ type: "plain",
248
+ value: this.customDomainUrl || this.url,
249
249
  },
250
250
  },
251
251
  permissions: {},
@@ -7,6 +7,7 @@ import * as lambda from "aws-cdk-lib/aws-lambda";
7
7
  import * as apig from "aws-cdk-lib/aws-apigateway";
8
8
  import * as apigV1AccessLog from "./util/apiGatewayV1AccessLog.js";
9
9
  import { Bucket } from "./Bucket.js";
10
+ import { FunctionBindingProps } from "./util/functionBinding.js";
10
11
  import { Duration } from "./util/duration.js";
11
12
  import { SSTConstruct } from "./Construct.js";
12
13
  import { Function as Fn, FunctionProps, FunctionInlineDefinition, FunctionDefinition } from "./Function.js";
@@ -622,16 +623,7 @@ export declare class ApiGatewayV1Api<Authorizers extends Record<string, ApiGatew
622
623
  };
623
624
  };
624
625
  /** @internal */
625
- getFunctionBinding(): {
626
- clientPackage: string;
627
- variables: {
628
- url: {
629
- environment: string;
630
- parameter: string;
631
- };
632
- };
633
- permissions: {};
634
- };
626
+ getFunctionBinding(): FunctionBindingProps;
635
627
  private createRestApi;
636
628
  private buildCorsConfig;
637
629
  private createGatewayResponseForCors;
@@ -234,8 +234,8 @@ export class ApiGatewayV1Api extends Construct {
234
234
  clientPackage: "api",
235
235
  variables: {
236
236
  url: {
237
- environment: this.customDomainUrl || this.url,
238
- parameter: this.customDomainUrl || this.url,
237
+ type: "plain",
238
+ value: this.customDomainUrl || this.url,
239
239
  },
240
240
  },
241
241
  permissions: {},
@@ -1,6 +1,5 @@
1
1
  import * as cdk from "aws-cdk-lib";
2
2
  import * as lambda from "aws-cdk-lib/aws-lambda";
3
- import * as cxapi from "aws-cdk-lib/cx-api";
4
3
  import { SSTConstruct } from "./Construct.js";
5
4
  import { FunctionProps } from "./Function.js";
6
5
  import { Permissions } from "./util/permission.js";
@@ -172,7 +171,6 @@ export declare class App extends cdk.App {
172
171
  * Adds additional default layers to be applied to all Lambda functions in the stack.
173
172
  */
174
173
  addDefaultFunctionLayers(layers: lambda.ILayerVersion[]): void;
175
- synth(options?: cdk.StageSynthesisOptions): cxapi.CloudAssembly;
176
174
  finish(): Promise<void>;
177
175
  isRunningSSTTest(): boolean;
178
176
  getInputFilesFromEsbuildMetafile(file: string): Array<string>;
package/constructs/App.js CHANGED
@@ -202,8 +202,10 @@ export class App extends cdk.App {
202
202
  layers,
203
203
  });
204
204
  }
205
- synth(options = {}) {
205
+ async finish() {
206
+ await useDeferredTasks().run();
206
207
  Auth.injectConfig();
208
+ this.buildConstructsMetadata();
207
209
  this.ensureUniqueConstructIds();
208
210
  this.codegenTypes();
209
211
  this.createBindingSsmParameters();
@@ -224,12 +226,6 @@ export class App extends cdk.App {
224
226
  }
225
227
  }
226
228
  }
227
- const cloudAssembly = super.synth(options);
228
- return cloudAssembly;
229
- }
230
- async finish() {
231
- await useDeferredTasks().run();
232
- this.buildConstructsMetadata();
233
229
  }
234
230
  isRunningSSTTest() {
235
231
  // Check the env var set inside test/setup-tests.js
@@ -10,6 +10,7 @@ import { RDS } from "./RDS.js";
10
10
  import * as appSyncApiDomain from "./util/appSyncApiDomain.js";
11
11
  import { SSTConstruct } from "./Construct.js";
12
12
  import { Function as Fn, FunctionProps, FunctionInlineDefinition, FunctionDefinition } from "./Function.js";
13
+ import { FunctionBindingProps } from "./util/functionBinding.js";
13
14
  import { Permissions } from "./util/permission.js";
14
15
  export interface AppSyncApiDomainProps extends appSyncApiDomain.CustomDomainProps {
15
16
  }
@@ -506,16 +507,7 @@ export declare class AppSyncApi extends Construct implements SSTConstruct {
506
507
  };
507
508
  };
508
509
  /** @internal */
509
- getFunctionBinding(): {
510
- clientPackage: string;
511
- variables: {
512
- url: {
513
- environment: string;
514
- parameter: string;
515
- };
516
- };
517
- permissions: {};
518
- };
510
+ getFunctionBinding(): FunctionBindingProps;
519
511
  private createGraphApi;
520
512
  private addDataSource;
521
513
  private addResolver;
@@ -256,8 +256,8 @@ export class AppSyncApi extends Construct {
256
256
  clientPackage: "api",
257
257
  variables: {
258
258
  url: {
259
- environment: this.customDomainUrl || this.url,
260
- parameter: this.customDomainUrl || this.url,
259
+ type: "plain",
260
+ value: this.customDomainUrl || this.url,
261
261
  },
262
262
  },
263
263
  permissions: {},
@@ -2,7 +2,7 @@ import * as ssm from "aws-cdk-lib/aws-ssm";
2
2
  import { Effect, Policy, PolicyStatement } from "aws-cdk-lib/aws-iam";
3
3
  import { Construct } from "constructs";
4
4
  import { Stack } from "./Stack.js";
5
- import { ENVIRONMENT_PLACEHOLDER, getEnvironmentKey, getParameterPath, } from "./util/functionBinding.js";
5
+ import { getEnvironmentKey, getParameterPath, placeholderSecretValue, } from "./util/functionBinding.js";
6
6
  import { CustomResource } from "aws-cdk-lib";
7
7
  const PUBLIC_KEY_PROP = "publicKey";
8
8
  const PRIVATE_KEY_PROP = "privateKey";
@@ -76,10 +76,13 @@ export class Auth extends Construct {
76
76
  clientPackage: "auth",
77
77
  variables: {
78
78
  publicKey: {
79
- environment: ENVIRONMENT_PLACEHOLDER,
80
- // SSM parameters will be created by the custom resource
81
- parameter: undefined,
79
+ type: "secret",
82
80
  },
81
+ // Example of referencing a secret
82
+ //publicKey2: {
83
+ // type: "secret_reference",
84
+ // secret: this.publicKey2,
85
+ //},
83
86
  },
84
87
  permissions: {
85
88
  "ssm:GetParameters": [
@@ -123,12 +126,12 @@ export class Auth extends Construct {
123
126
  });
124
127
  // Auth construct has two types of Function bindinds:
125
128
  // - Api routes: bindings defined in `getFunctionBinding()`
126
- // ie. calling `use.([auth])` will grant functions access to the public key
129
+ // ie. calling `bind([auth])` will grant functions access to the public key
127
130
  // - Auth authenticator: binds manually. Need to grant access to the prefix and private key
128
131
  const fn = props.api.getFunction(path);
129
132
  fn.addEnvironment(getEnvironmentKey(this, PREFIX_PROP), prefix);
130
- fn.addEnvironment(getEnvironmentKey(this, PUBLIC_KEY_PROP), ENVIRONMENT_PLACEHOLDER);
131
- fn.addEnvironment(getEnvironmentKey(this, PRIVATE_KEY_PROP), ENVIRONMENT_PLACEHOLDER);
133
+ fn.addEnvironment(getEnvironmentKey(this, PUBLIC_KEY_PROP), placeholderSecretValue());
134
+ fn.addEnvironment(getEnvironmentKey(this, PRIVATE_KEY_PROP), placeholderSecretValue());
132
135
  fn.attachPermissions([
133
136
  new PolicyStatement({
134
137
  actions: ["ssm:GetParameters"],
@@ -4,6 +4,7 @@ import { Queue } from "./Queue.js";
4
4
  import { Topic } from "./Topic.js";
5
5
  import { SSTConstruct } from "./Construct.js";
6
6
  import { Function as Fn, FunctionProps, FunctionInlineDefinition, FunctionDefinition } from "./Function.js";
7
+ import { FunctionBindingProps } from "./util/functionBinding.js";
7
8
  import { Permissions } from "./util/permission.js";
8
9
  import { Duration } from "./util/duration.js";
9
10
  export interface BucketCorsRule {
@@ -339,18 +340,7 @@ export declare class Bucket extends Construct implements SSTConstruct {
339
340
  };
340
341
  };
341
342
  /** @internal */
342
- getFunctionBinding(): {
343
- clientPackage: string;
344
- variables: {
345
- bucketName: {
346
- environment: string;
347
- parameter: string;
348
- };
349
- };
350
- permissions: {
351
- "s3:*": string[];
352
- };
353
- };
343
+ getFunctionBinding(): FunctionBindingProps;
354
344
  private createBucket;
355
345
  private addNotification;
356
346
  private addQueueNotification;
@@ -161,8 +161,8 @@ export class Bucket extends Construct {
161
161
  clientPackage: "bucket",
162
162
  variables: {
163
163
  bucketName: {
164
- environment: this.bucketName,
165
- parameter: this.bucketName,
164
+ type: "plain",
165
+ value: this.bucketName,
166
166
  },
167
167
  },
168
168
  permissions: {
@@ -5,6 +5,7 @@ import * as eventsTargets from "aws-cdk-lib/aws-events-targets";
5
5
  import { Queue } from "./Queue.js";
6
6
  import { SSTConstruct } from "./Construct.js";
7
7
  import { FunctionProps, FunctionInlineDefinition, FunctionDefinition } from "./Function.js";
8
+ import { FunctionBindingProps } from "./util/functionBinding.js";
8
9
  import { Permissions } from "./util/permission.js";
9
10
  /**
10
11
  * Used to configure an EventBus function target
@@ -375,18 +376,7 @@ export declare class EventBus extends Construct implements SSTConstruct {
375
376
  };
376
377
  };
377
378
  /** @internal */
378
- getFunctionBinding(): {
379
- clientPackage: string;
380
- variables: {
381
- eventBusName: {
382
- environment: string;
383
- parameter: string;
384
- };
385
- };
386
- permissions: {
387
- "events:*": string[];
388
- };
389
- };
379
+ getFunctionBinding(): FunctionBindingProps;
390
380
  private createEventBus;
391
381
  private addRule;
392
382
  private addTarget;
@@ -215,8 +215,8 @@ export class EventBus extends Construct {
215
215
  clientPackage: "event-bus",
216
216
  variables: {
217
217
  eventBusName: {
218
- environment: this.eventBusName,
219
- parameter: this.eventBusName,
218
+ type: "plain",
219
+ value: this.eventBusName,
220
220
  },
221
221
  },
222
222
  permissions: {
@@ -7,6 +7,7 @@ import { Stack } from "./Stack.js";
7
7
  import { SSTConstruct } from "./Construct.js";
8
8
  import { Size } from "./util/size.js";
9
9
  import { Duration } from "./util/duration.js";
10
+ import { FunctionBindingProps } from "./util/functionBinding.js";
10
11
  import { Permissions } from "./util/permission.js";
11
12
  import * as functionUrlCors from "./util/functionUrlCors.js";
12
13
  declare const supportedRuntimes: {
@@ -552,6 +553,7 @@ export declare class Function extends lambda.Function implements SSTConstruct {
552
553
  _disableBind?: boolean;
553
554
  private functionUrl?;
554
555
  private props;
556
+ private allBindings;
555
557
  constructor(scope: Construct, id: string, props: FunctionProps);
556
558
  /**
557
559
  * The AWS generated URL of the Function.
@@ -585,18 +587,7 @@ export declare class Function extends lambda.Function implements SSTConstruct {
585
587
  };
586
588
  };
587
589
  /** @internal */
588
- getFunctionBinding(): {
589
- clientPackage: string;
590
- variables: {
591
- functionName: {
592
- environment: string;
593
- parameter: string;
594
- };
595
- };
596
- permissions: {
597
- "lambda:*": string[];
598
- };
599
- };
590
+ getFunctionBinding(): FunctionBindingProps;
600
591
  private createUrl;
601
592
  private isNodeRuntime;
602
593
  static validateHandlerSet(id: string, props: FunctionProps): void;
@@ -11,7 +11,7 @@ import { Job } from "./Job.js";
11
11
  import { Secret } from "./Config.js";
12
12
  import { toCdkSize } from "./util/size.js";
13
13
  import { toCdkDuration } from "./util/duration.js";
14
- import { bindEnvironment, bindPermissions } from "./util/functionBinding.js";
14
+ import { bindEnvironment, bindPermissions, getReferencedSecrets, } from "./util/functionBinding.js";
15
15
  import { attachPermissionsToRole } from "./util/permission.js";
16
16
  import * as functionUrlCors from "./util/functionUrlCors.js";
17
17
  import url from "url";
@@ -67,6 +67,7 @@ export class Function extends lambda.Function {
67
67
  _disableBind;
68
68
  functionUrl;
69
69
  props;
70
+ allBindings = [];
70
71
  constructor(scope, id, props) {
71
72
  const app = scope.node.root;
72
73
  const stack = Stack.of(scope);
@@ -254,7 +255,10 @@ export class Function extends lambda.Function {
254
255
  * ```
255
256
  */
256
257
  bind(constructs) {
257
- constructs.forEach((c) => {
258
+ // Get referenced secrets
259
+ const referencedSecrets = [];
260
+ constructs.forEach((c) => referencedSecrets.push(...getReferencedSecrets(c)));
261
+ [...constructs, ...referencedSecrets].forEach((c) => {
258
262
  // Bind environment
259
263
  const env = bindEnvironment(c);
260
264
  Object.entries(env).forEach(([key, value]) => this.addEnvironment(key, value));
@@ -268,6 +272,7 @@ export class Function extends lambda.Function {
268
272
  }),
269
273
  ]));
270
274
  });
275
+ this.allBindings.push(...constructs, ...referencedSecrets);
271
276
  }
272
277
  /**
273
278
  * Attaches additional permissions to function.
@@ -291,13 +296,12 @@ export class Function extends lambda.Function {
291
296
  }
292
297
  /** @internal */
293
298
  getConstructMetadata() {
294
- const { bind } = this.props;
295
299
  return {
296
300
  type: "Function",
297
301
  data: {
298
302
  arn: this.functionArn,
299
303
  localId: this.node.addr,
300
- secrets: (bind || [])
304
+ secrets: this.allBindings
301
305
  .filter((c) => c instanceof Secret)
302
306
  .map((c) => c.name),
303
307
  },
@@ -309,8 +313,8 @@ export class Function extends lambda.Function {
309
313
  clientPackage: "function",
310
314
  variables: {
311
315
  functionName: {
312
- environment: this.functionName,
313
- parameter: this.functionName,
316
+ type: "plain",
317
+ value: this.functionName,
314
318
  },
315
319
  },
316
320
  permissions: {
@@ -3,6 +3,7 @@ import { SSTConstruct } from "./Construct.js";
3
3
  import { Function } from "./Function.js";
4
4
  import { Duration } from "./util/duration.js";
5
5
  import { Permissions } from "./util/permission.js";
6
+ import { FunctionBindingProps } from "./util/functionBinding.js";
6
7
  import { IVpc } from "aws-cdk-lib/aws-ec2";
7
8
  export type JobMemorySize = "3 GB" | "7 GB" | "15 GB" | "145 GB";
8
9
  export interface JobProps {
@@ -147,18 +148,7 @@ export declare class Job extends Construct implements SSTConstruct {
147
148
  data: {};
148
149
  };
149
150
  /** @internal */
150
- getFunctionBinding(): {
151
- clientPackage: string;
152
- variables: {
153
- functionName: {
154
- environment: string;
155
- parameter: string;
156
- };
157
- };
158
- permissions: {
159
- "lambda:*": string[];
160
- };
161
- };
151
+ getFunctionBinding(): FunctionBindingProps;
162
152
  /**
163
153
  * Binds additional resources to job.
164
154
  *
@@ -193,7 +183,7 @@ export declare class Job extends Construct implements SSTConstruct {
193
183
  private updateCodeBuildProjectCode;
194
184
  private createLocalInvoker;
195
185
  private createCodeBuildInvoker;
196
- private useForCodeBuild;
186
+ private bindForCodeBuild;
197
187
  private attachPermissionsForCodeBuild;
198
188
  private addEnvironmentForCodeBuild;
199
189
  private normalizeMemorySize;
package/constructs/Job.js CHANGED
@@ -10,7 +10,7 @@ import { Stack } from "./Stack.js";
10
10
  import { Function, useFunctions } from "./Function.js";
11
11
  import { toCdkDuration } from "./util/duration.js";
12
12
  import { attachPermissionsToRole } from "./util/permission.js";
13
- import { bindEnvironment, bindPermissions } from "./util/functionBinding.js";
13
+ import { bindEnvironment, bindPermissions, getReferencedSecrets, } from "./util/functionBinding.js";
14
14
  import { useDeferredTasks } from "./deferred_task.js";
15
15
  import { useProject } from "../project.js";
16
16
  import { useRuntimeHandlers } from "../runtime/handlers.js";
@@ -79,8 +79,8 @@ export class Job extends Construct {
79
79
  clientPackage: "job",
80
80
  variables: {
81
81
  functionName: {
82
- environment: this._jobInvoker.functionName,
83
- parameter: this._jobInvoker.functionName,
82
+ type: "plain",
83
+ value: this._jobInvoker.functionName,
84
84
  },
85
85
  },
86
86
  permissions: {
@@ -98,7 +98,7 @@ export class Job extends Construct {
98
98
  */
99
99
  bind(constructs) {
100
100
  this._jobInvoker.bind(constructs);
101
- this.useForCodeBuild(constructs);
101
+ this.bindForCodeBuild(constructs);
102
102
  }
103
103
  /**
104
104
  * Attaches the given list of [permissions](Permissions.md) to the job. This allows the job to access other AWS resources.
@@ -265,9 +265,11 @@ export class Job extends Construct {
265
265
  fn._disableBind = true;
266
266
  return fn;
267
267
  }
268
- useForCodeBuild(constructs) {
269
- const app = this.node.root;
270
- constructs.forEach((c) => {
268
+ bindForCodeBuild(constructs) {
269
+ // Get referenced secrets
270
+ const referencedSecrets = [];
271
+ constructs.forEach((c) => referencedSecrets.push(...getReferencedSecrets(c)));
272
+ [...constructs, ...referencedSecrets].forEach((c) => {
271
273
  // Bind environment
272
274
  const env = bindEnvironment(c);
273
275
  Object.entries(env).forEach(([key, value]) => this.addEnvironmentForCodeBuild(key, value));
@@ -3,6 +3,7 @@ import * as kinesis from "aws-cdk-lib/aws-kinesis";
3
3
  import * as lambdaEventSources from "aws-cdk-lib/aws-lambda-event-sources";
4
4
  import { SSTConstruct } from "./Construct.js";
5
5
  import { Function as Fn, FunctionProps, FunctionInlineDefinition, FunctionDefinition } from "./Function.js";
6
+ import { FunctionBindingProps } from "./util/functionBinding.js";
6
7
  import { Permissions } from "./util/permission.js";
7
8
  /**
8
9
  * Used to define the function consumer for the stream
@@ -217,18 +218,7 @@ export declare class KinesisStream extends Construct implements SSTConstruct {
217
218
  };
218
219
  };
219
220
  /** @internal */
220
- getFunctionBinding(): {
221
- clientPackage: string;
222
- variables: {
223
- streamName: {
224
- environment: string;
225
- parameter: string;
226
- };
227
- };
228
- permissions: {
229
- "kinesis:*": string[];
230
- };
231
- };
221
+ getFunctionBinding(): FunctionBindingProps;
232
222
  private createStream;
233
223
  private addConsumer;
234
224
  }
@@ -152,8 +152,8 @@ export class KinesisStream extends Construct {
152
152
  clientPackage: "kinesis-stream",
153
153
  variables: {
154
154
  streamName: {
155
- environment: this.streamName,
156
- parameter: this.streamName,
155
+ type: "plain",
156
+ value: this.streamName,
157
157
  },
158
158
  },
159
159
  permissions: {
@@ -84,51 +84,40 @@ export class NextjsSite extends SsrSite {
84
84
  createMiddlewareEdgeFunctionForRegional() {
85
85
  const { permissions, environment, path: sitePath } = this.props;
86
86
  const middlewarePath = path.resolve(sitePath, ".open-next/middleware-function");
87
- const isMiddlewareEnabled = fs.existsSync(middlewarePath);
88
- let bundlePath, handler;
89
- if (isMiddlewareEnabled) {
90
- bundlePath = middlewarePath;
91
- handler = "index.handler";
87
+ if (fs.existsSync(middlewarePath)) {
88
+ return new EdgeFunction(this, "Middleware", {
89
+ bundlePath: middlewarePath,
90
+ handler: "index.handler",
91
+ timeout: 5,
92
+ memorySize: 128,
93
+ permissions,
94
+ environment,
95
+ format: "esm",
96
+ });
92
97
  }
93
- else {
94
- bundlePath = path.resolve(__dirname, "../support/ssr-site-function-stub");
95
- handler = "server.handler";
96
- }
97
- const fn = new EdgeFunction(this, "Middleware", {
98
- bundlePath,
99
- handler,
100
- timeout: 5,
101
- memorySize: 128,
102
- permissions,
103
- environment,
104
- format: "esm",
105
- });
106
- return { fn, isMiddlewareEnabled };
107
98
  }
108
99
  createCloudFrontDistributionForRegional() {
109
100
  const { cdk } = this.props;
110
101
  const cfDistributionProps = cdk?.distribution || {};
111
102
  const s3Origin = new origins.S3Origin(this.cdk.bucket);
112
103
  // Create server behavior
113
- const { fn: middlewareFn, isMiddlewareEnabled } = this.createMiddlewareEdgeFunctionForRegional();
114
- const fnUrl = this.serverLambdaForRegional.addFunctionUrl({
104
+ const middlewareFn = this.createMiddlewareEdgeFunctionForRegional();
105
+ const serverFnUrl = this.serverLambdaForRegional.addFunctionUrl({
115
106
  authType: lambda.FunctionUrlAuthType.NONE,
116
107
  });
117
108
  const serverBehavior = {
118
109
  viewerProtocolPolicy: cloudfront.ViewerProtocolPolicy.REDIRECT_TO_HTTPS,
119
- origin: new origins.HttpOrigin(Fn.parseDomainName(fnUrl.url)),
110
+ origin: new origins.HttpOrigin(Fn.parseDomainName(serverFnUrl.url)),
120
111
  allowedMethods: cloudfront.AllowedMethods.ALLOW_ALL,
121
112
  cachedMethods: cloudfront.CachedMethods.CACHE_GET_HEAD_OPTIONS,
122
113
  compress: true,
123
114
  cachePolicy: cdk?.serverCachePolicy ?? this.createCloudFrontServerCachePolicy(),
124
- edgeLambdas: isMiddlewareEnabled
125
- ? [
126
- {
127
- eventType: cloudfront.LambdaEdgeEventType.VIEWER_REQUEST,
128
- functionVersion: middlewareFn.currentVersion,
129
- },
130
- ]
131
- : undefined,
115
+ edgeLambdas: middlewareFn && [
116
+ {
117
+ eventType: cloudfront.LambdaEdgeEventType.VIEWER_REQUEST,
118
+ functionVersion: middlewareFn.currentVersion,
119
+ },
120
+ ],
132
121
  };
133
122
  // Create image optimization behavior
134
123
  const imageFn = this.createImageOptimizationFunctionForRegional();
@@ -1,5 +1,6 @@
1
1
  import { Construct } from "constructs";
2
2
  import { SSTConstruct } from "./Construct.js";
3
+ import { FunctionBindingProps } from "./util/functionBinding.js";
3
4
  export interface ParameterProps {
4
5
  /**
5
6
  * Value of the parameter
@@ -31,15 +32,6 @@ export declare class Parameter extends Construct implements SSTConstruct {
31
32
  };
32
33
  };
33
34
  /** @internal */
34
- getFunctionBinding(): {
35
- clientPackage: string;
36
- variables: {
37
- value: {
38
- environment: string;
39
- parameter: string;
40
- };
41
- };
42
- permissions: {};
43
- };
35
+ getFunctionBinding(): FunctionBindingProps;
44
36
  static create<T extends Record<string, any>>(scope: Construct, parameters: T): { [key in keyof T]: Parameter; };
45
37
  }
@@ -36,8 +36,8 @@ export class Parameter extends Construct {
36
36
  clientPackage: "config",
37
37
  variables: {
38
38
  value: {
39
- environment: this.value,
40
- parameter: this.value,
39
+ type: "plain",
40
+ value: this.value,
41
41
  },
42
42
  },
43
43
  permissions: {},
@@ -4,6 +4,7 @@ import * as lambda from "aws-cdk-lib/aws-lambda";
4
4
  import * as lambdaEventSources from "aws-cdk-lib/aws-lambda-event-sources";
5
5
  import { SSTConstruct } from "./Construct.js";
6
6
  import { Function as Fn, FunctionInlineDefinition, FunctionDefinition } from "./Function.js";
7
+ import { FunctionBindingProps } from "./util/functionBinding.js";
7
8
  import { Permissions } from "./util/permission.js";
8
9
  /**
9
10
  * Used to define the consumer for the queue and invocation details
@@ -188,17 +189,6 @@ export declare class Queue extends Construct implements SSTConstruct {
188
189
  };
189
190
  };
190
191
  /** @internal */
191
- getFunctionBinding(): {
192
- clientPackage: string;
193
- variables: {
194
- queueUrl: {
195
- environment: string;
196
- parameter: string;
197
- };
198
- };
199
- permissions: {
200
- "sqs:*": string[];
201
- };
202
- };
192
+ getFunctionBinding(): FunctionBindingProps;
203
193
  private createQueue;
204
194
  }
@@ -161,8 +161,8 @@ export class Queue extends Construct {
161
161
  clientPackage: "queue",
162
162
  variables: {
163
163
  queueUrl: {
164
- environment: this.queueUrl,
165
- parameter: this.queueUrl,
164
+ type: "plain",
165
+ value: this.queueUrl,
166
166
  },
167
167
  },
168
168
  permissions: {