sst 2.26.2 → 2.26.4

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 (46) hide show
  1. package/cli/commands/types.js +3 -7
  2. package/constructs/Api.js +2 -0
  3. package/constructs/ApiGatewayV1Api.js +2 -0
  4. package/constructs/App.d.ts +3 -1
  5. package/constructs/App.js +63 -62
  6. package/constructs/AppSyncApi.js +2 -0
  7. package/constructs/AstroSite.d.ts +50 -11
  8. package/constructs/AstroSite.js +69 -51
  9. package/constructs/Auth.js +2 -0
  10. package/constructs/Bucket.js +2 -0
  11. package/constructs/Cognito.js +2 -0
  12. package/constructs/Cron.js +2 -0
  13. package/constructs/EdgeFunction.d.ts +3 -4
  14. package/constructs/EdgeFunction.js +13 -9
  15. package/constructs/EventBus.js +2 -0
  16. package/constructs/Function.d.ts +5 -1
  17. package/constructs/Function.js +8 -6
  18. package/constructs/Job.js +3 -3
  19. package/constructs/KinesisStream.js +2 -0
  20. package/constructs/NextjsSite.d.ts +84 -22
  21. package/constructs/NextjsSite.js +150 -254
  22. package/constructs/Parameter.js +2 -0
  23. package/constructs/Queue.js +2 -0
  24. package/constructs/RDS.js +5 -4
  25. package/constructs/RemixSite.d.ts +65 -11
  26. package/constructs/RemixSite.js +112 -71
  27. package/constructs/Script.js +2 -0
  28. package/constructs/Secret.js +2 -0
  29. package/constructs/Service.js +4 -3
  30. package/constructs/SolidStartSite.d.ts +48 -9
  31. package/constructs/SolidStartSite.js +68 -40
  32. package/constructs/SsrFunction.d.ts +4 -5
  33. package/constructs/SsrFunction.js +18 -13
  34. package/constructs/SsrSite.d.ts +74 -68
  35. package/constructs/SsrSite.js +657 -682
  36. package/constructs/StaticSite.js +2 -0
  37. package/constructs/SvelteKitSite.d.ts +80 -12
  38. package/constructs/SvelteKitSite.js +90 -64
  39. package/constructs/Table.js +2 -0
  40. package/constructs/Topic.js +2 -0
  41. package/constructs/WebSocketApi.js +2 -0
  42. package/constructs/deprecated/NextjsSite.js +1 -0
  43. package/constructs/future/Auth.js +1 -0
  44. package/package.json +1 -1
  45. package/support/remix-site-function/edge-server.js +2 -4
  46. package/support/remix-site-function/regional-server.js +2 -4
@@ -1,10 +1,8 @@
1
1
  import { Construct } from "constructs";
2
- import { FunctionProps } from "aws-cdk-lib/aws-lambda";
3
- import { Distribution } from "./Distribution.js";
4
- import { SsrFunction } from "./SsrFunction.js";
5
- import { EdgeFunction } from "./EdgeFunction.js";
2
+ import { Runtime, FunctionProps, Architecture } from "aws-cdk-lib/aws-lambda";
6
3
  import { SsrSite, SsrSiteProps } from "./SsrSite.js";
7
4
  import { Size } from "./util/size.js";
