sst 2.0.38 → 2.1.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/cdk/cloudformation-deployments-wrapper.js +4 -3
- package/cli/commands/plugins/kysely.js +1 -1
- package/cli/sst.js +5 -0
- package/constructs/SsrSite.d.ts +1 -1
- package/constructs/SsrSite.js +5 -10
- package/constructs/StaticSite.d.ts +3 -2
- package/constructs/StaticSite.js +55 -35
- package/package.json +1 -1
- package/sst.mjs +11 -4
|
@@ -47,13 +47,14 @@ const useDeployment = Context.memo(() => {
|
|
|
47
47
|
const state = new Map();
|
|
48
48
|
return {
|
|
49
49
|
async get(sdkProvider, options) {
|
|
50
|
-
|
|
50
|
+
const region = options.stack.environment.region;
|
|
51
|
+
if (!state.has(region)) {
|
|
51
52
|
const deployment = new CloudFormationDeployments({ sdkProvider });
|
|
52
53
|
const { stackSdk, resolvedEnvironment, cloudFormationRoleArn } = await deployment.prepareSdkFor(options.stack, options.roleArn);
|
|
53
54
|
const toolkitInfo = await ToolkitInfo.lookup(resolvedEnvironment, stackSdk, options.toolkitStackName);
|
|
54
55
|
// Do a verification of the bootstrap stack version
|
|
55
56
|
await deployment.validateBootstrapStackVersion(options.stack.stackName, options.stack.requiresBootstrapStackVersion, options.stack.bootstrapStackVersionSsmParameter, toolkitInfo);
|
|
56
|
-
state.set(
|
|
57
|
+
state.set(region, {
|
|
57
58
|
deployment,
|
|
58
59
|
toolkitInfo,
|
|
59
60
|
stackSdk,
|
|
@@ -61,7 +62,7 @@ const useDeployment = Context.memo(() => {
|
|
|
61
62
|
cloudFormationRoleArn,
|
|
62
63
|
});
|
|
63
64
|
}
|
|
64
|
-
return state.get(
|
|
65
|
+
return state.get(region);
|
|
65
66
|
},
|
|
66
67
|
};
|
|
67
68
|
});
|
|
@@ -85,7 +85,7 @@ export const useKyselyTypeGenerator = Context.memo(async () => {
|
|
|
85
85
|
defaultDatabaseName: c.data.defaultDatabaseName,
|
|
86
86
|
secretArn: c.data.secretArn,
|
|
87
87
|
}));
|
|
88
|
-
databases.map((db) => generate(db));
|
|
88
|
+
databases.map((db) => generate(db).catch());
|
|
89
89
|
});
|
|
90
90
|
bus.subscribe("function.success", async (evt) => {
|
|
91
91
|
if (!evt.properties.body?.results)
|
package/cli/sst.js
CHANGED
|
@@ -62,4 +62,9 @@ process.on("uncaughtException", (err) => {
|
|
|
62
62
|
process.exit(1);
|
|
63
63
|
});
|
|
64
64
|
process.on("beforeExit", () => { });
|
|
65
|
+
// Check Node version
|
|
66
|
+
const nodeVersion = process.versions.node;
|
|
67
|
+
if (Number(nodeVersion.split(".")[0]) < 16) {
|
|
68
|
+
throw new VisibleError(`Node.js version ${nodeVersion} is not supported by SST. Please upgrade to Node.js 16 or later.`);
|
|
69
|
+
}
|
|
65
70
|
program.parse();
|
package/constructs/SsrSite.d.ts
CHANGED
|
@@ -211,7 +211,7 @@ export declare class SsrSite extends Construct implements SSTConstruct {
|
|
|
211
211
|
distribution: Distribution;
|
|
212
212
|
hostedZone: IHostedZone | undefined;
|
|
213
213
|
certificate: ICertificate | undefined;
|
|
214
|
-
};
|
|
214
|
+
} | undefined;
|
|
215
215
|
/**
|
|
216
216
|
* Attaches the given list of permissions to allow the Astro server side
|
|
217
217
|
* rendering to access other AWS resources.
|
package/constructs/SsrSite.js
CHANGED
|
@@ -26,7 +26,6 @@ import { attachPermissionsToRole } from "./util/permission.js";
|
|
|
26
26
|
import { getParameterPath, } from "./util/functionBinding.js";
|
|
27
27
|
import { SiteEnv } from "../site-env.js";
|
|
28
28
|
import { useProject } from "../project.js";
|
|
29
|
-
import { VisibleError } from "../error.js";
|
|
30
29
|
const __dirname = url.fileURLToPath(new URL(".", import.meta.url));
|
|
31
30
|
/**
|
|
32
31
|
* The `SsrSite` construct is a higher level CDK construct that makes it easy to create modern web apps with Server Side Rendering capabilities.
|
|
@@ -111,9 +110,8 @@ export class SsrSite extends Construct {
|
|
|
111
110
|
* The CloudFront URL of the website.
|
|
112
111
|
*/
|
|
113
112
|
get url() {
|
|
114
|
-
if (this.doNotDeploy)
|
|
113
|
+
if (this.doNotDeploy)
|
|
115
114
|
return;
|
|
116
|
-
}
|
|
117
115
|
return `https://${this.distribution.distributionDomainName}`;
|
|
118
116
|
}
|
|
119
117
|
/**
|
|
@@ -121,13 +119,11 @@ export class SsrSite extends Construct {
|
|
|
121
119
|
* custom domain.
|
|
122
120
|
*/
|
|
123
121
|
get customDomainUrl() {
|
|
124
|
-
if (this.doNotDeploy)
|
|
122
|
+
if (this.doNotDeploy)
|
|
125
123
|
return;
|
|
126
|
-
}
|
|
127
124
|
const { customDomain } = this.props;
|
|
128
|
-
if (!customDomain)
|
|
125
|
+
if (!customDomain)
|
|
129
126
|
return;
|
|
130
|
-
}
|
|
131
127
|
if (typeof customDomain === "string") {
|
|
132
128
|
return `https://${customDomain}`;
|
|
133
129
|
}
|
|
@@ -139,9 +135,8 @@ export class SsrSite extends Construct {
|
|
|
139
135
|
* The internally created CDK resources.
|
|
140
136
|
*/
|
|
141
137
|
get cdk() {
|
|
142
|
-
if (this.doNotDeploy)
|
|
143
|
-
|
|
144
|
-
}
|
|
138
|
+
if (this.doNotDeploy)
|
|
139
|
+
return;
|
|
145
140
|
return {
|
|
146
141
|
function: this.serverLambdaForRegional,
|
|
147
142
|
bucket: this.bucket,
|
|
@@ -305,7 +305,7 @@ export declare class StaticSite extends Construct implements SSTConstruct {
|
|
|
305
305
|
distribution: Distribution;
|
|
306
306
|
hostedZone: IHostedZone | undefined;
|
|
307
307
|
certificate: ICertificate | undefined;
|
|
308
|
-
};
|
|
308
|
+
} | undefined;
|
|
309
309
|
getConstructMetadata(): {
|
|
310
310
|
type: "StaticSite";
|
|
311
311
|
data: {
|
|
@@ -321,9 +321,10 @@ export declare class StaticSite extends Construct implements SSTConstruct {
|
|
|
321
321
|
private createS3Bucket;
|
|
322
322
|
private createS3Deployment;
|
|
323
323
|
private validateCloudFrontDistributionSettings;
|
|
324
|
-
protected buildDistributionDomainNames(): string[];
|
|
325
324
|
private createCfDistribution;
|
|
326
325
|
private createCloudFrontInvalidation;
|
|
326
|
+
protected buildDistributionDomainNames(): string[];
|
|
327
|
+
private buildDistributionBehavior;
|
|
327
328
|
protected validateCustomDomainSettings(): void;
|
|
328
329
|
protected lookupHostedZone(): IHostedZone | undefined;
|
|
329
330
|
private createCertificate;
|
package/constructs/StaticSite.js
CHANGED
|
@@ -11,7 +11,7 @@ import { Effect, Policy, PolicyStatement } from "aws-cdk-lib/aws-iam";
|
|
|
11
11
|
import { Code, Function, Runtime } from "aws-cdk-lib/aws-lambda";
|
|
12
12
|
import { HostedZone, ARecord, AaaaRecord, RecordTarget, } from "aws-cdk-lib/aws-route53";
|
|
13
13
|
import { CloudFrontTarget } from "aws-cdk-lib/aws-route53-targets";
|
|
14
|
-
import { Distribution, ViewerProtocolPolicy } from "aws-cdk-lib/aws-cloudfront";
|
|
14
|
+
import { Distribution, Function as CfFunction, FunctionCode as CfFunctionCode, FunctionEventType as CfFunctionEventType, ViewerProtocolPolicy, } from "aws-cdk-lib/aws-cloudfront";
|
|
15
15
|
import { S3Origin } from "aws-cdk-lib/aws-cloudfront-origins";
|
|
16
16
|
import { AwsCliLayer } from "aws-cdk-lib/lambda-layer-awscli";
|
|
17
17
|
import { Stack } from "./Stack.js";
|
|
@@ -23,7 +23,6 @@ import { getParameterPath, } from "./util/functionBinding.js";
|
|
|
23
23
|
import { gray } from "colorette";
|
|
24
24
|
import { useProject } from "../project.js";
|
|
25
25
|
import { SiteEnv } from "../site-env.js";
|
|
26
|
-
import { VisibleError } from "../error.js";
|
|
27
26
|
const __dirname = path.dirname(url.fileURLToPath(import.meta.url));
|
|
28
27
|
/////////////////////
|
|
29
28
|
// Construct
|
|
@@ -100,22 +99,19 @@ export class StaticSite extends Construct {
|
|
|
100
99
|
* The CloudFront URL of the website.
|
|
101
100
|
*/
|
|
102
101
|
get url() {
|
|
103
|
-
if (this.doNotDeploy)
|
|
102
|
+
if (this.doNotDeploy)
|
|
104
103
|
return;
|
|
105
|
-
}
|
|
106
104
|
return `https://${this.distribution.distributionDomainName}`;
|
|
107
105
|
}
|
|
108
106
|
/**
|
|
109
107
|
* If the custom domain is enabled, this is the URL of the website with the custom domain.
|
|
110
108
|
*/
|
|
111
109
|
get customDomainUrl() {
|
|
112
|
-
if (this.doNotDeploy)
|
|
110
|
+
if (this.doNotDeploy)
|
|
113
111
|
return;
|
|
114
|
-
}
|
|
115
112
|
const { customDomain } = this.props;
|
|
116
|
-
if (!customDomain)
|
|
113
|
+
if (!customDomain)
|
|
117
114
|
return;
|
|
118
|
-
}
|
|
119
115
|
if (typeof customDomain === "string") {
|
|
120
116
|
return `https://${customDomain}`;
|
|
121
117
|
}
|
|
@@ -127,9 +123,8 @@ export class StaticSite extends Construct {
|
|
|
127
123
|
* The internally created CDK resources.
|
|
128
124
|
*/
|
|
129
125
|
get cdk() {
|
|
130
|
-
if (this.doNotDeploy)
|
|
131
|
-
|
|
132
|
-
}
|
|
126
|
+
if (this.doNotDeploy)
|
|
127
|
+
return;
|
|
133
128
|
return {
|
|
134
129
|
bucket: this.bucket,
|
|
135
130
|
distribution: this.distribution,
|
|
@@ -387,25 +382,6 @@ interface ImportMeta {
|
|
|
387
382
|
throw new Error(`Cannot configure the "cfDistribution.errorResponses" when "errorPage" is passed in. Use one or the other to configure the behavior for error pages.`);
|
|
388
383
|
}
|
|
389
384
|
}
|
|
390
|
-
buildDistributionDomainNames() {
|
|
391
|
-
const { customDomain } = this.props;
|
|
392
|
-
const domainNames = [];
|
|
393
|
-
if (!customDomain) {
|
|
394
|
-
// no domain
|
|
395
|
-
}
|
|
396
|
-
else if (typeof customDomain === "string") {
|
|
397
|
-
domainNames.push(customDomain);
|
|
398
|
-
}
|
|
399
|
-
else {
|
|
400
|
-
domainNames.push(customDomain.domainName);
|
|
401
|
-
if (customDomain.alternateNames) {
|
|
402
|
-
if (!customDomain.cdk?.certificate)
|
|
403
|
-
throw new Error("Certificates for alternate domains cannot be automatically created. Please specify certificate to use");
|
|
404
|
-
domainNames.push(...customDomain.alternateNames);
|
|
405
|
-
}
|
|
406
|
-
}
|
|
407
|
-
return domainNames;
|
|
408
|
-
}
|
|
409
385
|
createCfDistribution() {
|
|
410
386
|
const { cdk, errorPage } = this.props;
|
|
411
387
|
const indexPage = this.props.indexPage || "index.html";
|
|
@@ -420,11 +396,7 @@ interface ImportMeta {
|
|
|
420
396
|
// these values can NOT be overwritten by cfDistributionProps
|
|
421
397
|
domainNames: this.buildDistributionDomainNames(),
|
|
422
398
|
certificate: this.certificate,
|
|
423
|
-
defaultBehavior:
|
|
424
|
-
origin: new S3Origin(this.bucket),
|
|
425
|
-
viewerProtocolPolicy: ViewerProtocolPolicy.REDIRECT_TO_HTTPS,
|
|
426
|
-
...cdk?.distribution?.defaultBehavior,
|
|
427
|
-
},
|
|
399
|
+
defaultBehavior: this.buildDistributionBehavior(),
|
|
428
400
|
});
|
|
429
401
|
}
|
|
430
402
|
createCloudFrontInvalidation(assets) {
|
|
@@ -462,6 +434,54 @@ interface ImportMeta {
|
|
|
462
434
|
resource.node.addDependency(policy);
|
|
463
435
|
return resource;
|
|
464
436
|
}
|
|
437
|
+
buildDistributionDomainNames() {
|
|
438
|
+
const { customDomain } = this.props;
|
|
439
|
+
const domainNames = [];
|
|
440
|
+
if (!customDomain) {
|
|
441
|
+
// no domain
|
|
442
|
+
}
|
|
443
|
+
else if (typeof customDomain === "string") {
|
|
444
|
+
domainNames.push(customDomain);
|
|
445
|
+
}
|
|
446
|
+
else {
|
|
447
|
+
domainNames.push(customDomain.domainName);
|
|
448
|
+
if (customDomain.alternateNames) {
|
|
449
|
+
if (!customDomain.cdk?.certificate)
|
|
450
|
+
throw new Error("Certificates for alternate domains cannot be automatically created. Please specify certificate to use");
|
|
451
|
+
domainNames.push(...customDomain.alternateNames);
|
|
452
|
+
}
|
|
453
|
+
}
|
|
454
|
+
return domainNames;
|
|
455
|
+
}
|
|
456
|
+
buildDistributionBehavior() {
|
|
457
|
+
const { cdk } = this.props;
|
|
458
|
+
return {
|
|
459
|
+
origin: new S3Origin(this.bucket),
|
|
460
|
+
viewerProtocolPolicy: ViewerProtocolPolicy.REDIRECT_TO_HTTPS,
|
|
461
|
+
functionAssociations: [
|
|
462
|
+
{
|
|
463
|
+
function: new CfFunction(this, "CloudFrontFunction", {
|
|
464
|
+
code: CfFunctionCode.fromInline(`
|
|
465
|
+
function handler(event) {
|
|
466
|
+
var request = event.request;
|
|
467
|
+
var uri = request.uri;
|
|
468
|
+
|
|
469
|
+
if (uri.endsWith("/")) {
|
|
470
|
+
request.uri += "index.html";
|
|
471
|
+
} else if (!uri.split("/").pop().includes(".")) {
|
|
472
|
+
request.uri += ".html";
|
|
473
|
+
}
|
|
474
|
+
|
|
475
|
+
return request;
|
|
476
|
+
}
|
|
477
|
+
`),
|
|
478
|
+
}),
|
|
479
|
+
eventType: CfFunctionEventType.VIEWER_REQUEST,
|
|
480
|
+
},
|
|
481
|
+
],
|
|
482
|
+
...cdk?.distribution?.defaultBehavior,
|
|
483
|
+
};
|
|
484
|
+
}
|
|
465
485
|
/////////////////////
|
|
466
486
|
// Custom Domain
|
|
467
487
|
/////////////////////
|
package/package.json
CHANGED
package/sst.mjs
CHANGED
|
@@ -4249,7 +4249,8 @@ var init_cloudformation_deployments_wrapper = __esm({
|
|
|
4249
4249
|
const state2 = /* @__PURE__ */ new Map();
|
|
4250
4250
|
return {
|
|
4251
4251
|
async get(sdkProvider, options) {
|
|
4252
|
-
|
|
4252
|
+
const region = options.stack.environment.region;
|
|
4253
|
+
if (!state2.has(region)) {
|
|
4253
4254
|
const deployment = new CloudFormationDeployments({ sdkProvider });
|
|
4254
4255
|
const { stackSdk, resolvedEnvironment, cloudFormationRoleArn } = await deployment.prepareSdkFor(options.stack, options.roleArn);
|
|
4255
4256
|
const toolkitInfo = await ToolkitInfo2.lookup(
|
|
@@ -4263,7 +4264,7 @@ var init_cloudformation_deployments_wrapper = __esm({
|
|
|
4263
4264
|
options.stack.bootstrapStackVersionSsmParameter,
|
|
4264
4265
|
toolkitInfo
|
|
4265
4266
|
);
|
|
4266
|
-
state2.set(
|
|
4267
|
+
state2.set(region, {
|
|
4267
4268
|
deployment,
|
|
4268
4269
|
toolkitInfo,
|
|
4269
4270
|
stackSdk,
|
|
@@ -4271,7 +4272,7 @@ var init_cloudformation_deployments_wrapper = __esm({
|
|
|
4271
4272
|
cloudFormationRoleArn
|
|
4272
4273
|
});
|
|
4273
4274
|
}
|
|
4274
|
-
return state2.get(
|
|
4275
|
+
return state2.get(region);
|
|
4275
4276
|
}
|
|
4276
4277
|
};
|
|
4277
4278
|
});
|
|
@@ -6319,7 +6320,7 @@ var init_kysely = __esm({
|
|
|
6319
6320
|
defaultDatabaseName: c.data.defaultDatabaseName,
|
|
6320
6321
|
secretArn: c.data.secretArn
|
|
6321
6322
|
}));
|
|
6322
|
-
databases.map((db) => generate2(db));
|
|
6323
|
+
databases.map((db) => generate2(db).catch());
|
|
6323
6324
|
});
|
|
6324
6325
|
bus.subscribe("function.success", async (evt) => {
|
|
6325
6326
|
if (!evt.properties.body?.results)
|
|
@@ -7789,4 +7790,10 @@ process.on("uncaughtException", (err) => {
|
|
|
7789
7790
|
});
|
|
7790
7791
|
process.on("beforeExit", () => {
|
|
7791
7792
|
});
|
|
7793
|
+
var nodeVersion = process.versions.node;
|
|
7794
|
+
if (Number(nodeVersion.split(".")[0]) < 16) {
|
|
7795
|
+
throw new VisibleError(
|
|
7796
|
+
`Node.js version ${nodeVersion} is not supported by SST. Please upgrade to Node.js 16 or later.`
|
|
7797
|
+
);
|
|
7798
|
+
}
|
|
7792
7799
|
program.parse();
|