sst 2.0.15 → 2.0.17
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/bootstrap.js +6 -4
- package/constructs/Auth.js +12 -10
- package/constructs/EdgeFunction.js +11 -9
- package/constructs/SsrFunction.js +11 -9
- package/constructs/SsrSite.js +14 -12
- package/constructs/StaticSite.js +14 -12
- package/package.json +1 -1
- package/runtime/handlers/python.js +1 -0
- package/sst.mjs +18 -8
package/bootstrap.js
CHANGED
|
@@ -3,7 +3,7 @@ import path from "path";
|
|
|
3
3
|
import { bold, dim } from "colorette";
|
|
4
4
|
import { spawn } from "child_process";
|
|
5
5
|
import { DescribeStacksCommand, CloudFormationClient, } from "@aws-sdk/client-cloudformation";
|
|
6
|
-
import { Tags, Stack, RemovalPolicy, App, CfnOutput } from "aws-cdk-lib";
|
|
6
|
+
import { Duration, Tags, Stack, RemovalPolicy, App, CfnOutput, } from "aws-cdk-lib";
|
|
7
7
|
import { Function, Runtime, Code } from "aws-cdk-lib/aws-lambda";
|
|
8
8
|
import { SqsEventSource } from "aws-cdk-lib/aws-lambda-event-sources";
|
|
9
9
|
import { PolicyStatement } from "aws-cdk-lib/aws-iam";
|
|
@@ -21,7 +21,7 @@ import { Stacks } from "./stacks/index.js";
|
|
|
21
21
|
const STACK_NAME = "SSTBootstrap";
|
|
22
22
|
const OUTPUT_VERSION = "Version";
|
|
23
23
|
const OUTPUT_BUCKET = "BucketName";
|
|
24
|
-
const LATEST_VERSION = "
|
|
24
|
+
const LATEST_VERSION = "7";
|
|
25
25
|
const __dirname = url.fileURLToPath(new URL(".", import.meta.url));
|
|
26
26
|
export const useBootstrap = Context.memo(async () => {
|
|
27
27
|
Logger.debug("Initializing bootstrap context");
|
|
@@ -80,7 +80,6 @@ async function loadCDKStatus() {
|
|
|
80
80
|
throw e;
|
|
81
81
|
}
|
|
82
82
|
}
|
|
83
|
-
return false;
|
|
84
83
|
}
|
|
85
84
|
export async function bootstrapSST(tags) {
|
|
86
85
|
// Create bootstrap stack
|
|
@@ -127,7 +126,10 @@ export async function bootstrapSST(tags) {
|
|
|
127
126
|
}),
|
|
128
127
|
],
|
|
129
128
|
});
|
|
130
|
-
const queue = new Queue(stack, "MetadataQueue"
|
|
129
|
+
const queue = new Queue(stack, "MetadataQueue", {
|
|
130
|
+
visibilityTimeout: Duration.seconds(30),
|
|
131
|
+
retentionPeriod: Duration.minutes(2),
|
|
132
|
+
});
|
|
131
133
|
fn.addEventSource(new SqsEventSource(queue));
|
|
132
134
|
const rule = new Rule(stack, "MetadataRule", {
|
|
133
135
|
eventPattern: {
|
package/constructs/Auth.js
CHANGED
|
@@ -37,15 +37,7 @@ export class Auth extends Construct {
|
|
|
37
37
|
this.id = id;
|
|
38
38
|
const stack = Stack.of(scope);
|
|
39
39
|
this.authenticator = props.authenticator;
|
|
40
|
-
new
|
|
41
|
-
serviceToken: stack.customResourceHandler.functionArn,
|
|
42
|
-
resourceType: "Custom::AuthKeys",
|
|
43
|
-
properties: {
|
|
44
|
-
publicPath: getParameterPath(this, PUBLIC_KEY_PROP),
|
|
45
|
-
privatePath: getParameterPath(this, PRIVATE_KEY_PROP),
|
|
46
|
-
},
|
|
47
|
-
});
|
|
48
|
-
stack.customResourceHandler.role?.attachInlinePolicy(new Policy(this, "CloudFrontInvalidatorPolicy", {
|
|
40
|
+
const policy = new Policy(this, "CloudFrontInvalidatorPolicy", {
|
|
49
41
|
statements: [
|
|
50
42
|
new PolicyStatement({
|
|
51
43
|
actions: [
|
|
@@ -58,7 +50,17 @@ export class Auth extends Construct {
|
|
|
58
50
|
],
|
|
59
51
|
}),
|
|
60
52
|
],
|
|
61
|
-
})
|
|
53
|
+
});
|
|
54
|
+
stack.customResourceHandler.role?.attachInlinePolicy(policy);
|
|
55
|
+
const resource = new CustomResource(this, "StackMetadata", {
|
|
56
|
+
serviceToken: stack.customResourceHandler.functionArn,
|
|
57
|
+
resourceType: "Custom::AuthKeys",
|
|
58
|
+
properties: {
|
|
59
|
+
publicPath: getParameterPath(this, PUBLIC_KEY_PROP),
|
|
60
|
+
privatePath: getParameterPath(this, PRIVATE_KEY_PROP),
|
|
61
|
+
},
|
|
62
|
+
});
|
|
63
|
+
resource.node.addDependency(policy);
|
|
62
64
|
}
|
|
63
65
|
/** @internal */
|
|
64
66
|
getConstructMetadata() {
|
|
@@ -150,6 +150,16 @@ ${exports}
|
|
|
150
150
|
// They need to be replaced with real values before the Lambda
|
|
151
151
|
// functions get deployed.
|
|
152
152
|
const stack = Stack.of(this);
|
|
153
|
+
const policy = new Policy(this, "AssetReplacerPolicy", {
|
|
154
|
+
statements: [
|
|
155
|
+
new PolicyStatement({
|
|
156
|
+
effect: Effect.ALLOW,
|
|
157
|
+
actions: ["s3:GetObject", "s3:PutObject"],
|
|
158
|
+
resources: [`arn:${stack.partition}:s3:::${asset.s3BucketName}/*`],
|
|
159
|
+
}),
|
|
160
|
+
],
|
|
161
|
+
});
|
|
162
|
+
stack.customResourceHandler.role?.attachInlinePolicy(policy);
|
|
153
163
|
const resource = new CustomResource(this.scope, "AssetReplacer", {
|
|
154
164
|
serviceToken: stack.customResourceHandler.functionArn,
|
|
155
165
|
resourceType: "Custom::AssetReplacer",
|
|
@@ -159,15 +169,7 @@ ${exports}
|
|
|
159
169
|
replacements: this.getLambdaContentReplaceValues(),
|
|
160
170
|
},
|
|
161
171
|
});
|
|
162
|
-
|
|
163
|
-
statements: [
|
|
164
|
-
new PolicyStatement({
|
|
165
|
-
effect: Effect.ALLOW,
|
|
166
|
-
actions: ["s3:GetObject", "s3:PutObject"],
|
|
167
|
-
resources: [`arn:${stack.partition}:s3:::${asset.s3BucketName}/*`],
|
|
168
|
-
}),
|
|
169
|
-
],
|
|
170
|
-
}));
|
|
172
|
+
resource.node.addDependency(policy);
|
|
171
173
|
return resource;
|
|
172
174
|
}
|
|
173
175
|
createSingletonBucketCR() {
|
|
@@ -78,6 +78,16 @@ export class SsrFunction extends Construct {
|
|
|
78
78
|
// They need to be replaced with real values before the Lambda
|
|
79
79
|
// functions get deployed.
|
|
80
80
|
const stack = Stack.of(this);
|
|
81
|
+
const policy = new Policy(this, "AssetReplacerPolicy", {
|
|
82
|
+
statements: [
|
|
83
|
+
new PolicyStatement({
|
|
84
|
+
effect: Effect.ALLOW,
|
|
85
|
+
actions: ["s3:GetObject", "s3:PutObject"],
|
|
86
|
+
resources: [`arn:${stack.partition}:s3:::${asset.s3BucketName}/*`],
|
|
87
|
+
}),
|
|
88
|
+
],
|
|
89
|
+
});
|
|
90
|
+
stack.customResourceHandler.role?.attachInlinePolicy(policy);
|
|
81
91
|
const resource = new CustomResource(this, "AssetReplacer", {
|
|
82
92
|
serviceToken: stack.customResourceHandler.functionArn,
|
|
83
93
|
resourceType: "Custom::AssetReplacer",
|
|
@@ -87,15 +97,7 @@ export class SsrFunction extends Construct {
|
|
|
87
97
|
replacements: this.getLambdaContentReplaceValues(),
|
|
88
98
|
},
|
|
89
99
|
});
|
|
90
|
-
|
|
91
|
-
statements: [
|
|
92
|
-
new PolicyStatement({
|
|
93
|
-
effect: Effect.ALLOW,
|
|
94
|
-
actions: ["s3:GetObject", "s3:PutObject"],
|
|
95
|
-
resources: [`arn:${stack.partition}:s3:::${asset.s3BucketName}/*`],
|
|
96
|
-
}),
|
|
97
|
-
],
|
|
98
|
-
}));
|
|
100
|
+
resource.node.addDependency(policy);
|
|
99
101
|
return resource;
|
|
100
102
|
}
|
|
101
103
|
getLambdaContentReplaceValues() {
|
package/constructs/SsrSite.js
CHANGED
|
@@ -552,17 +552,7 @@ export class SsrSite extends Construct {
|
|
|
552
552
|
}
|
|
553
553
|
createCloudFrontInvalidation() {
|
|
554
554
|
const stack = Stack.of(this);
|
|
555
|
-
const
|
|
556
|
-
serviceToken: stack.customResourceHandler.functionArn,
|
|
557
|
-
resourceType: "Custom::CloudFrontInvalidator",
|
|
558
|
-
properties: {
|
|
559
|
-
buildId: this.generateBuildId(),
|
|
560
|
-
distributionId: this.distribution.distributionId,
|
|
561
|
-
paths: ["/*"],
|
|
562
|
-
waitForInvalidation: this.props.waitForInvalidation,
|
|
563
|
-
},
|
|
564
|
-
});
|
|
565
|
-
stack.customResourceHandler.role?.attachInlinePolicy(new Policy(this, "CloudFrontInvalidatorPolicy", {
|
|
555
|
+
const policy = new Policy(this, "CloudFrontInvalidatorPolicy", {
|
|
566
556
|
statements: [
|
|
567
557
|
new PolicyStatement({
|
|
568
558
|
effect: Effect.ALLOW,
|
|
@@ -575,7 +565,19 @@ export class SsrSite extends Construct {
|
|
|
575
565
|
],
|
|
576
566
|
}),
|
|
577
567
|
],
|
|
578
|
-
})
|
|
568
|
+
});
|
|
569
|
+
stack.customResourceHandler.role?.attachInlinePolicy(policy);
|
|
570
|
+
const resource = new CustomResource(this, "CloudFrontInvalidator", {
|
|
571
|
+
serviceToken: stack.customResourceHandler.functionArn,
|
|
572
|
+
resourceType: "Custom::CloudFrontInvalidator",
|
|
573
|
+
properties: {
|
|
574
|
+
buildId: this.generateBuildId(),
|
|
575
|
+
distributionId: this.distribution.distributionId,
|
|
576
|
+
paths: ["/*"],
|
|
577
|
+
waitForInvalidation: this.props.waitForInvalidation,
|
|
578
|
+
},
|
|
579
|
+
});
|
|
580
|
+
resource.node.addDependency(policy);
|
|
579
581
|
return resource;
|
|
580
582
|
}
|
|
581
583
|
/////////////////////
|
package/constructs/StaticSite.js
CHANGED
|
@@ -427,17 +427,7 @@ interface ImportMeta {
|
|
|
427
427
|
.createHash("md5")
|
|
428
428
|
.update(assets.map(({ assetHash }) => assetHash).join(""))
|
|
429
429
|
.digest("hex");
|
|
430
|
-
const
|
|
431
|
-
serviceToken: stack.customResourceHandler.functionArn,
|
|
432
|
-
resourceType: "Custom::CloudFrontInvalidator",
|
|
433
|
-
properties: {
|
|
434
|
-
assetsHash,
|
|
435
|
-
distributionId: this.distribution.distributionId,
|
|
436
|
-
paths: ["/*"],
|
|
437
|
-
waitForInvalidation: this.props.waitForInvalidation,
|
|
438
|
-
},
|
|
439
|
-
});
|
|
440
|
-
stack.customResourceHandler.role?.attachInlinePolicy(new Policy(this, "CloudFrontInvalidatorPolicy", {
|
|
430
|
+
const policy = new Policy(this, "CloudFrontInvalidatorPolicy", {
|
|
441
431
|
statements: [
|
|
442
432
|
new PolicyStatement({
|
|
443
433
|
effect: Effect.ALLOW,
|
|
@@ -450,7 +440,19 @@ interface ImportMeta {
|
|
|
450
440
|
],
|
|
451
441
|
}),
|
|
452
442
|
],
|
|
453
|
-
})
|
|
443
|
+
});
|
|
444
|
+
stack.customResourceHandler.role?.attachInlinePolicy(policy);
|
|
445
|
+
const resource = new CustomResource(this, "CloudFrontInvalidator", {
|
|
446
|
+
serviceToken: stack.customResourceHandler.functionArn,
|
|
447
|
+
resourceType: "Custom::CloudFrontInvalidator",
|
|
448
|
+
properties: {
|
|
449
|
+
assetsHash,
|
|
450
|
+
distributionId: this.distribution.distributionId,
|
|
451
|
+
paths: ["/*"],
|
|
452
|
+
waitForInvalidation: this.props.waitForInvalidation,
|
|
453
|
+
},
|
|
454
|
+
});
|
|
455
|
+
resource.node.addDependency(policy);
|
|
454
456
|
return resource;
|
|
455
457
|
}
|
|
456
458
|
/////////////////////
|
package/package.json
CHANGED
|
@@ -78,6 +78,7 @@ export const usePythonHandler = Context.memo(async () => {
|
|
|
78
78
|
const src = await findAbove(input.props.handler, "requirements.txt");
|
|
79
79
|
await fs.cp(src, input.out, {
|
|
80
80
|
recursive: true,
|
|
81
|
+
filter: (src) => !src.includes(".sst"),
|
|
81
82
|
});
|
|
82
83
|
if (input.props.python?.installCommands) {
|
|
83
84
|
for (const cmd of input.props.python.installCommands) {
|
package/sst.mjs
CHANGED
|
@@ -2627,7 +2627,14 @@ import {
|
|
|
2627
2627
|
DescribeStacksCommand,
|
|
2628
2628
|
CloudFormationClient
|
|
2629
2629
|
} from "@aws-sdk/client-cloudformation";
|
|
2630
|
-
import {
|
|
2630
|
+
import {
|
|
2631
|
+
Duration,
|
|
2632
|
+
Tags,
|
|
2633
|
+
Stack,
|
|
2634
|
+
RemovalPolicy,
|
|
2635
|
+
App,
|
|
2636
|
+
CfnOutput
|
|
2637
|
+
} from "aws-cdk-lib";
|
|
2631
2638
|
import { Function, Runtime, Code } from "aws-cdk-lib/aws-lambda";
|
|
2632
2639
|
import { SqsEventSource } from "aws-cdk-lib/aws-lambda-event-sources";
|
|
2633
2640
|
import { PolicyStatement } from "aws-cdk-lib/aws-iam";
|
|
@@ -2665,7 +2672,6 @@ async function loadCDKStatus() {
|
|
|
2665
2672
|
throw e;
|
|
2666
2673
|
}
|
|
2667
2674
|
}
|
|
2668
|
-
return false;
|
|
2669
2675
|
}
|
|
2670
2676
|
async function bootstrapSST(tags) {
|
|
2671
2677
|
const project = useProject();
|
|
@@ -2710,7 +2716,10 @@ async function bootstrapSST(tags) {
|
|
|
2710
2716
|
})
|
|
2711
2717
|
]
|
|
2712
2718
|
});
|
|
2713
|
-
const queue = new Queue(stack, "MetadataQueue"
|
|
2719
|
+
const queue = new Queue(stack, "MetadataQueue", {
|
|
2720
|
+
visibilityTimeout: Duration.seconds(30),
|
|
2721
|
+
retentionPeriod: Duration.minutes(2)
|
|
2722
|
+
});
|
|
2714
2723
|
fn.addEventSource(new SqsEventSource(queue));
|
|
2715
2724
|
const rule = new Rule(stack, "MetadataRule", {
|
|
2716
2725
|
eventPattern: {
|
|
@@ -2836,7 +2845,7 @@ var init_bootstrap = __esm({
|
|
|
2836
2845
|
STACK_NAME = "SSTBootstrap";
|
|
2837
2846
|
OUTPUT_VERSION = "Version";
|
|
2838
2847
|
OUTPUT_BUCKET = "BucketName";
|
|
2839
|
-
LATEST_VERSION = "
|
|
2848
|
+
LATEST_VERSION = "7";
|
|
2840
2849
|
__dirname = url3.fileURLToPath(new URL(".", import.meta.url));
|
|
2841
2850
|
useBootstrap = Context.memo(async () => {
|
|
2842
2851
|
Logger.debug("Initializing bootstrap context");
|
|
@@ -5132,7 +5141,8 @@ var init_python = __esm({
|
|
|
5132
5141
|
};
|
|
5133
5142
|
const src = await findAbove(input.props.handler, "requirements.txt");
|
|
5134
5143
|
await fs12.cp(src, input.out, {
|
|
5135
|
-
recursive: true
|
|
5144
|
+
recursive: true,
|
|
5145
|
+
filter: (src2) => !src2.includes(".sst")
|
|
5136
5146
|
});
|
|
5137
5147
|
if (input.props.python?.installCommands) {
|
|
5138
5148
|
for (const cmd of input.props.python.installCommands) {
|
|
@@ -6260,7 +6270,7 @@ var init_config = __esm({
|
|
|
6260
6270
|
});
|
|
6261
6271
|
|
|
6262
6272
|
// src/cli/sst.ts
|
|
6263
|
-
import { blue as blue3, red
|
|
6273
|
+
import { blue as blue3, red } from "colorette";
|
|
6264
6274
|
|
|
6265
6275
|
// src/cli/program.ts
|
|
6266
6276
|
import yargs from "yargs";
|
|
@@ -6927,7 +6937,7 @@ var get = (program2) => program2.command(
|
|
|
6927
6937
|
describe: "Get the fallback value"
|
|
6928
6938
|
}),
|
|
6929
6939
|
async (args) => {
|
|
6930
|
-
const { red:
|
|
6940
|
+
const { red: red2 } = await import("colorette");
|
|
6931
6941
|
const { Config: Config2 } = await Promise.resolve().then(() => (init_config(), config_exports));
|
|
6932
6942
|
const { Colors: Colors2 } = await Promise.resolve().then(() => (init_colors(), colors_exports));
|
|
6933
6943
|
try {
|
|
@@ -7428,7 +7438,7 @@ process.on("uncaughtException", (err) => {
|
|
|
7428
7438
|
if (spinner.isSpinning)
|
|
7429
7439
|
spinner.fail(spinner.text);
|
|
7430
7440
|
}
|
|
7431
|
-
console.log(
|
|
7441
|
+
console.log(red("Error:"), err.message);
|
|
7432
7442
|
if (!(err instanceof VisibleError)) {
|
|
7433
7443
|
console.log();
|
|
7434
7444
|
console.trace(err.stack);
|