5
+ import { Bucket } from "aws-cdk-lib/aws-s3";
8
6
  export interface NextjsSiteProps extends Omit<SsrSiteProps, "nodejs"> {
9
7
  imageOptimization?: {
10
8
  /**
@@ -69,25 +67,89 @@ export declare class NextjsSite extends SsrSite {
69
67
  waitForInvalidation: Exclude<NextjsSiteProps["waitForInvalidation"], undefined>;
70
68
  };
71
69
  constructor(scope: Construct, id: string, props?: NextjsSiteProps);
72
- protected createRevalidation(): void;
73
- protected initBuildConfig(): {
74
- typesPath: string;
75
- serverBuildOutputFile: string;
76
- clientBuildOutputDir: string;
77
- clientBuildVersionedSubDir: string;
78
- clientBuildS3KeyPrefix: string;
79
- prerenderedBuildOutputDir: string;
80
- prerenderedBuildS3KeyPrefix: string;
81
- warmerFunctionAssetPath: string;
70
+ protected plan(bucket: Bucket): {
71
+ cloudFrontFunctions?: {
72
+ serverCfFunction: {
73
+ constructId: string;
74
+ injections: string[];
75
+ };
76
+ } | undefined;
77
+ edgeFunctions?: {
78
+ edgeServer: {
79
+ constructId: string;
80
+ function: {
81
+ description: string;
82
+ bundle: string;
83
+ handler: string;
84
+ environment: {
85
+ CACHE_BUCKET_NAME: string;
86
+ CACHE_BUCKET_KEY_PREFIX: string;
87
+ CACHE_BUCKET_REGION: string;
88
+ };
89
+ };
90
+ };
91
+ } | undefined;
92
+ origins: {
93
+ imageOptimizer: {
94
+ type: "image-optimization-function";
95
+ constructId: string;
96
+ function: {
97
+ description: string;
98
+ handler: string;
99
+ code: import("aws-cdk-lib/aws-lambda").AssetCode;
100
+ runtime: Runtime;
101
+ architecture: Architecture;
102
+ environment: {
103
+ BUCKET_NAME: string;
104
+ BUCKET_KEY_PREFIX: string;
105
+ };
106
+ memorySize: number;
107
+ };
108
+ };
109
+ s3: {
110
+ type: "s3";
111
+ originPath: string;
112
+ copy: ({
113
+ from: string;
114
+ to: string;
115
+ cached: true;
116
+ versionedSubDir: string;
117
+ } | {
118
+ from: string;
119
+ to: string;
120
+ cached: false;
121
+ versionedSubDir?: undefined;
122
+ })[];
123
+ };
124
+ regionalServer?: {
125
+ type: "function";
126
+ constructId: string;
127
+ function: {
128
+ description: string;
129
+ bundle: string;
130
+ handler: string;
131
+ environment: {
132
+ CACHE_BUCKET_NAME: string;
133
+ CACHE_BUCKET_KEY_PREFIX: string;
134
+ CACHE_BUCKET_REGION: string;
135
+ };
136
+ };
137
+ } | undefined;
138
+ };
139
+ behaviors: {
140
+ cacheType: "server" | "static";
141
+ pattern?: string | undefined;
142
+ origin: "s3" | "regionalServer" | "imageOptimizer";
143
+ cfFunction?: "serverCfFunction" | undefined;
144
+ edgeFunction?: "edgeServer" | undefined;
145
+ }[];
146
+ cachePolicyAllowedHeaders?: string[] | undefined;
147
+ buildId?: string | undefined;
148
+ warmerConfig?: {
149
+ function: string;
150
+ } | undefined;
82
151
  };
83
- protected createFunctionForRegional(): SsrFunction;
84
- protected createFunctionForEdge(): EdgeFunction;
85
- private createImageOptimizationFunction;
86
- protected createCloudFrontDistributionForRegional(): Distribution;
87
- protected createCloudFrontDistributionForEdge(): Distribution;
88
- protected useServerBehaviorCachePolicy(): import("aws-cdk-lib/aws-cloudfront").CachePolicy;
89
- private buildImageBehavior;
90
- protected generateBuildId(): string;
152
+ protected createRevalidation(): void;
91
153
  getConstructMetadata(): {
92
154
  data: {
93
155
  mode: "placeholder" | "deployed";
@@ -1,17 +1,10 @@
1
1
  import fs from "fs";
2
2
  import path from "path";
3
- import { Fn, Duration as CdkDuration, RemovalPolicy } from "aws-cdk-lib/core";
4
- import { PolicyStatement } from "aws-cdk-lib/aws-iam";
5
- import { RetentionDays } from "aws-cdk-lib/aws-logs";
6
- import { Code, Runtime, Architecture, Function as CdkFunction, FunctionUrlAuthType, } from "aws-cdk-lib/aws-lambda";
7
- import { ViewerProtocolPolicy, AllowedMethods, CachedMethods, LambdaEdgeEventType, } from "aws-cdk-lib/aws-cloudfront";
8
- import { HttpOrigin } from "aws-cdk-lib/aws-cloudfront-origins";
3
+ import { Duration as CdkDuration } from "aws-cdk-lib/core";
4
+ import { Code, Runtime, Function as CdkFunction, Architecture, } from "aws-cdk-lib/aws-lambda";
9
5
  import { Queue } from "aws-cdk-lib/aws-sqs";
10
6
  import { SqsEventSource } from "aws-cdk-lib/aws-lambda-event-sources";
11
7
  import { Stack } from "./Stack.js";
12
- import { Distribution } from "./Distribution.js";
13
- import { SsrFunction } from "./SsrFunction.js";
14
- import { EdgeFunction } from "./EdgeFunction.js";
15
8
  import { SsrSite } from "./SsrSite.js";
16
9
  import { toCdkSize } from "./util/size.js";
17
10
  /**
@@ -31,12 +24,156 @@ export class NextjsSite extends SsrSite {
31
24
  buildCommand: "npx --yes open-next@2.1.5 build",
32
25
  ...props,
33
26
  });
34
- this.deferredTaskCallbacks.push(() => {
35
- this.createRevalidation();
27
+ this.createRevalidation();
28
+ }
29
+ plan(bucket) {
30
+ const { path: sitePath, edge, imageOptimization } = this.props;
31
+ const serverConfig = {
32
+ description: "Next.js server",
33
+ bundle: path.join(sitePath, ".open-next", "server-function"),
34
+ handler: "index.handler",
35
+ environment: {
36
+ CACHE_BUCKET_NAME: bucket.bucketName,
37
+ CACHE_BUCKET_KEY_PREFIX: "_cache",
38
+ CACHE_BUCKET_REGION: Stack.of(this).region,
39
+ },
40
+ };
41
+ return this.validatePlan({
42
+ cloudFrontFunctions: {
43
+ serverCfFunction: {
44
+ constructId: "CloudFrontFunction",
45
+ injections: [this.useCloudFrontFunctionHostHeaderInjection()],
46
+ },
47
+ },
48
+ edgeFunctions: edge
49
+ ? {
50
+ edgeServer: {
51
+ constructId: "ServerFunction",
52
+ function: serverConfig,
53
+ },
54
+ }
55
+ : undefined,
56
+ origins: {
57
+ ...(edge
58
+ ? {}
59
+ : {
60
+ regionalServer: {
61
+ type: "function",
62
+ constructId: "ServerFunction",
63
+ function: serverConfig,
64
+ },
65
+ }),
66
+ imageOptimizer: {
67
+ type: "image-optimization-function",
68
+ constructId: "ImageFunction",
69
+ function: {
70
+ description: "Next.js image optimizer",
71
+ handler: "index.handler",
72
+ code: Code.fromAsset(path.join(sitePath, ".open-next/image-optimization-function")),
73
+ runtime: Runtime.NODEJS_18_X,
74
+ architecture: Architecture.ARM_64,
75
+ environment: {
76
+ BUCKET_NAME: bucket.bucketName,
77
+ BUCKET_KEY_PREFIX: "_assets",
78
+ },
79
+ memorySize: imageOptimization?.memorySize
80
+ ? typeof imageOptimization.memorySize === "string"
81
+ ? toCdkSize(imageOptimization.memorySize).toMebibytes()
82
+ : imageOptimization.memorySize
83
+ : 1536,
84
+ },
85
+ },
86
+ s3: {
87
+ type: "s3",
88
+ originPath: "_assets",
89
+ copy: [
90
+ {
91
+ from: ".open-next/assets",
92
+ to: "_assets",
93
+ cached: true,
94
+ versionedSubDir: "_next",
95
+ },
96
+ { from: ".open-next/cache", to: "_cache", cached: false },
97
+ ],
98
+ },
99
+ },
100
+ behaviors: [
101
+ ...(edge
102
+ ? [
103
+ {
104
+ cacheType: "server",
105
+ cfFunction: "serverCfFunction",
106
+ edgeFunction: "edgeServer",
107
+ origin: "s3",
108
+ },
109
+ {
110
+ cacheType: "server",
111
+ pattern: "api/*",
112
+ cfFunction: "serverCfFunction",
113
+ edgeFunction: "edgeServer",
114
+ origin: "s3",
115
+ },
116
+ {
117
+ cacheType: "server",
118
+ pattern: "_next/data/*",
119
+ cfFunction: "serverCfFunction",
120
+ edgeFunction: "edgeServer",
121
+ origin: "s3",
122
+ },
123
+ ]
124
+ : [
125
+ {
126
+ cacheType: "server",
127
+ cfFunction: "serverCfFunction",
128
+ origin: "regionalServer",
129
+ },
130
+ {
131
+ cacheType: "server",
132
+ pattern: "api/*",
133
+ cfFunction: "serverCfFunction",
134
+ origin: "regionalServer",
135
+ },
136
+ {
137
+ cacheType: "server",
138
+ pattern: "_next/data/*",
139
+ cfFunction: "serverCfFunction",
140
+ origin: "regionalServer",
141
+ },
142
+ ]),
143
+ {
144
+ cacheType: "server",
145
+ pattern: "_next/image*",
146
+ cfFunction: "serverCfFunction",
147
+ origin: "imageOptimizer",
148
+ },
149
+ // create 1 behaviour for each top level asset file/folder
150
+ ...fs.readdirSync(path.join(sitePath, ".open-next/assets")).map((item) => ({
151
+ cacheType: "static",
152
+ pattern: fs
153
+ .statSync(path.join(sitePath, ".open-next/assets", item))
154
+ .isDirectory()
155
+ ? `${item}/*`
156
+ : item,
157
+ origin: "s3",
158
+ })),
159
+ ],
160
+ cachePolicyAllowedHeaders: [
161
+ "accept",
162
+ "rsc",
163
+ "next-router-prefetch",
164
+ "next-router-state-tree",
165
+ "next-url",
166
+ ],
167
+ buildId: fs
168
+ .readFileSync(path.join(sitePath, ".next/BUILD_ID"))
169
+ .toString(),
170
+ warmerConfig: {
171
+ function: path.join(sitePath, ".open-next", "warmer-function"),
172
+ },
36
173
  });
37
174
  }
38
175
  createRevalidation() {
39
- if (!this.serverLambdaForRegional && !this.serverLambdaForEdge)
176
+ if (!this.serverFunction)
40
177
  return;
41
178
  const { cdk } = this.props;
42
179
  const queue = new Queue(this, "RevalidationQueue", {
@@ -53,252 +190,11 @@ export class NextjsSite extends SsrSite {
53
190
  });
54
191
  consumer.addEventSource(new SqsEventSource(queue, { batchSize: 5 }));
55
192
  // Allow server to send messages to the queue
56
- const server = this.serverLambdaForRegional || this.serverLambdaForEdge;
193
+ const server = this.serverFunction;
57
194
  server?.addEnvironment("REVALIDATION_QUEUE_URL", queue.queueUrl);
58
195
  server?.addEnvironment("REVALIDATION_QUEUE_REGION", Stack.of(this).region);
59
196
  queue.grantSendMessages(server?.role);
60
197
  }
61
- initBuildConfig() {
62
- return {
63
- typesPath: ".",
64
- serverBuildOutputFile: ".open-next/server-function/index.mjs",
65
- clientBuildOutputDir: ".open-next/assets",
66
- clientBuildVersionedSubDir: "_next",
67
- clientBuildS3KeyPrefix: "_assets",
68
- prerenderedBuildOutputDir: ".open-next/cache",
69
- prerenderedBuildS3KeyPrefix: "_cache",
70
- warmerFunctionAssetPath: path.join(this.props.path, ".open-next/warmer-function"),
71
- };
72
- }
73
- createFunctionForRegional() {
74
- const { runtime, timeout, memorySize, bind, permissions, environment, cdk, } = this.props;
75
- return new SsrFunction(this, `ServerFunction`, {
76
- description: "Next.js server",
77
- bundle: path.join(this.props.path, ".open-next", "server-function"),
78
- handler: "index.handler",
79
- runtime,
80
- timeout,
81
- memorySize,
82
- bind,
83
- permissions,
84
- environment: {
85
- ...environment,
86
- CACHE_BUCKET_NAME: this.bucket.bucketName,
87
- CACHE_BUCKET_KEY_PREFIX: "_cache",
88
- CACHE_BUCKET_REGION: Stack.of(this).region,
89
- },
90
- ...cdk?.server,
91
- });
92
- }
93
- createFunctionForEdge() {
94
- const { runtime, timeout, memorySize, bind, permissions, environment } = this.props;
95
- return new EdgeFunction(this, "ServerFunction", {
96
- bundle: path.join(this.props.path, ".open-next", "server-function"),
97
- handler: "index.handler",
98
- runtime,
99
- timeout,
100
- memorySize,
101
- bind,
102
- permissions,
103
- environment: {
104
- ...environment,
105
- CACHE_BUCKET_NAME: this.bucket.bucketName,
106
- CACHE_BUCKET_KEY_PREFIX: "_cache",
107
- CACHE_BUCKET_REGION: Stack.of(this).region,
108
- },
109
- });
110
- }
111
- createImageOptimizationFunction() {
112
- const { imageOptimization, path: sitePath } = this.props;
113
- const fn = new CdkFunction(this, `ImageFunction`, {
114
- description: "Next.js image optimizer",
115
- handler: "index.handler",
116
- currentVersionOptions: {
117
- removalPolicy: RemovalPolicy.DESTROY,
118
- },
119
- logRetention: RetentionDays.THREE_DAYS,
120
- code: Code.fromInline("export function handler() {}"),
121
- runtime: Runtime.NODEJS_18_X,
122
- memorySize: imageOptimization?.memorySize
123
- ? typeof imageOptimization.memorySize === "string"
124
- ? toCdkSize(imageOptimization.memorySize).toMebibytes()
125
- : imageOptimization.memorySize
126
- : 1536,
127
- timeout: CdkDuration.seconds(25),
128
- architecture: Architecture.ARM_64,
129
- environment: {
130
- BUCKET_NAME: this.bucket.bucketName,
131
- BUCKET_KEY_PREFIX: "_assets",
132
- },
133
- initialPolicy: [
134
- new PolicyStatement({
135
- actions: ["s3:GetObject"],
136
- resources: [this.bucket.arnForObjects("*")],
137
- }),
138
- ],
139
- });
140
- // update code after build
141
- this.deferredTaskCallbacks.push(() => {
142
- const cfnFunction = fn.node.defaultChild;
143
- const code = Code.fromAsset(path.join(sitePath, ".open-next/image-optimization-function"));
144
- const codeConfig = code.bind(fn);
145
- cfnFunction.code = {
146
- s3Bucket: codeConfig.s3Location?.bucketName,
147
- s3Key: codeConfig.s3Location?.objectKey,
148
- s3ObjectVersion: codeConfig.s3Location?.objectVersion,
149
- };
150
- code.bindToResource(cfnFunction);
151
- });
152
- return fn;
153
- }
154
- createCloudFrontDistributionForRegional() {
155
- /**
156
- * Next.js requests
157
- *
158
- * - Public asset
159
- * Use case: When you request an asset in /public
160
- * Request: /myImage.png
161
- * Response cache:
162
- * - Cache-Control: public, max-age=0, must-revalidate
163
- * - x-vercel-cache: MISS (1st request)
164
- * - x-vercel-cache: HIT (2nd request)
165
- *
166
- * - SSG page
167
- * Use case: When you request an SSG page directly
168
- * Request: /myPage
169
- * Response cache:
170
- * - Cache-Control: public, max-age=0, must-revalidate
171
- * - Content-Encoding: br
172
- * - x-vercel-cache: HIT (2nd request, not set for 1st request)
173
- *
174
- * - SSR page (directly)
175
- * Use case: When you request an SSR page directly
176
- * Request: /myPage
177
- * Response cache:
178
- * - Cache-Control: private, no-cache, no-store, max-age=0, must-revalidate
179
- * - x-vercel-cache: MISS
180
- *
181
- * - SSR pages (user transition)
182
- * Use case: When the page uses getServerSideProps(), and you request this page on
183
- * client-side page trasitions. Next.js sends an API request to the server,
184
- * which runs getServerSideProps()
185
- * Request: /_next/data/_-fpIB1rqWyRD-EJO59pO/myPage.json
186
- * Response cache:
187
- * - Cache-Control: private, no-cache, no-store, max-age=0, must-revalidate
188
- * - x-vercel-cache: MISS
189
- *
190
- * - Image optimization
191
- * Use case: when you request an image
192
- * Request: /_next/image?url=%2F_next%2Fstatic%2Fmedia%2F4600x4600.ce39e3d6.jpg&w=256&q=75
193
- * Response cache:
194
- * - Cache-Control: public, max-age=31536000, immutable
195
- * - x-vercel-cache: HIT
196
- *
197
- * - API
198
- * Use case: when you request an API endpoint
199
- * Request: /api/hello
200
- * Response cache:
201
- * - Cache-Control: public, max-age=0, must-revalidate
202
- * - x-vercel-cache: MISS
203
- */
204
- const { customDomain, cdk } = this.props;
205
- const cfDistributionProps = cdk?.distribution || {};
206
- const serverBehavior = this.buildDefaultBehaviorForRegional();
207
- return new Distribution(this, "CDN", {
208
- scopeOverride: this,
209
- customDomain,
210
- cdk: {
211
- distribution: {
212
- // these values can be overwritten by cfDistributionProps
213
- defaultRootObject: "",
214
- // Override props.
215
- ...cfDistributionProps,
216
- // these values can NOT be overwritten by cfDistributionProps
217
- defaultBehavior: serverBehavior,
218
- additionalBehaviors: {
219
- "api/*": serverBehavior,
220
- "_next/data/*": serverBehavior,
221
- "_next/image*": this.buildImageBehavior(),
222
- ...(cfDistributionProps.additionalBehaviors || {}),
223
- },
224
- },
225
- },
226
- });
227
- }
228
- createCloudFrontDistributionForEdge() {
229
- const { customDomain, cdk } = this.props;
230
- const cfDistributionProps = cdk?.distribution || {};
231
- const serverBehavior = this.buildDefaultBehaviorForEdge();
232
- return new Distribution(this, "CDN", {
233
- scopeOverride: this,
234
- customDomain,
235
- cdk: {
236
- distribution: {
237
- // these values can be overwritten by cfDistributionProps
238
- defaultRootObject: "",
239
- // Override props.
240
- ...cfDistributionProps,
241
- // these values can NOT be overwritten by cfDistributionProps
242
- defaultBehavior: serverBehavior,
243
- additionalBehaviors: {
244
- "api/*": serverBehavior,
245
- "_next/data/*": serverBehavior,
246
- "_next/image*": this.buildImageBehavior(),
247
- ...(cfDistributionProps.additionalBehaviors || {}),
248
- },
249
- },
250
- },
251
- });
252
- }
253
- useServerBehaviorCachePolicy() {
254
- return super.useServerBehaviorCachePolicy([
255
- "accept",
256
- "rsc",
257
- "next-router-prefetch",
258
- "next-router-state-tree",
259
- "next-url",
260
- ]);
261
- }
262
- buildImageBehavior() {
263
- const { cdk, regional } = this.props;
264
- const imageFn = this.createImageOptimizationFunction();
265
- const imageFnUrl = imageFn.addFunctionUrl({
266
- authType: regional?.enableServerUrlIamAuth
267
- ? FunctionUrlAuthType.AWS_IAM
268
- : FunctionUrlAuthType.NONE,
269
- });
270
- return {
271
- viewerProtocolPolicy: ViewerProtocolPolicy.REDIRECT_TO_HTTPS,
272
- origin: new HttpOrigin(Fn.parseDomainName(imageFnUrl.url)),
273
- allowedMethods: AllowedMethods.ALLOW_ALL,
274
- cachedMethods: CachedMethods.CACHE_GET_HEAD_OPTIONS,
275
- compress: true,
276
- cachePolicy: cdk?.serverCachePolicy ?? this.useServerBehaviorCachePolicy(),
277
- responseHeadersPolicy: cdk?.responseHeadersPolicy,
278
- edgeLambdas: regional?.enableServerUrlIamAuth
279
- ? [
280
- (() => {
281
- const fn = this.useServerUrlSigningFunction();
282
- fn.attachPermissions([
283
- new PolicyStatement({
284
- actions: ["lambda:InvokeFunctionUrl"],
285
- resources: [imageFn.functionArn],
286
- }),
287
- ]);
288
- return {
289
- includeBody: true,
290
- eventType: LambdaEdgeEventType.ORIGIN_REQUEST,
291
- functionVersion: fn.currentVersion,
292
- };
293
- })(),
294
- ]
295
- : [],
296
- };
297
- }
298
- generateBuildId() {
299
- const filePath = path.join(this.props.path, ".next/BUILD_ID");
300
- return fs.readFileSync(filePath).toString();
301
- }
302
198
  getConstructMetadata() {
303
199
  return {
304
200
  type: "NextjsSite",
@@ -20,6 +20,8 @@ export class Parameter extends Construct {
20
20
  this.id = id;
21
21
  this.name = id;
22
22
  this.value = props.value;
23
+ const app = this.node.root;
24
+ app.registerTypes(this);
23
25
  }
24
26
  /** @internal */
25
27
  getConstructMetadata() {
@@ -39,6 +39,8 @@ export class Queue extends Construct {
39
39
  if (props?.consumer) {
40
40
  this.addConsumer(this, props.consumer);
41
41
  }
42
+ const app = this.node.root;
43
+ app.registerTypes(this);
42
44
  }
43
45
  /**
44
46
  * The ARN of the SQS Queue
package/constructs/RDS.js CHANGED
@@ -63,6 +63,8 @@ export class RDS extends Construct {
63
63
  this.createMigrationsFunction(migrations);
64
64
  this.createMigrationCustomResource(migrations);
65
65
  }
66
+ const app = this.node.root;
67
+ app.registerTypes(this);
66
68
  }
67
69
  /**
68
70
  * The ARN of the internally created RDS Serverless Cluster.
@@ -275,7 +277,7 @@ export class RDS extends Construct {
275
277
  // - when invoked from `sst build`, __dirname is `resources/dist`
276
278
  // - when running resources tests, __dirname is `resources/src`
277
279
  // For now we will do `__dirname/../dist` to make both cases work.
278
- const fn = new Fn(this, "MigrationFunction", {
280
+ this.migratorFunction = new Fn(this, "MigrationFunction", {
279
281
  handler: path.resolve(path.join(__dirname, "../support/rds-migrator/index.handler")),
280
282
  runtime: "nodejs16.x",
281
283
  timeout: 900,
@@ -289,6 +291,7 @@ export class RDS extends Construct {
289
291
  // can locate the migration files
290
292
  RDS_MIGRATIONS_PATH: app.mode === "dev" ? migrations : migrationsDestination,
291
293
  },
294
+ permissions: [this.cdk.cluster],
292
295
  // Note that we need to generate a relative path of the migrations off the
293
296
  // srcPath because sst.Function internally builds the copy "from" path by
294
297
  // joining the srcPath and the from path.
@@ -302,10 +305,8 @@ export class RDS extends Construct {
302
305
  install: ["kysely", "kysely-data-api"],
303
306
  format: "esm",
304
307
  },
308
+ _doNotAllowOthersToBind: true,
305
309
  });
306
- fn._doNotAllowOthersToBind = true;
307
- fn.attachPermissions([this.cdk.cluster]);
308
- this.migratorFunction = fn;
309
310
  }
310
311
  createMigrationCustomResource(migrations) {
311
312
  const app = this.node.root;