sst 2.2.8 → 2.3.0
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/cli/commands/bind.js +191 -19
- package/cli/commands/dev.js +2 -17
- package/cli/commands/secrets/set.js +22 -5
- package/cli/sst.js +0 -2
- package/cli/ui/deploy.d.ts +1 -1
- package/cli/ui/deploy.js +3 -6
- package/cli/ui/functions.d.ts +1 -1
- package/config.d.ts +14 -1
- package/config.js +68 -31
- package/constructs/App.d.ts +2 -2
- package/constructs/App.js +2 -4
- package/constructs/AstroSite.d.ts +1 -0
- package/constructs/AstroSite.js +1 -0
- package/constructs/Function.d.ts +1 -1
- package/constructs/Metadata.d.ts +5 -1
- package/constructs/NextjsSite.d.ts +1 -0
- package/constructs/NextjsSite.js +1 -0
- package/constructs/RemixSite.d.ts +1 -0
- package/constructs/RemixSite.js +1 -0
- package/constructs/SolidStartSite.d.ts +1 -0
- package/constructs/SolidStartSite.js +1 -0
- package/constructs/SsrSite.d.ts +15 -7
- package/constructs/SsrSite.js +52 -21
- package/constructs/StaticSite.d.ts +2 -1
- package/constructs/StaticSite.js +3 -15
- package/constructs/deprecated/NextjsSite.d.ts +5 -2
- package/constructs/deprecated/NextjsSite.js +4 -16
- package/package.json +1 -1
- package/sst.mjs +349 -268
- package/stacks/metadata.d.ts +0 -1
- package/stacks/metadata.js +1 -26
- package/support/bootstrap-metadata-function/index.mjs +2 -2
- package/cli/commands/env.d.ts +0 -15
- package/cli/commands/env.js +0 -48
- package/site-env.d.ts +0 -13
- package/site-env.js +0 -48
|
@@ -14,6 +14,7 @@ import { EdgeFunction } from "./EdgeFunction.js";
|
|
|
14
14
|
*/
|
|
15
15
|
export declare class SolidStartSite extends SsrSite {
|
|
16
16
|
protected initBuildConfig(): {
|
|
17
|
+
typesPath: string;
|
|
17
18
|
serverBuildOutputFile: string;
|
|
18
19
|
clientBuildOutputDir: string;
|
|
19
20
|
clientBuildVersionedSubDir: string;
|
|
@@ -17,6 +17,7 @@ import { EdgeFunction } from "./EdgeFunction.js";
|
|
|
17
17
|
export class SolidStartSite extends SsrSite {
|
|
18
18
|
initBuildConfig() {
|
|
19
19
|
return {
|
|
20
|
+
typesPath: ".",
|
|
20
21
|
serverBuildOutputFile: "dist/server/index.mjs",
|
|
21
22
|
clientBuildOutputDir: "dist/client",
|
|
22
23
|
clientBuildVersionedSubDir: "assets",
|
package/constructs/SsrSite.d.ts
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import { Construct } from "constructs";
|
|
2
2
|
import { Bucket, BucketProps, IBucket } from "aws-cdk-lib/aws-s3";
|
|
3
|
-
import { Function, FunctionProps } from "aws-cdk-lib/aws-lambda";
|
|
3
|
+
import { Function as CdkFunction, FunctionProps } from "aws-cdk-lib/aws-lambda";
|
|
4
4
|
import { IHostedZone } from "aws-cdk-lib/aws-route53";
|
|
5
5
|
import { Distribution, ICachePolicy, BehaviorOptions, CachePolicy } from "aws-cdk-lib/aws-cloudfront";
|
|
6
6
|
import { ICertificate } from "aws-cdk-lib/aws-certificatemanager";
|
|
7
7
|
import { S3Origin } from "aws-cdk-lib/aws-cloudfront-origins";
|
|
8
8
|
import { SSTConstruct } from "./Construct.js";
|
|
9
|
-
import { NodeJSProps } from "./Function.js";
|
|
9
|
+
import { NodeJSProps, Function } from "./Function.js";
|
|
10
10
|
import { EdgeFunction } from "./EdgeFunction.js";
|
|
11
11
|
import { BaseSiteDomainProps, BaseSiteReplaceProps, BaseSiteCdkDistributionProps } from "./BaseSite.js";
|
|
12
12
|
import { Size } from "./util/size.js";
|
|
@@ -14,6 +14,7 @@ import { Duration } from "./util/duration.js";
|
|
|
14
14
|
import { Permissions } from "./util/permission.js";
|
|
15
15
|
import { FunctionBindingProps } from "./util/functionBinding.js";
|
|
16
16
|
export type SsrBuildConfig = {
|
|
17
|
+
typesPath: string;
|
|
17
18
|
serverBuildOutputFile: string;
|
|
18
19
|
clientBuildOutputDir: string;
|
|
19
20
|
clientBuildVersionedSubDir: string;
|
|
@@ -196,7 +197,8 @@ export declare class SsrSite extends Construct implements SSTConstruct {
|
|
|
196
197
|
private doNotDeploy;
|
|
197
198
|
protected buildConfig: SsrBuildConfig;
|
|
198
199
|
private serverLambdaForEdge?;
|
|
199
|
-
protected serverLambdaForRegional?:
|
|
200
|
+
protected serverLambdaForRegional?: CdkFunction;
|
|
201
|
+
private serverLambdaForDev?;
|
|
200
202
|
private bucket;
|
|
201
203
|
private distribution;
|
|
202
204
|
private hostedZone?;
|
|
@@ -215,7 +217,7 @@ export declare class SsrSite extends Construct implements SSTConstruct {
|
|
|
215
217
|
* The internally created CDK resources.
|
|
216
218
|
*/
|
|
217
219
|
get cdk(): {
|
|
218
|
-
function:
|
|
220
|
+
function: CdkFunction | undefined;
|
|
219
221
|
bucket: Bucket;
|
|
220
222
|
distribution: Distribution;
|
|
221
223
|
hostedZone: IHostedZone | undefined;
|
|
@@ -233,9 +235,14 @@ export declare class SsrSite extends Construct implements SSTConstruct {
|
|
|
233
235
|
attachPermissions(permissions: Permissions): void;
|
|
234
236
|
/** @internal */
|
|
235
237
|
getConstructMetadata(): {
|
|
236
|
-
type: "
|
|
238
|
+
type: "NextjsSite" | "RemixSite" | "AstroSite" | "SolidStartSite";
|
|
237
239
|
data: {
|
|
240
|
+
mode: "placeholder" | "deployed";
|
|
241
|
+
path: string;
|
|
238
242
|
customDomainUrl: string | undefined;
|
|
243
|
+
edge: boolean | undefined;
|
|
244
|
+
server: string;
|
|
245
|
+
secrets: string[];
|
|
239
246
|
};
|
|
240
247
|
};
|
|
241
248
|
/** @internal */
|
|
@@ -248,8 +255,9 @@ export declare class SsrSite extends Construct implements SSTConstruct {
|
|
|
248
255
|
private createS3AssetFileOptions;
|
|
249
256
|
private createS3Bucket;
|
|
250
257
|
private createS3Deployment;
|
|
251
|
-
protected createFunctionForRegional():
|
|
258
|
+
protected createFunctionForRegional(): CdkFunction;
|
|
252
259
|
protected createFunctionForEdge(): EdgeFunction;
|
|
260
|
+
protected createFunctionForDev(): Function;
|
|
253
261
|
private createFunctionPermissionsForRegional;
|
|
254
262
|
private createFunctionPermissionsForEdge;
|
|
255
263
|
private validateCloudFrontDistributionSettings;
|
|
@@ -269,6 +277,6 @@ export declare class SsrSite extends Construct implements SSTConstruct {
|
|
|
269
277
|
protected createRoute53Records(): void;
|
|
270
278
|
private getS3ContentReplaceValues;
|
|
271
279
|
private validateSiteExists;
|
|
272
|
-
private
|
|
280
|
+
private writeTypesFile;
|
|
273
281
|
protected generateBuildId(): string;
|
|
274
282
|
}
|
package/constructs/SsrSite.js
CHANGED
|
@@ -6,10 +6,10 @@ import crypto from "crypto";
|
|
|
6
6
|
import spawn from "cross-spawn";
|
|
7
7
|
import { execSync } from "child_process";
|
|
8
8
|
import { Construct } from "constructs";
|
|
9
|
-
import { Fn, Token, Duration as CdkDuration,
|
|
9
|
+
import { Fn, Token, Duration as CdkDuration, RemovalPolicy, CustomResource, } from "aws-cdk-lib";
|
|
10
10
|
import { BlockPublicAccess, Bucket, } from "aws-cdk-lib/aws-s3";
|
|
11
|
-
import { Effect, Policy, PolicyStatement } from "aws-cdk-lib/aws-iam";
|
|
12
|
-
import { Function, Code, Runtime, FunctionUrlAuthType, } from "aws-cdk-lib/aws-lambda";
|
|
11
|
+
import { Role, Effect, Policy, PolicyStatement, AnyPrincipal, } from "aws-cdk-lib/aws-iam";
|
|
12
|
+
import { Function as CdkFunction, 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
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";
|
|
@@ -19,12 +19,13 @@ import { CloudFrontTarget } from "aws-cdk-lib/aws-route53-targets";
|
|
|
19
19
|
import { Stack } from "./Stack.js";
|
|
20
20
|
import { Logger } from "../logger.js";
|
|
21
21
|
import { isCDKConstruct } from "./Construct.js";
|
|
22
|
+
import { Function } from "./Function.js";
|
|
23
|
+
import { Secret } from "./Secret.js";
|
|
22
24
|
import { getBuildCmdEnvironment, } from "./BaseSite.js";
|
|
23
25
|
import { HttpsRedirect } from "./cdk/website-redirect.js";
|
|
24
26
|
import { DnsValidatedCertificate } from "./cdk/dns-validated-certificate.js";
|
|
25
27
|
import { attachPermissionsToRole } from "./util/permission.js";
|
|
26
28
|
import { getParameterPath, } from "./util/functionBinding.js";
|
|
27
|
-
import { SiteEnv } from "../site-env.js";
|
|
28
29
|
import { useProject } from "../project.js";
|
|
29
30
|
const __dirname = url.fileURLToPath(new URL(".", import.meta.url));
|
|
30
31
|
/**
|
|
@@ -45,6 +46,7 @@ export class SsrSite extends Construct {
|
|
|
45
46
|
buildConfig;
|
|
46
47
|
serverLambdaForEdge;
|
|
47
48
|
serverLambdaForRegional;
|
|
49
|
+
serverLambdaForDev;
|
|
48
50
|
bucket;
|
|
49
51
|
distribution;
|
|
50
52
|
hostedZone;
|
|
@@ -64,16 +66,17 @@ export class SsrSite extends Construct {
|
|
|
64
66
|
};
|
|
65
67
|
this.doNotDeploy =
|
|
66
68
|
!stack.isActive || (app.mode === "dev" && !this.props.dev?.deploy);
|
|
69
|
+
this.buildConfig = this.initBuildConfig();
|
|
67
70
|
this.validateSiteExists();
|
|
68
|
-
this.
|
|
71
|
+
this.writeTypesFile();
|
|
69
72
|
if (this.doNotDeploy) {
|
|
70
73
|
// @ts-ignore
|
|
71
|
-
this.
|
|
74
|
+
this.bucket = this.distribution = null;
|
|
75
|
+
this.serverLambdaForDev = this.createFunctionForDev();
|
|
72
76
|
return;
|
|
73
77
|
}
|
|
74
78
|
const cliLayer = new AwsCliLayer(this, "AwsCliLayer");
|
|
75
79
|
// Build app
|
|
76
|
-
this.buildConfig = this.initBuildConfig();
|
|
77
80
|
this.buildApp();
|
|
78
81
|
// Create Bucket which will be utilised to contain the statics
|
|
79
82
|
this.bucket = this.createS3Bucket();
|
|
@@ -168,9 +171,20 @@ export class SsrSite extends Construct {
|
|
|
168
171
|
/** @internal */
|
|
169
172
|
getConstructMetadata() {
|
|
170
173
|
return {
|
|
171
|
-
type:
|
|
174
|
+
type: this.constructor.name,
|
|
172
175
|
data: {
|
|
176
|
+
mode: this.doNotDeploy
|
|
177
|
+
? "placeholder"
|
|
178
|
+
: "deployed",
|
|
179
|
+
path: this.props.path,
|
|
173
180
|
customDomainUrl: this.customDomainUrl,
|
|
181
|
+
edge: this.props.edge,
|
|
182
|
+
server: (this.serverLambdaForDev ||
|
|
183
|
+
this.serverLambdaForRegional ||
|
|
184
|
+
this.serverLambdaForEdge)?.functionArn,
|
|
185
|
+
secrets: (this.props.bind || [])
|
|
186
|
+
.filter((c) => c instanceof Secret)
|
|
187
|
+
.map((c) => c.name),
|
|
174
188
|
},
|
|
175
189
|
};
|
|
176
190
|
}
|
|
@@ -206,6 +220,7 @@ export class SsrSite extends Construct {
|
|
|
206
220
|
/////////////////////
|
|
207
221
|
initBuildConfig() {
|
|
208
222
|
return {
|
|
223
|
+
typesPath: ".",
|
|
209
224
|
serverBuildOutputFile: "placeholder",
|
|
210
225
|
clientBuildOutputDir: "placeholder",
|
|
211
226
|
clientBuildVersionedSubDir: "placeholder",
|
|
@@ -342,7 +357,7 @@ export class SsrSite extends Construct {
|
|
|
342
357
|
}
|
|
343
358
|
createS3Deployment(cliLayer, assets, fileOptions) {
|
|
344
359
|
// Create a Lambda function that will be doing the uploading
|
|
345
|
-
const uploader = new
|
|
360
|
+
const uploader = new CdkFunction(this, "S3Uploader", {
|
|
346
361
|
code: Code.fromAsset(path.join(__dirname, "../support/base-site-custom-resource")),
|
|
347
362
|
layers: [cliLayer],
|
|
348
363
|
runtime: Runtime.PYTHON_3_7,
|
|
@@ -353,7 +368,7 @@ export class SsrSite extends Construct {
|
|
|
353
368
|
this.bucket.grantReadWrite(uploader);
|
|
354
369
|
assets.forEach((asset) => asset.grantRead(uploader));
|
|
355
370
|
// Create the custom resource function
|
|
356
|
-
const handler = new
|
|
371
|
+
const handler = new CdkFunction(this, "S3Handler", {
|
|
357
372
|
code: Code.fromAsset(path.join(__dirname, "../support/base-site-custom-resource")),
|
|
358
373
|
layers: [cliLayer],
|
|
359
374
|
runtime: Runtime.PYTHON_3_7,
|
|
@@ -399,6 +414,26 @@ export class SsrSite extends Construct {
|
|
|
399
414
|
createFunctionForEdge() {
|
|
400
415
|
return {};
|
|
401
416
|
}
|
|
417
|
+
createFunctionForDev() {
|
|
418
|
+
const { runtime, timeout, memorySize, permissions, environment, bind } = this.props;
|
|
419
|
+
const role = new Role(this, "ServerFunctionRole", {
|
|
420
|
+
assumedBy: new AnyPrincipal(),
|
|
421
|
+
maxSessionDuration: CdkDuration.hours(12),
|
|
422
|
+
});
|
|
423
|
+
const fn = new Function(this, `ServerFunction`, {
|
|
424
|
+
description: "Server handler placeholder",
|
|
425
|
+
handler: "placeholder",
|
|
426
|
+
runtime,
|
|
427
|
+
memorySize,
|
|
428
|
+
timeout,
|
|
429
|
+
bind,
|
|
430
|
+
environment,
|
|
431
|
+
permissions,
|
|
432
|
+
role,
|
|
433
|
+
});
|
|
434
|
+
fn._doNotAllowOthersToBind = true;
|
|
435
|
+
return fn;
|
|
436
|
+
}
|
|
402
437
|
createFunctionPermissionsForRegional() {
|
|
403
438
|
this.bucket.grantReadWrite(this.serverLambdaForRegional.role);
|
|
404
439
|
}
|
|
@@ -751,17 +786,13 @@ function handler(event) {
|
|
|
751
786
|
throw new Error(`No site found at "${path.resolve(sitePath)}"`);
|
|
752
787
|
}
|
|
753
788
|
}
|
|
754
|
-
|
|
755
|
-
|
|
756
|
-
|
|
757
|
-
|
|
758
|
-
|
|
759
|
-
|
|
760
|
-
|
|
761
|
-
environment: key,
|
|
762
|
-
stack: Stack.of(this).stackName,
|
|
763
|
-
});
|
|
764
|
-
}
|
|
789
|
+
writeTypesFile() {
|
|
790
|
+
const typesPath = path.resolve(this.props.path, this.buildConfig.typesPath, "sst-env.d.ts");
|
|
791
|
+
// Do not override the types file if it already exists
|
|
792
|
+
if (fs.existsSync(typesPath))
|
|
793
|
+
return;
|
|
794
|
+
const relPathToSstTypesFile = path.join(path.relative(path.dirname(typesPath), useProject().paths.root), ".sst/types/index.ts");
|
|
795
|
+
fs.writeFileSync(typesPath, `/// <reference path="${relPathToSstTypesFile}" />`);
|
|
765
796
|
}
|
|
766
797
|
generateBuildId() {
|
|
767
798
|
// We will generate a hash based on the contents of the "public" folder
|
|
@@ -309,6 +309,8 @@ export declare class StaticSite extends Construct implements SSTConstruct {
|
|
|
309
309
|
getConstructMetadata(): {
|
|
310
310
|
type: "StaticSite";
|
|
311
311
|
data: {
|
|
312
|
+
path: string;
|
|
313
|
+
environment: Record<string, string>;
|
|
312
314
|
customDomainUrl: string | undefined;
|
|
313
315
|
};
|
|
314
316
|
};
|
|
@@ -330,5 +332,4 @@ export declare class StaticSite extends Construct implements SSTConstruct {
|
|
|
330
332
|
private createCertificate;
|
|
331
333
|
protected createRoute53Records(): void;
|
|
332
334
|
private getS3ContentReplaceValues;
|
|
333
|
-
private registerSiteEnvironment;
|
|
334
335
|
}
|
package/constructs/StaticSite.js
CHANGED
|
@@ -4,7 +4,7 @@ import fs from "fs";
|
|
|
4
4
|
import crypto from "crypto";
|
|
5
5
|
import { execSync } from "child_process";
|
|
6
6
|
import { Construct } from "constructs";
|
|
7
|
-
import { Token, Duration,
|
|
7
|
+
import { Token, Duration, RemovalPolicy, CustomResource, } from "aws-cdk-lib";
|
|
8
8
|
import { BlockPublicAccess, Bucket, } from "aws-cdk-lib/aws-s3";
|
|
9
9
|
import { Asset } from "aws-cdk-lib/aws-s3-assets";
|
|
10
10
|
import { Effect, Policy, PolicyStatement } from "aws-cdk-lib/aws-iam";
|
|
@@ -22,7 +22,6 @@ import { isCDKConstruct } from "./Construct.js";
|
|
|
22
22
|
import { getParameterPath, } from "./util/functionBinding.js";
|
|
23
23
|
import { gray } from "colorette";
|
|
24
24
|
import { useProject } from "../project.js";
|
|
25
|
-
import { SiteEnv } from "../site-env.js";
|
|
26
25
|
const __dirname = path.dirname(url.fileURLToPath(import.meta.url));
|
|
27
26
|
/////////////////////
|
|
28
27
|
// Construct
|
|
@@ -63,7 +62,6 @@ export class StaticSite extends Construct {
|
|
|
63
62
|
this.doNotDeploy =
|
|
64
63
|
!stack.isActive || (app.mode === "dev" && !this.props.dev?.deploy);
|
|
65
64
|
this.validateCustomDomainSettings();
|
|
66
|
-
this.registerSiteEnvironment();
|
|
67
65
|
this.generateViteTypes();
|
|
68
66
|
if (this.doNotDeploy) {
|
|
69
67
|
// @ts-ignore
|
|
@@ -138,6 +136,8 @@ export class StaticSite extends Construct {
|
|
|
138
136
|
return {
|
|
139
137
|
type: "StaticSite",
|
|
140
138
|
data: {
|
|
139
|
+
path: this.props.path,
|
|
140
|
+
environment: this.props.environment || {},
|
|
141
141
|
customDomainUrl: this.customDomainUrl,
|
|
142
142
|
},
|
|
143
143
|
};
|
|
@@ -627,16 +627,4 @@ function handler(event) {
|
|
|
627
627
|
});
|
|
628
628
|
return replaceValues;
|
|
629
629
|
}
|
|
630
|
-
registerSiteEnvironment() {
|
|
631
|
-
for (const [key, value] of Object.entries(this.props.environment || {})) {
|
|
632
|
-
const outputId = `SstSiteEnv_${key}`;
|
|
633
|
-
const output = new CfnOutput(this, outputId, { value });
|
|
634
|
-
SiteEnv.append({
|
|
635
|
-
path: this.props.path,
|
|
636
|
-
output: Stack.of(this).getLogicalId(output),
|
|
637
|
-
environment: key,
|
|
638
|
-
stack: Stack.of(this).stackName,
|
|
639
|
-
});
|
|
640
|
-
}
|
|
641
|
-
}
|
|
642
630
|
}
|
|
@@ -256,8 +256,12 @@ export declare class NextjsSite extends Construct implements SSTConstruct {
|
|
|
256
256
|
*/
|
|
257
257
|
attachPermissions(permissions: Permissions): void;
|
|
258
258
|
getConstructMetadata(): {
|
|
259
|
-
type: "
|
|
259
|
+
type: "SlsNextjsSite";
|
|
260
260
|
data: {
|
|
261
|
+
path: string;
|
|
262
|
+
environment: {
|
|
263
|
+
[key: string]: string;
|
|
264
|
+
};
|
|
261
265
|
distributionId: string;
|
|
262
266
|
customDomainUrl: string | undefined;
|
|
263
267
|
};
|
|
@@ -292,6 +296,5 @@ export declare class NextjsSite extends Construct implements SSTConstruct {
|
|
|
292
296
|
private readRoutesManifest;
|
|
293
297
|
private getS3ContentReplaceValues;
|
|
294
298
|
private getLambdaContentReplaceValues;
|
|
295
|
-
private registerSiteEnvironment;
|
|
296
299
|
private normalizeRuntime;
|
|
297
300
|
}
|
|
@@ -4,7 +4,7 @@ import fs from "fs";
|
|
|
4
4
|
import spawn from "cross-spawn";
|
|
5
5
|
import { execSync } from "child_process";
|
|
6
6
|
import { Construct } from "constructs";
|
|
7
|
-
import { Token, Duration,
|
|
7
|
+
import { Token, Duration, RemovalPolicy, CustomResource, } from "aws-cdk-lib";
|
|
8
8
|
import * as s3 from "aws-cdk-lib/aws-s3";
|
|
9
9
|
import { Role, Effect, PolicyStatement, CompositePrincipal, ServicePrincipal, ManagedPolicy, } from "aws-cdk-lib/aws-iam";
|
|
10
10
|
import * as sqs from "aws-cdk-lib/aws-sqs";
|
|
@@ -27,7 +27,6 @@ import { getHandlerHash } from "../util/builder.js";
|
|
|
27
27
|
import { getParameterPath, } from "../util/functionBinding.js";
|
|
28
28
|
import * as crossRegionHelper from "./cross-region-helper.js";
|
|
29
29
|
import { gray, red } from "colorette";
|
|
30
|
-
import { SiteEnv } from "../../site-env.js";
|
|
31
30
|
import { useProject } from "../../project.js";
|
|
32
31
|
const __dirname = url.fileURLToPath(new URL(".", import.meta.url));
|
|
33
32
|
/////////////////////
|
|
@@ -130,7 +129,6 @@ export class NextjsSite extends Construct {
|
|
|
130
129
|
this.props = props;
|
|
131
130
|
this.cdk = {};
|
|
132
131
|
this.awsCliLayer = new AwsCliLayer(this, "AwsCliLayer");
|
|
133
|
-
this.registerSiteEnvironment();
|
|
134
132
|
// Build app
|
|
135
133
|
if (this.isPlaceholder) {
|
|
136
134
|
this.buildOutDir = null;
|
|
@@ -230,8 +228,10 @@ export class NextjsSite extends Construct {
|
|
|
230
228
|
}
|
|
231
229
|
getConstructMetadata() {
|
|
232
230
|
return {
|
|
233
|
-
type: "
|
|
231
|
+
type: "SlsNextjsSite",
|
|
234
232
|
data: {
|
|
233
|
+
path: this.props.path,
|
|
234
|
+
environment: this.props.environment || {},
|
|
235
235
|
distributionId: this.cdk.distribution.distributionId,
|
|
236
236
|
customDomainUrl: this.customDomainUrl,
|
|
237
237
|
},
|
|
@@ -1045,18 +1045,6 @@ export class NextjsSite extends Construct {
|
|
|
1045
1045
|
});
|
|
1046
1046
|
return replaceValues;
|
|
1047
1047
|
}
|
|
1048
|
-
registerSiteEnvironment() {
|
|
1049
|
-
for (const [key, value] of Object.entries(this.props.environment || {})) {
|
|
1050
|
-
const outputId = `SstSiteEnv_${key}`;
|
|
1051
|
-
const output = new CfnOutput(this, outputId, { value });
|
|
1052
|
-
SiteEnv.append({
|
|
1053
|
-
path: this.props.path,
|
|
1054
|
-
output: Stack.of(this).getLogicalId(output),
|
|
1055
|
-
environment: key,
|
|
1056
|
-
stack: Stack.of(this).stackName,
|
|
1057
|
-
});
|
|
1058
|
-
}
|
|
1059
|
-
}
|
|
1060
1048
|
normalizeRuntime(runtime) {
|
|
1061
1049
|
if (runtime === "nodejs12.x") {
|
|
1062
1050
|
return lambda.Runtime.NODEJS_12_X;
|