sst 2.30.2 → 2.30.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.
- package/constructs/BaseSite.d.ts +5 -3
- package/constructs/NextjsSite.d.ts +144 -18
- package/constructs/NextjsSite.js +115 -27
- package/constructs/SsrSite.d.ts +5 -1
- package/constructs/StaticSite.d.ts +4 -1
- package/credentials.d.ts +1 -0
- package/package.json +32 -31
- package/stacks/synth.js +2 -3
- package/support/bootstrap-metadata-function/index.mjs +16628 -12477
- package/support/bridge/bridge.mjs +65 -44
- package/support/custom-resources/index.mjs +38987 -67260
- package/support/event-bus-retrier/index.mjs +22 -45
- package/support/job-manager/index.mjs +25961 -40983
- package/support/rds-migrator/index.mjs +17 -17
- package/support/script-function/index.mjs +5567 -3134
- package/support/ssr-warmer/index.mjs +7300 -5225
package/constructs/BaseSite.d.ts
CHANGED
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
import { ErrorResponse, DistributionProps, BehaviorOptions, IOrigin } from "aws-cdk-lib/aws-cloudfront";
|
|
2
|
+
export interface BaseSiteFileOptionsFilter {
|
|
3
|
+
include?: string;
|
|
4
|
+
exclude?: string;
|
|
5
|
+
}
|
|
2
6
|
export interface BaseSiteFileOptions {
|
|
3
|
-
filters:
|
|
4
|
-
[key in "include" | "exclude"]?: string;
|
|
5
|
-
}[];
|
|
7
|
+
filters: BaseSiteFileOptionsFilter[];
|
|
6
8
|
cacheControl?: string;
|
|
7
9
|
contentType?: string;
|
|
8
10
|
contentEncoding?: string;
|
|
@@ -1,8 +1,11 @@
|
|
|
1
1
|
import { Construct } from "constructs";
|
|
2
|
+
import { Duration as CdkDuration } from "aws-cdk-lib/core";
|
|
2
3
|
import { Runtime, FunctionProps, Architecture } from "aws-cdk-lib/aws-lambda";
|
|
3
4
|
import { SsrSite, SsrSiteNormalizedProps, SsrSiteProps } from "./SsrSite.js";
|
|
4
5
|
import { Size } from "./util/size.js";
|
|
5
6
|
import { Bucket } from "aws-cdk-lib/aws-s3";
|
|
7
|
+
import { PolicyStatement } from "aws-cdk-lib/aws-iam";
|
|
8
|
+
import { RetentionDays } from "aws-cdk-lib/aws-logs";
|
|
6
9
|
import { CachePolicyProps } from "aws-cdk-lib/aws-cloudfront";
|
|
7
10
|
export interface NextjsSiteProps extends Omit<SsrSiteProps, "nodejs"> {
|
|
8
11
|
/**
|
|
@@ -14,6 +17,17 @@ export interface NextjsSiteProps extends Omit<SsrSiteProps, "nodejs"> {
|
|
|
14
17
|
* ```
|
|
15
18
|
*/
|
|
16
19
|
openNextVersion?: string;
|
|
20
|
+
/**
|
|
21
|
+
* How the logs are stored in CloudWatch
|
|
22
|
+
* - "combined" - Logs from all routes are stored in the same log group.
|
|
23
|
+
* - "per-route" - Logs from each route are stored in a separate log group.
|
|
24
|
+
* @default "combined"
|
|
25
|
+
* @example
|
|
26
|
+
* ```js
|
|
27
|
+
* logging: "per-route",
|
|
28
|
+
* ```
|
|
29
|
+
*/
|
|
30
|
+
_logging?: "combined" | "per-route";
|
|
17
31
|
imageOptimization?: {
|
|
18
32
|
/**
|
|
19
33
|
* The amount of memory in MB allocated for image optimization function.
|
|
@@ -109,6 +123,7 @@ type NextjsSiteNormalizedProps = NextjsSiteProps & SsrSiteNormalizedProps;
|
|
|
109
123
|
*/
|
|
110
124
|
export declare class NextjsSite extends SsrSite {
|
|
111
125
|
props: NextjsSiteNormalizedProps;
|
|
126
|
+
private routes?;
|
|
112
127
|
constructor(scope: Construct, id: string, props?: NextjsSiteProps);
|
|
113
128
|
static buildDefaultServerCachePolicyProps(): CachePolicyProps;
|
|
114
129
|
protected plan(bucket: Bucket): {
|
|
@@ -122,14 +137,64 @@ export declare class NextjsSite extends SsrSite {
|
|
|
122
137
|
edgeServer: {
|
|
123
138
|
constructId: string;
|
|
124
139
|
function: {
|
|
125
|
-
|
|
126
|
-
bundle: string;
|
|
140
|
+
layers: import("aws-cdk-lib/aws-lambda").ILayerVersion[] | undefined;
|
|
127
141
|
handler: string;
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
142
|
+
bundle?: string | undefined;
|
|
143
|
+
runtime?: "nodejs14.x" | "nodejs16.x" | "nodejs18.x" | undefined;
|
|
144
|
+
timeout?: number | `${number} second` | `${number} seconds` | `${number} minute` | `${number} minutes` | `${number} hour` | `${number} hours` | `${number} day` | `${number} days` | undefined;
|
|
145
|
+
memorySize?: number | `${number} MB` | `${number} GB` | undefined;
|
|
146
|
+
permissions?: import("./index.js").Permissions | undefined;
|
|
147
|
+
environment?: Record<string, string> | undefined;
|
|
148
|
+
bind?: import("./Construct.js").SSTConstruct[] | undefined;
|
|
149
|
+
nodejs?: import("./Function.js").NodeJSProps | undefined;
|
|
150
|
+
copyFiles?: import("./Function.js").FunctionCopyFilesProps[] | undefined;
|
|
151
|
+
logRetention?: RetentionDays | undefined;
|
|
152
|
+
functionName?: string | undefined;
|
|
153
|
+
tracing?: import("aws-cdk-lib/aws-lambda").Tracing | undefined;
|
|
154
|
+
architecture?: Architecture | undefined;
|
|
155
|
+
description?: string | undefined;
|
|
156
|
+
ephemeralStorageSize?: import("aws-cdk-lib/core").Size | undefined;
|
|
157
|
+
initialPolicy?: PolicyStatement[] | undefined;
|
|
158
|
+
role?: import("aws-cdk-lib/aws-iam").IRole | undefined;
|
|
159
|
+
vpc?: import("aws-cdk-lib/aws-ec2").IVpc | undefined;
|
|
160
|
+
vpcSubnets?: import("aws-cdk-lib/aws-ec2").SubnetSelection | undefined;
|
|
161
|
+
securityGroups?: import("aws-cdk-lib/aws-ec2").ISecurityGroup[] | undefined;
|
|
162
|
+
allowAllOutbound?: boolean | undefined;
|
|
163
|
+
deadLetterQueueEnabled?: boolean | undefined;
|
|
164
|
+
deadLetterQueue?: import("aws-cdk-lib/aws-sqs").IQueue | undefined;
|
|
165
|
+
deadLetterTopic?: import("aws-cdk-lib/aws-sns").ITopic | undefined;
|
|
166
|
+
snapStart?: import("aws-cdk-lib/aws-lambda").SnapStartConf | undefined;
|
|
167
|
+
profiling?: boolean | undefined;
|
|
168
|
+
profilingGroup?: import("aws-cdk-lib/aws-codeguruprofiler").IProfilingGroup | undefined;
|
|
169
|
+
insightsVersion?: import("aws-cdk-lib/aws-lambda").LambdaInsightsVersion | undefined;
|
|
170
|
+
adotInstrumentation?: import("aws-cdk-lib/aws-lambda").AdotInstrumentationConfig | undefined;
|
|
171
|
+
paramsAndSecrets?: import("aws-cdk-lib/aws-lambda").ParamsAndSecretsLayerVersion | undefined;
|
|
172
|
+
reservedConcurrentExecutions?: number | undefined;
|
|
173
|
+
events?: import("aws-cdk-lib/aws-lambda").IEventSource[] | undefined;
|
|
174
|
+
logRetentionRole?: import("aws-cdk-lib/aws-iam").IRole | undefined;
|
|
175
|
+
logRetentionRetryOptions?: import("aws-cdk-lib/aws-lambda").LogRetentionRetryOptions | undefined;
|
|
176
|
+
currentVersionOptions?: import("aws-cdk-lib/aws-lambda").VersionOptions | undefined;
|
|
177
|
+
filesystem?: import("aws-cdk-lib/aws-lambda").FileSystem | undefined;
|
|
178
|
+
allowPublicSubnet?: boolean | undefined;
|
|
179
|
+
environmentEncryption?: import("aws-cdk-lib/aws-kms").IKey | undefined;
|
|
180
|
+
codeSigningConfig?: import("aws-cdk-lib/aws-lambda").ICodeSigningConfig | undefined;
|
|
181
|
+
runtimeManagementMode?: import("aws-cdk-lib/aws-lambda").RuntimeManagementMode | undefined;
|
|
182
|
+
onFailure?: import("aws-cdk-lib/aws-lambda").IDestination | undefined;
|
|
183
|
+
onSuccess?: import("aws-cdk-lib/aws-lambda").IDestination | undefined;
|
|
184
|
+
maxEventAge?: CdkDuration | undefined;
|
|
185
|
+
retryAttempts?: number | undefined;
|
|
186
|
+
} | {
|
|
187
|
+
layers: import("aws-cdk-lib/aws-lambda").ILayerVersion[] | undefined;
|
|
188
|
+
handler: string;
|
|
189
|
+
bundle?: string | undefined;
|
|
190
|
+
runtime?: "nodejs14.x" | "nodejs16.x" | "nodejs18.x" | undefined;
|
|
191
|
+
timeout?: number | `${number} second` | `${number} seconds` | `${number} minute` | `${number} minutes` | `${number} hour` | `${number} hours` | `${number} day` | `${number} days` | undefined;
|
|
192
|
+
memorySize?: number | `${number} MB` | `${number} GB` | undefined;
|
|
193
|
+
permissions?: import("./index.js").Permissions | undefined;
|
|
194
|
+
environment?: Record<string, string> | undefined;
|
|
195
|
+
bind?: import("./Construct.js").SSTConstruct[] | undefined;
|
|
196
|
+
nodejs?: import("./Function.js").NodeJSProps | undefined;
|
|
197
|
+
scopeOverride?: import("constructs").IConstruct | undefined;
|
|
133
198
|
};
|
|
134
199
|
};
|
|
135
200
|
} | undefined;
|
|
@@ -169,14 +234,64 @@ export declare class NextjsSite extends SsrSite {
|
|
|
169
234
|
type: "function";
|
|
170
235
|
constructId: string;
|
|
171
236
|
function: {
|
|
172
|
-
|
|
173
|
-
bundle: string;
|
|
237
|
+
layers: import("aws-cdk-lib/aws-lambda").ILayerVersion[] | undefined;
|
|
174
238
|
handler: string;
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
239
|
+
bundle?: string | undefined;
|
|
240
|
+
runtime?: "nodejs14.x" | "nodejs16.x" | "nodejs18.x" | undefined;
|
|
241
|
+
timeout?: number | `${number} second` | `${number} seconds` | `${number} minute` | `${number} minutes` | `${number} hour` | `${number} hours` | `${number} day` | `${number} days` | undefined;
|
|
242
|
+
memorySize?: number | `${number} MB` | `${number} GB` | undefined;
|
|
243
|
+
permissions?: import("./index.js").Permissions | undefined;
|
|
244
|
+
environment?: Record<string, string> | undefined;
|
|
245
|
+
bind?: import("./Construct.js").SSTConstruct[] | undefined;
|
|
246
|
+
nodejs?: import("./Function.js").NodeJSProps | undefined;
|
|
247
|
+
copyFiles?: import("./Function.js").FunctionCopyFilesProps[] | undefined;
|
|
248
|
+
logRetention?: RetentionDays | undefined;
|
|
249
|
+
functionName?: string | undefined;
|
|
250
|
+
tracing?: import("aws-cdk-lib/aws-lambda").Tracing | undefined;
|
|
251
|
+
architecture?: Architecture | undefined;
|
|
252
|
+
description?: string | undefined;
|
|
253
|
+
ephemeralStorageSize?: import("aws-cdk-lib/core").Size | undefined;
|
|
254
|
+
initialPolicy?: PolicyStatement[] | undefined;
|
|
255
|
+
role?: import("aws-cdk-lib/aws-iam").IRole | undefined;
|
|
256
|
+
vpc?: import("aws-cdk-lib/aws-ec2").IVpc | undefined;
|
|
257
|
+
vpcSubnets?: import("aws-cdk-lib/aws-ec2").SubnetSelection | undefined;
|
|
258
|
+
securityGroups?: import("aws-cdk-lib/aws-ec2").ISecurityGroup[] | undefined;
|
|
259
|
+
allowAllOutbound?: boolean | undefined;
|
|
260
|
+
deadLetterQueueEnabled?: boolean | undefined;
|
|
261
|
+
deadLetterQueue?: import("aws-cdk-lib/aws-sqs").IQueue | undefined;
|
|
262
|
+
deadLetterTopic?: import("aws-cdk-lib/aws-sns").ITopic | undefined;
|
|
263
|
+
snapStart?: import("aws-cdk-lib/aws-lambda").SnapStartConf | undefined;
|
|
264
|
+
profiling?: boolean | undefined;
|
|
265
|
+
profilingGroup?: import("aws-cdk-lib/aws-codeguruprofiler").IProfilingGroup | undefined;
|
|
266
|
+
insightsVersion?: import("aws-cdk-lib/aws-lambda").LambdaInsightsVersion | undefined;
|
|
267
|
+
adotInstrumentation?: import("aws-cdk-lib/aws-lambda").AdotInstrumentationConfig | undefined;
|
|
268
|
+
paramsAndSecrets?: import("aws-cdk-lib/aws-lambda").ParamsAndSecretsLayerVersion | undefined;
|
|
269
|
+
reservedConcurrentExecutions?: number | undefined;
|
|
270
|
+
events?: import("aws-cdk-lib/aws-lambda").IEventSource[] | undefined;
|
|
271
|
+
logRetentionRole?: import("aws-cdk-lib/aws-iam").IRole | undefined;
|
|
272
|
+
logRetentionRetryOptions?: import("aws-cdk-lib/aws-lambda").LogRetentionRetryOptions | undefined;
|
|
273
|
+
currentVersionOptions?: import("aws-cdk-lib/aws-lambda").VersionOptions | undefined;
|
|
274
|
+
filesystem?: import("aws-cdk-lib/aws-lambda").FileSystem | undefined;
|
|
275
|
+
allowPublicSubnet?: boolean | undefined;
|
|
276
|
+
environmentEncryption?: import("aws-cdk-lib/aws-kms").IKey | undefined;
|
|
277
|
+
codeSigningConfig?: import("aws-cdk-lib/aws-lambda").ICodeSigningConfig | undefined;
|
|
278
|
+
runtimeManagementMode?: import("aws-cdk-lib/aws-lambda").RuntimeManagementMode | undefined;
|
|
279
|
+
onFailure?: import("aws-cdk-lib/aws-lambda").IDestination | undefined;
|
|
280
|
+
onSuccess?: import("aws-cdk-lib/aws-lambda").IDestination | undefined;
|
|
281
|
+
maxEventAge?: CdkDuration | undefined;
|
|
282
|
+
retryAttempts?: number | undefined;
|
|
283
|
+
} | {
|
|
284
|
+
layers: import("aws-cdk-lib/aws-lambda").ILayerVersion[] | undefined;
|
|
285
|
+
handler: string;
|
|
286
|
+
bundle?: string | undefined;
|
|
287
|
+
runtime?: "nodejs14.x" | "nodejs16.x" | "nodejs18.x" | undefined;
|
|
288
|
+
timeout?: number | `${number} second` | `${number} seconds` | `${number} minute` | `${number} minutes` | `${number} hour` | `${number} hours` | `${number} day` | `${number} days` | undefined;
|
|
289
|
+
memorySize?: number | `${number} MB` | `${number} GB` | undefined;
|
|
290
|
+
permissions?: import("./index.js").Permissions | undefined;
|
|
291
|
+
environment?: Record<string, string> | undefined;
|
|
292
|
+
bind?: import("./Construct.js").SSTConstruct[] | undefined;
|
|
293
|
+
nodejs?: import("./Function.js").NodeJSProps | undefined;
|
|
294
|
+
scopeOverride?: import("constructs").IConstruct | undefined;
|
|
180
295
|
};
|
|
181
296
|
streaming: boolean | undefined;
|
|
182
297
|
} | undefined;
|
|
@@ -203,8 +318,12 @@ export declare class NextjsSite extends SsrSite {
|
|
|
203
318
|
type: "NextjsSite";
|
|
204
319
|
data: {
|
|
205
320
|
routes: {
|
|
206
|
-
|
|
207
|
-
|
|
321
|
+
logGroupPrefix: string;
|
|
322
|
+
data: {
|
|
323
|
+
route: string;
|
|
324
|
+
logGroupPath: string;
|
|
325
|
+
}[];
|
|
326
|
+
} | undefined;
|
|
208
327
|
mode: "placeholder" | "deployed";
|
|
209
328
|
path: string;
|
|
210
329
|
runtime: "nodejs14.x" | "nodejs16.x" | "nodejs18.x";
|
|
@@ -215,8 +334,15 @@ export declare class NextjsSite extends SsrSite {
|
|
|
215
334
|
secrets: string[];
|
|
216
335
|
};
|
|
217
336
|
};
|
|
218
|
-
private
|
|
219
|
-
private
|
|
337
|
+
private wrapServerFunction;
|
|
338
|
+
private useRoutes;
|
|
220
339
|
private getBuildId;
|
|
340
|
+
private isPerRouteLoggingEnabled;
|
|
341
|
+
private disableDefaultLogging;
|
|
342
|
+
private static buildCloudWatchRouteName;
|
|
343
|
+
private static buildCloudWatchRouteHash;
|
|
344
|
+
static _test: {
|
|
345
|
+
buildCloudWatchRouteName: typeof NextjsSite.buildCloudWatchRouteName;
|
|
346
|
+
};
|
|
221
347
|
}
|
|
222
348
|
export {};
|
package/constructs/NextjsSite.js
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import fs from "fs";
|
|
2
2
|
import path from "path";
|
|
3
|
+
import crypto from "crypto";
|
|
3
4
|
import { Duration as CdkDuration, RemovalPolicy, CustomResource, } from "aws-cdk-lib/core";
|
|
4
|
-
import { Code, Runtime, Function as CdkFunction, Architecture, } from "aws-cdk-lib/aws-lambda";
|
|
5
|
+
import { Code, Runtime, Function as CdkFunction, Architecture, LayerVersion, } from "aws-cdk-lib/aws-lambda";
|
|
5
6
|
import { AttributeType, Billing, TableV2 as Table, } from "aws-cdk-lib/aws-dynamodb";
|
|
6
7
|
import { Provider } from "aws-cdk-lib/custom-resources";
|
|
7
8
|
import { Queue } from "aws-cdk-lib/aws-sqs";
|
|
@@ -9,9 +10,10 @@ import { SqsEventSource } from "aws-cdk-lib/aws-lambda-event-sources";
|
|
|
9
10
|
import { Stack } from "./Stack.js";
|
|
10
11
|
import { SsrSite } from "./SsrSite.js";
|
|
11
12
|
import { toCdkSize } from "./util/size.js";
|
|
12
|
-
import { PolicyStatement } from "aws-cdk-lib/aws-iam";
|
|
13
|
+
import { Effect, Policy, PolicyStatement } from "aws-cdk-lib/aws-iam";
|
|
13
14
|
import { RetentionDays } from "aws-cdk-lib/aws-logs";
|
|
14
15
|
import { VisibleError } from "../error.js";
|
|
16
|
+
const LAYER_VERSION = "9";
|
|
15
17
|
const DEFAULT_OPEN_NEXT_VERSION = "2.2.4";
|
|
16
18
|
const DEFAULT_CACHE_POLICY_ALLOWED_HEADERS = [
|
|
17
19
|
"accept",
|
|
@@ -32,13 +34,11 @@ const DEFAULT_CACHE_POLICY_ALLOWED_HEADERS = [
|
|
|
32
34
|
* ```
|
|
33
35
|
*/
|
|
34
36
|
export class NextjsSite extends SsrSite {
|
|
37
|
+
routes;
|
|
35
38
|
constructor(scope, id, props) {
|
|
36
|
-
const
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
disableIncrementalCache: false,
|
|
40
|
-
...props?.experimental,
|
|
41
|
-
};
|
|
39
|
+
const streaming = props?.experimental?.streaming ?? false;
|
|
40
|
+
const disableDynamoDBCache = props?.experimental?.disableDynamoDBCache ?? false;
|
|
41
|
+
const disableIncrementalCache = props?.experimental?.disableIncrementalCache ?? false;
|
|
42
42
|
super(scope, id, {
|
|
43
43
|
buildCommand: [
|
|
44
44
|
"npx",
|
|
@@ -55,6 +55,9 @@ export class NextjsSite extends SsrSite {
|
|
|
55
55
|
].join(" "),
|
|
56
56
|
...props,
|
|
57
57
|
});
|
|
58
|
+
if (this.isPerRouteLoggingEnabled()) {
|
|
59
|
+
this.disableDefaultLogging();
|
|
60
|
+
}
|
|
58
61
|
if (!disableIncrementalCache) {
|
|
59
62
|
this.createRevalidationQueue();
|
|
60
63
|
if (!disableDynamoDBCache) {
|
|
@@ -67,16 +70,16 @@ export class NextjsSite extends SsrSite {
|
|
|
67
70
|
}
|
|
68
71
|
plan(bucket) {
|
|
69
72
|
const { path: sitePath, edge, experimental, imageOptimization, } = this.props;
|
|
70
|
-
const serverConfig = {
|
|
73
|
+
const serverConfig = this.wrapServerFunction({
|
|
71
74
|
description: "Next.js server",
|
|
72
75
|
bundle: path.join(sitePath, ".open-next", "server-function"),
|
|
73
|
-
handler:
|
|
76
|
+
handler: "index.handler",
|
|
74
77
|
environment: {
|
|
75
78
|
CACHE_BUCKET_NAME: bucket.bucketName,
|
|
76
79
|
CACHE_BUCKET_KEY_PREFIX: "_cache",
|
|
77
80
|
CACHE_BUCKET_REGION: Stack.of(this).region,
|
|
78
81
|
},
|
|
79
|
-
};
|
|
82
|
+
});
|
|
80
83
|
return this.validatePlan({
|
|
81
84
|
cloudFrontFunctions: {
|
|
82
85
|
serverCfFunction: {
|
|
@@ -289,50 +292,98 @@ export class NextjsSite extends SsrSite {
|
|
|
289
292
|
type: "NextjsSite",
|
|
290
293
|
data: {
|
|
291
294
|
...metadata.data,
|
|
292
|
-
routes: this.
|
|
295
|
+
routes: this.isPerRouteLoggingEnabled()
|
|
296
|
+
? {
|
|
297
|
+
logGroupPrefix: `/sst/lambda/${this.serverFunction.functionName}`,
|
|
298
|
+
data: this.useRoutes().map(({ route, logGroupPath }) => ({
|
|
299
|
+
route,
|
|
300
|
+
logGroupPath,
|
|
301
|
+
})),
|
|
302
|
+
}
|
|
303
|
+
: undefined,
|
|
293
304
|
},
|
|
294
305
|
};
|
|
295
306
|
}
|
|
296
|
-
|
|
307
|
+
wrapServerFunction(config) {
|
|
297
308
|
const { path: sitePath, experimental } = this.props;
|
|
309
|
+
const stack = Stack.of(this);
|
|
298
310
|
const wrapperName = "nextjssite-index";
|
|
299
311
|
const serverPath = path.join(sitePath, ".open-next", "server-function");
|
|
312
|
+
const injections = [];
|
|
313
|
+
if (this.isPerRouteLoggingEnabled()) {
|
|
314
|
+
injections.push(`
|
|
315
|
+
const routeData = ${JSON.stringify(this.useRoutes())}.find(({ regex }) => event.rawPath.match(new RegExp(regex)));
|
|
316
|
+
if (routeData) {
|
|
317
|
+
console.log("::sst::" + JSON.stringify({
|
|
318
|
+
action:"log.split",
|
|
319
|
+
properties: {
|
|
320
|
+
logGroupName:"/sst/lambda/" + context.functionName + routeData.logGroupPath,
|
|
321
|
+
},
|
|
322
|
+
}));
|
|
323
|
+
}`);
|
|
324
|
+
}
|
|
300
325
|
fs.writeFileSync(path.join(serverPath, `${wrapperName}.mjs`), experimental?.streaming
|
|
301
326
|
? [
|
|
302
|
-
`export const handler = awslambda.streamifyResponse(async (
|
|
327
|
+
`export const handler = awslambda.streamifyResponse(async (event, context) => {`,
|
|
328
|
+
...injections,
|
|
303
329
|
` const { handler: rawHandler} = await import("./index.mjs");`,
|
|
304
|
-
` return rawHandler(
|
|
330
|
+
` return rawHandler(event, context);`,
|
|
305
331
|
`});`,
|
|
306
332
|
].join("\n")
|
|
307
333
|
: [
|
|
308
|
-
`export const handler = async (
|
|
334
|
+
`export const handler = async (event, context) => {`,
|
|
335
|
+
...injections,
|
|
309
336
|
` const { handler: rawHandler} = await import("./index.mjs");`,
|
|
310
|
-
` return rawHandler(
|
|
337
|
+
` return rawHandler(event, context);`,
|
|
311
338
|
`};`,
|
|
312
339
|
].join("\n"));
|
|
313
|
-
return
|
|
340
|
+
return {
|
|
341
|
+
...config,
|
|
342
|
+
layers: this.isPerRouteLoggingEnabled()
|
|
343
|
+
? [
|
|
344
|
+
LayerVersion.fromLayerVersionArn(this, "SSTExtension", `arn:aws:lambda:${stack.region}:226609089145:layer:sst-extension:${LAYER_VERSION}`),
|
|
345
|
+
]
|
|
346
|
+
: undefined,
|
|
347
|
+
handler: `${wrapperName}.handler`,
|
|
348
|
+
};
|
|
314
349
|
}
|
|
315
|
-
|
|
350
|
+
useRoutes() {
|
|
351
|
+
if (this.routes)
|
|
352
|
+
return this.routes;
|
|
316
353
|
const id = this.node.id;
|
|
317
354
|
const { path: sitePath } = this.props;
|
|
318
355
|
try {
|
|
319
356
|
const content = JSON.parse(fs
|
|
320
357
|
.readFileSync(path.join(sitePath, ".next/routes-manifest.json"))
|
|
321
358
|
.toString());
|
|
322
|
-
|
|
359
|
+
this.routes = [
|
|
323
360
|
...[...content.dynamicRoutes, ...content.staticRoutes]
|
|
324
|
-
.map(({ page }) =>
|
|
325
|
-
|
|
326
|
-
|
|
361
|
+
.map(({ page, regex }) => {
|
|
362
|
+
const cwRoute = NextjsSite.buildCloudWatchRouteName(page);
|
|
363
|
+
const cwHash = NextjsSite.buildCloudWatchRouteHash(page);
|
|
364
|
+
return {
|
|
365
|
+
route: page,
|
|
366
|
+
regex,
|
|
367
|
+
logGroupPath: `/${cwHash}${cwRoute}`,
|
|
368
|
+
};
|
|
369
|
+
})
|
|
327
370
|
.sort((a, b) => a.route.localeCompare(b.route)),
|
|
328
371
|
...(content.dataRoutes || [])
|
|
329
|
-
.map(({ page }) =>
|
|
330
|
-
|
|
372
|
+
.map(({ page, dataRouteRegex }) => {
|
|
373
|
+
const routeDisplayName = page.endsWith("/")
|
|
331
374
|
? `/_next/data/BUILD_ID${page}index.json`
|
|
332
|
-
: `/_next/data/BUILD_ID${page}.json
|
|
333
|
-
|
|
375
|
+
: `/_next/data/BUILD_ID${page}.json`;
|
|
376
|
+
const cwRoute = NextjsSite.buildCloudWatchRouteName(routeDisplayName);
|
|
377
|
+
const cwHash = NextjsSite.buildCloudWatchRouteHash(`data:${page}`);
|
|
378
|
+
return {
|
|
379
|
+
route: routeDisplayName,
|
|
380
|
+
regex: dataRouteRegex,
|
|
381
|
+
logGroupPath: `/${cwHash}${cwRoute}`,
|
|
382
|
+
};
|
|
383
|
+
})
|
|
334
384
|
.sort((a, b) => a.route.localeCompare(b.route)),
|
|
335
385
|
];
|
|
386
|
+
return this.routes;
|
|
336
387
|
}
|
|
337
388
|
catch (e) {
|
|
338
389
|
console.error(e);
|
|
@@ -343,4 +394,41 @@ export class NextjsSite extends SsrSite {
|
|
|
343
394
|
const { path: sitePath } = this.props;
|
|
344
395
|
return fs.readFileSync(path.join(sitePath, ".next/BUILD_ID")).toString();
|
|
345
396
|
}
|
|
397
|
+
isPerRouteLoggingEnabled() {
|
|
398
|
+
return (!this.doNotDeploy &&
|
|
399
|
+
!this.props.edge &&
|
|
400
|
+
this.props._logging === "per-route");
|
|
401
|
+
}
|
|
402
|
+
disableDefaultLogging() {
|
|
403
|
+
const stack = Stack.of(this);
|
|
404
|
+
const server = this.serverFunction;
|
|
405
|
+
const policy = new Policy(this, "DisableLoggingPolicy", {
|
|
406
|
+
statements: [
|
|
407
|
+
new PolicyStatement({
|
|
408
|
+
effect: Effect.DENY,
|
|
409
|
+
actions: [
|
|
410
|
+
"logs:CreateLogGroup",
|
|
411
|
+
"logs:CreateLogStream",
|
|
412
|
+
"logs:PutLogEvents",
|
|
413
|
+
],
|
|
414
|
+
resources: [
|
|
415
|
+
`arn:aws:logs:${stack.region}:${stack.account}:log-group:/aws/lambda/${server.functionName}`,
|
|
416
|
+
`arn:aws:logs:${stack.region}:${stack.account}:log-group:/aws/lambda/${server.functionName}:*`,
|
|
417
|
+
],
|
|
418
|
+
}),
|
|
419
|
+
],
|
|
420
|
+
});
|
|
421
|
+
server.role?.attachInlinePolicy(policy);
|
|
422
|
+
}
|
|
423
|
+
static buildCloudWatchRouteName(route) {
|
|
424
|
+
return route.replace(/[^a-zA-Z0-9_\-/.#]/g, "");
|
|
425
|
+
}
|
|
426
|
+
static buildCloudWatchRouteHash(route) {
|
|
427
|
+
const hash = crypto.createHash("sha256");
|
|
428
|
+
hash.update(route);
|
|
429
|
+
return hash.digest("hex").substring(0, 8);
|
|
430
|
+
}
|
|
431
|
+
static _test = {
|
|
432
|
+
buildCloudWatchRouteName: NextjsSite.buildCloudWatchRouteName,
|
|
433
|
+
};
|
|
346
434
|
}
|
package/constructs/SsrSite.d.ts
CHANGED
|
@@ -8,7 +8,7 @@ import { SSTConstruct } from "./Construct.js";
|
|
|
8
8
|
import { NodeJSProps, FunctionProps } from "./Function.js";
|
|
9
9
|
import { SsrFunction, SsrFunctionProps } from "./SsrFunction.js";
|
|
10
10
|
import { EdgeFunction, EdgeFunctionProps } from "./EdgeFunction.js";
|
|
11
|
-
import { BaseSiteFileOptions, BaseSiteFileOptionsDeprecated, BaseSiteReplaceProps, BaseSiteCdkDistributionProps } from "./BaseSite.js";
|
|
11
|
+
import { BaseSiteFileOptions, BaseSiteFileOptionsFilter, BaseSiteFileOptionsDeprecated, BaseSiteReplaceProps, BaseSiteCdkDistributionProps } from "./BaseSite.js";
|
|
12
12
|
import { Size } from "./util/size.js";
|
|
13
13
|
import { Duration } from "./util/duration.js";
|
|
14
14
|
import { Permissions } from "./util/permission.js";
|
|
@@ -52,7 +52,10 @@ export interface SsrSiteNodeJSProps extends NodeJSProps {
|
|
|
52
52
|
}
|
|
53
53
|
export interface SsrDomainProps extends DistributionDomainProps {
|
|
54
54
|
}
|
|
55
|
+
export interface SsrSiteFileOptionsFilter extends BaseSiteFileOptionsFilter {
|
|
56
|
+
}
|
|
55
57
|
export interface SsrSiteFileOptions extends BaseSiteFileOptions {
|
|
58
|
+
filters: SsrSiteFileOptionsFilter[];
|
|
56
59
|
}
|
|
57
60
|
export interface SsrSiteFileOptionsDeprecated extends BaseSiteFileOptionsDeprecated {
|
|
58
61
|
}
|
|
@@ -288,6 +291,7 @@ export interface SsrSiteProps {
|
|
|
288
291
|
* },
|
|
289
292
|
* ],
|
|
290
293
|
* }
|
|
294
|
+
* ```
|
|
291
295
|
*/
|
|
292
296
|
fileOptions?: SsrSiteFileOptions[];
|
|
293
297
|
};
|
|
@@ -2,7 +2,7 @@ import { Construct } from "constructs";
|
|
|
2
2
|
import { Bucket, BucketProps, IBucket } from "aws-cdk-lib/aws-s3";
|
|
3
3
|
import { IDistribution } from "aws-cdk-lib/aws-cloudfront";
|
|
4
4
|
import { DistributionDomainProps } from "./Distribution.js";
|
|
5
|
-
import { BaseSiteFileOptions, BaseSiteReplaceProps, BaseSiteCdkDistributionProps, BaseSiteFileOptionsDeprecated } from "./BaseSite.js";
|
|
5
|
+
import { BaseSiteFileOptions, BaseSiteFileOptionsFilter, BaseSiteReplaceProps, BaseSiteCdkDistributionProps, BaseSiteFileOptionsDeprecated } from "./BaseSite.js";
|
|
6
6
|
import { SSTConstruct } from "./Construct.js";
|
|
7
7
|
import { FunctionBindingProps } from "./util/functionBinding.js";
|
|
8
8
|
export interface StaticSiteProps {
|
|
@@ -263,7 +263,10 @@ export interface StaticSiteProps {
|
|
|
263
263
|
}
|
|
264
264
|
export interface StaticSiteDomainProps extends DistributionDomainProps {
|
|
265
265
|
}
|
|
266
|
+
export interface StaticSiteFileOptionsFilter extends BaseSiteFileOptionsFilter {
|
|
267
|
+
}
|
|
266
268
|
export interface StaticSiteFileOptions extends BaseSiteFileOptions {
|
|
269
|
+
filters: StaticSiteFileOptionsFilter[];
|
|
267
270
|
}
|
|
268
271
|
export interface StaticSiteFileOptionsDeprecated extends BaseSiteFileOptionsDeprecated {
|
|
269
272
|
}
|
package/credentials.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { SdkProvider } from "sst-aws-cdk/lib/api/aws-auth/sdk-provider.js";
|
|
2
|
+
export type {} from "@smithy/types";
|
|
2
3
|
export declare const useAWSCredentialsProvider: () => import("@smithy/types").AwsCredentialIdentityProvider;
|
|
3
4
|
export declare const useAWSCredentials: () => Promise<import("@smithy/types").AwsCredentialIdentity>;
|
|
4
5
|
export declare const useSTSIdentity: () => Promise<import("@aws-sdk/client-sts").GetCallerIdentityCommandOutput>;
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"sideEffects": false,
|
|
3
3
|
"name": "sst",
|
|
4
|
-
"version": "2.30.
|
|
4
|
+
"version": "2.30.4",
|
|
5
5
|
"bin": {
|
|
6
6
|
"sst": "cli/sst.js"
|
|
7
7
|
},
|
|
@@ -25,29 +25,29 @@
|
|
|
25
25
|
},
|
|
26
26
|
"homepage": "https://sst.dev",
|
|
27
27
|
"dependencies": {
|
|
28
|
-
"@aws-cdk/aws-apigatewayv2-alpha": "^2.
|
|
29
|
-
"@aws-cdk/aws-apigatewayv2-authorizers-alpha": "^2.
|
|
30
|
-
"@aws-cdk/aws-apigatewayv2-integrations-alpha": "^2.
|
|
31
|
-
"@aws-cdk/cloud-assembly-schema": "2.
|
|
32
|
-
"@aws-cdk/cloudformation-diff": "2.
|
|
33
|
-
"@aws-cdk/cx-api": "2.
|
|
28
|
+
"@aws-cdk/aws-apigatewayv2-alpha": "^2.101.1-alpha.0",
|
|
29
|
+
"@aws-cdk/aws-apigatewayv2-authorizers-alpha": "^2.101.1-alpha.0",
|
|
30
|
+
"@aws-cdk/aws-apigatewayv2-integrations-alpha": "^2.101.1-alpha.0",
|
|
31
|
+
"@aws-cdk/cloud-assembly-schema": "2.101.1",
|
|
32
|
+
"@aws-cdk/cloudformation-diff": "2.101.1",
|
|
33
|
+
"@aws-cdk/cx-api": "2.101.1",
|
|
34
34
|
"@aws-crypto/sha256-js": "^5.0.0",
|
|
35
|
-
"@aws-sdk/client-cloudformation": "^3.
|
|
36
|
-
"@aws-sdk/client-ecs": "^3.
|
|
37
|
-
"@aws-sdk/client-eventbridge": "^3.
|
|
38
|
-
"@aws-sdk/client-iam": "^3.
|
|
39
|
-
"@aws-sdk/client-iot": "^3.
|
|
40
|
-
"@aws-sdk/client-iot-data-plane": "^3.
|
|
41
|
-
"@aws-sdk/client-lambda": "^3.
|
|
42
|
-
"@aws-sdk/client-rds-data": "^3.
|
|
43
|
-
"@aws-sdk/client-s3": "^3.
|
|
44
|
-
"@aws-sdk/client-ssm": "^3.
|
|
45
|
-
"@aws-sdk/client-sts": "^3.
|
|
35
|
+
"@aws-sdk/client-cloudformation": "^3.430.0",
|
|
36
|
+
"@aws-sdk/client-ecs": "^3.430.0",
|
|
37
|
+
"@aws-sdk/client-eventbridge": "^3.430.0",
|
|
38
|
+
"@aws-sdk/client-iam": "^3.430.0",
|
|
39
|
+
"@aws-sdk/client-iot": "^3.430.0",
|
|
40
|
+
"@aws-sdk/client-iot-data-plane": "^3.430.0",
|
|
41
|
+
"@aws-sdk/client-lambda": "^3.430.0",
|
|
42
|
+
"@aws-sdk/client-rds-data": "^3.430.0",
|
|
43
|
+
"@aws-sdk/client-s3": "^3.430.0",
|
|
44
|
+
"@aws-sdk/client-ssm": "^3.430.0",
|
|
45
|
+
"@aws-sdk/client-sts": "^3.430.0",
|
|
46
46
|
"@aws-sdk/config-resolver": "^3.374.0",
|
|
47
|
-
"@aws-sdk/credential-providers": "^3.
|
|
47
|
+
"@aws-sdk/credential-providers": "^3.430.0",
|
|
48
48
|
"@aws-sdk/middleware-retry": "^3.374.0",
|
|
49
|
-
"@aws-sdk/middleware-signing": "^3.
|
|
50
|
-
"@aws-sdk/signature-v4-crt": "^3.
|
|
49
|
+
"@aws-sdk/middleware-signing": "^3.428.0",
|
|
50
|
+
"@aws-sdk/signature-v4-crt": "^3.428.0",
|
|
51
51
|
"@aws-sdk/smithy-client": "^3.374.0",
|
|
52
52
|
"@babel/core": "^7.0.0-0",
|
|
53
53
|
"@babel/generator": "^7.20.5",
|
|
@@ -55,11 +55,11 @@
|
|
|
55
55
|
"@smithy/signature-v4": "^2.0.4",
|
|
56
56
|
"@trpc/server": "9.16.0",
|
|
57
57
|
"adm-zip": "^0.5.10",
|
|
58
|
-
"aws-cdk-lib": "2.
|
|
58
|
+
"aws-cdk-lib": "2.101.1",
|
|
59
59
|
"aws-iot-device-sdk": "^2.2.12",
|
|
60
60
|
"aws-sdk": "^2.1326.0",
|
|
61
61
|
"builtin-modules": "3.2.0",
|
|
62
|
-
"cdk-assets": "2.
|
|
62
|
+
"cdk-assets": "2.101.1",
|
|
63
63
|
"chalk": "^5.2.0",
|
|
64
64
|
"chokidar": "^3.5.3",
|
|
65
65
|
"ci-info": "^3.7.0",
|
|
@@ -87,7 +87,7 @@
|
|
|
87
87
|
"ora": "^6.1.2",
|
|
88
88
|
"react": "18.2.0",
|
|
89
89
|
"remeda": "^1.3.0",
|
|
90
|
-
"sst-aws-cdk": "2.
|
|
90
|
+
"sst-aws-cdk": "2.101.1",
|
|
91
91
|
"tree-kill": "^1.2.2",
|
|
92
92
|
"undici": "^5.12.0",
|
|
93
93
|
"uuid": "^9.0.0",
|
|
@@ -96,15 +96,16 @@
|
|
|
96
96
|
"zod": "^3.21.4"
|
|
97
97
|
},
|
|
98
98
|
"devDependencies": {
|
|
99
|
-
"@aws-sdk/client-api-gateway": "^3.
|
|
100
|
-
"@aws-sdk/client-cloudfront": "^3.
|
|
101
|
-
"@aws-sdk/client-codebuild": "^3.
|
|
102
|
-
"@aws-sdk/client-sqs": "^3.
|
|
103
|
-
"@aws-sdk/types": "^3.
|
|
99
|
+
"@aws-sdk/client-api-gateway": "^3.430.0",
|
|
100
|
+
"@aws-sdk/client-cloudfront": "^3.430.0",
|
|
101
|
+
"@aws-sdk/client-codebuild": "^3.430.0",
|
|
102
|
+
"@aws-sdk/client-sqs": "^3.430.0",
|
|
103
|
+
"@aws-sdk/types": "^3.428.0",
|
|
104
104
|
"@graphql-tools/merge": "^8.3.16",
|
|
105
105
|
"@sls-next/lambda-at-edge": "^3.7.0",
|
|
106
|
-
"@smithy/types": "^2.
|
|
106
|
+
"@smithy/types": "^2.3.5",
|
|
107
107
|
"@tsconfig/node16": "^1.0.3",
|
|
108
|
+
"@tsconfig/node18": "^18.2.2",
|
|
108
109
|
"@types/adm-zip": "^0.5.0",
|
|
109
110
|
"@types/aws-iot-device-sdk": "^2.2.4",
|
|
110
111
|
"@types/aws-lambda": "^8.10.108",
|
|
@@ -119,7 +120,7 @@
|
|
|
119
120
|
"@types/ws": "^8.5.3",
|
|
120
121
|
"@types/yargs": "^17.0.13",
|
|
121
122
|
"archiver": "^5.3.1",
|
|
122
|
-
"astro-sst": "2.30.
|
|
123
|
+
"astro-sst": "2.30.4",
|
|
123
124
|
"tsx": "^3.12.1",
|
|
124
125
|
"typescript": "^5.2.2",
|
|
125
126
|
"vitest": "^0.33.0"
|
package/stacks/synth.js
CHANGED
|
@@ -4,7 +4,6 @@ import { useAWSProvider, useSTSIdentity } from "../credentials.js";
|
|
|
4
4
|
import * as contextproviders from "sst-aws-cdk/lib/context-providers/index.js";
|
|
5
5
|
import path from "path";
|
|
6
6
|
import { VisibleError } from "../error.js";
|
|
7
|
-
import fs from "fs/promises";
|
|
8
7
|
import { Semaphore } from "../util/semaphore.js";
|
|
9
8
|
const sem = new Semaphore(1);
|
|
10
9
|
export async function synth(opts) {
|
|
@@ -32,8 +31,8 @@ export async function synth(opts) {
|
|
|
32
31
|
...opts,
|
|
33
32
|
buildDir: opts.buildDir || path.join(project.paths.out, "dist"),
|
|
34
33
|
};
|
|
35
|
-
await fs.rm(opts.buildDir
|
|
36
|
-
await fs.mkdir(opts.buildDir
|
|
34
|
+
// await fs.rm(opts.buildDir!, { recursive: true, force: true });
|
|
35
|
+
// await fs.mkdir(opts.buildDir!, { recursive: true });
|
|
37
36
|
const cfg = new Configuration();
|
|
38
37
|
await cfg.load();
|
|
39
38
|
let previous = new Set();
|