sst 2.16.4 → 2.17.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/bootstrap.js +24 -15
- package/package.json +1 -1
- package/runtime/handlers/node.js +6 -4
- package/sst.mjs +22 -21
- package/support/bootstrap-metadata-function/index.mjs +390 -394
package/bootstrap.js
CHANGED
|
@@ -3,13 +3,11 @@ 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 { App, DefaultStackSynthesizer, CfnOutput,
|
|
6
|
+
import { App, DefaultStackSynthesizer, CfnOutput, Tags, Stack, RemovalPolicy, } from "aws-cdk-lib/core";
|
|
7
7
|
import { Function, Runtime, Code } from "aws-cdk-lib/aws-lambda";
|
|
8
|
-
import { SqsEventSource } from "aws-cdk-lib/aws-lambda-event-sources";
|
|
9
8
|
import { PolicyStatement } from "aws-cdk-lib/aws-iam";
|
|
10
|
-
import { Queue } from "aws-cdk-lib/aws-sqs";
|
|
11
9
|
import { Rule } from "aws-cdk-lib/aws-events";
|
|
12
|
-
import {
|
|
10
|
+
import { LambdaFunction } from "aws-cdk-lib/aws-events-targets";
|
|
13
11
|
import { BlockPublicAccess, Bucket, BucketEncryption, } from "aws-cdk-lib/aws-s3";
|
|
14
12
|
import { useProject } from "./project.js";
|
|
15
13
|
import { createSpinner } from "./cli/spinner.js";
|
|
@@ -22,7 +20,7 @@ const CDK_STACK_NAME = "CDKToolkit";
|
|
|
22
20
|
const SST_STACK_NAME = "SSTBootstrap";
|
|
23
21
|
const OUTPUT_VERSION = "Version";
|
|
24
22
|
const OUTPUT_BUCKET = "BucketName";
|
|
25
|
-
const LATEST_VERSION = "7";
|
|
23
|
+
const LATEST_VERSION = "7.1";
|
|
26
24
|
const __dirname = url.fileURLToPath(new URL(".", import.meta.url));
|
|
27
25
|
export const useBootstrap = Context.memo(async () => {
|
|
28
26
|
Logger.debug("Initializing bootstrap context");
|
|
@@ -32,7 +30,7 @@ export const useBootstrap = Context.memo(async () => {
|
|
|
32
30
|
]);
|
|
33
31
|
Logger.debug("Loaded bootstrap status");
|
|
34
32
|
const needToBootstrapCDK = !cdkStatus;
|
|
35
|
-
const needToBootstrapSST = !sstStatus
|
|
33
|
+
const needToBootstrapSST = !sstStatus;
|
|
36
34
|
if (needToBootstrapCDK || needToBootstrapSST) {
|
|
37
35
|
const spinner = createSpinner("Deploying bootstrap stack, this only needs to happen once").start();
|
|
38
36
|
if (needToBootstrapCDK) {
|
|
@@ -101,7 +99,8 @@ async function loadSSTStatus() {
|
|
|
101
99
|
throw e;
|
|
102
100
|
}
|
|
103
101
|
// Parse stack outputs
|
|
104
|
-
let version
|
|
102
|
+
let version;
|
|
103
|
+
let bucket;
|
|
105
104
|
(result.Stacks[0].Outputs || []).forEach((o) => {
|
|
106
105
|
if (o.OutputKey === OUTPUT_VERSION) {
|
|
107
106
|
version = o.OutputValue;
|
|
@@ -113,6 +112,22 @@ async function loadSSTStatus() {
|
|
|
113
112
|
if (!version || !bucket) {
|
|
114
113
|
return null;
|
|
115
114
|
}
|
|
115
|
+
// Need to update bootstrap stack:
|
|
116
|
+
// 1. If current MAJOR version < latest MAJOR version
|
|
117
|
+
// 2. If current MAJOR version > latest MAJOR version (has breaking change)
|
|
118
|
+
// 3. If current MAJOR version == latest MAJOR version,
|
|
119
|
+
// but current MINOR version < latest MINOR version
|
|
120
|
+
const latestParts = LATEST_VERSION.split(".");
|
|
121
|
+
const latestMajor = parseInt(latestParts[0]);
|
|
122
|
+
const latestMinor = parseInt(latestParts[1] || "0");
|
|
123
|
+
const currentParts = version.split(".");
|
|
124
|
+
const currentMajor = parseInt(currentParts[0]);
|
|
125
|
+
const currentMinor = parseInt(currentParts[1] || "0");
|
|
126
|
+
if (currentMajor < latestMajor ||
|
|
127
|
+
currentMajor > latestMajor ||
|
|
128
|
+
currentMinor < latestMinor) {
|
|
129
|
+
return null;
|
|
130
|
+
}
|
|
116
131
|
return { version, bucket };
|
|
117
132
|
}
|
|
118
133
|
export async function bootstrapSST() {
|
|
@@ -143,6 +158,7 @@ export async function bootstrapSST() {
|
|
|
143
158
|
encryption: BucketEncryption.S3_MANAGED,
|
|
144
159
|
removalPolicy: RemovalPolicy.DESTROY,
|
|
145
160
|
autoDeleteObjects: true,
|
|
161
|
+
enforceSSL: true,
|
|
146
162
|
blockPublicAccess: cdk?.publicAccessBlockConfiguration !== false
|
|
147
163
|
? BlockPublicAccess.BLOCK_ALL
|
|
148
164
|
: undefined,
|
|
@@ -174,11 +190,6 @@ export async function bootstrapSST() {
|
|
|
174
190
|
}),
|
|
175
191
|
],
|
|
176
192
|
});
|
|
177
|
-
const queue = new Queue(stack, "MetadataQueue", {
|
|
178
|
-
visibilityTimeout: Duration.seconds(30),
|
|
179
|
-
retentionPeriod: Duration.minutes(2),
|
|
180
|
-
});
|
|
181
|
-
fn.addEventSource(new SqsEventSource(queue));
|
|
182
193
|
const rule = new Rule(stack, "MetadataRule", {
|
|
183
194
|
eventPattern: {
|
|
184
195
|
source: ["aws.cloudformation"],
|
|
@@ -196,9 +207,7 @@ export async function bootstrapSST() {
|
|
|
196
207
|
},
|
|
197
208
|
},
|
|
198
209
|
});
|
|
199
|
-
rule.addTarget(new
|
|
200
|
-
retryAttempts: 10,
|
|
201
|
-
}));
|
|
210
|
+
rule.addTarget(new LambdaFunction(fn));
|
|
202
211
|
// Create stack outputs to store bootstrap stack info
|
|
203
212
|
new CfnOutput(stack, OUTPUT_VERSION, { value: LATEST_VERSION });
|
|
204
213
|
new CfnOutput(stack, OUTPUT_BUCKET, { value: bucket.bucketName });
|
package/package.json
CHANGED
package/runtime/handlers/node.js
CHANGED
|
@@ -186,11 +186,13 @@ export const useNodeHandler = Context.memo(async () => {
|
|
|
186
186
|
? "--arch=arm64"
|
|
187
187
|
: "--arch=x64");
|
|
188
188
|
}
|
|
189
|
-
await new Promise((resolve) => {
|
|
190
|
-
|
|
191
|
-
|
|
189
|
+
await new Promise((resolve, reject) => {
|
|
190
|
+
exec(cmd.join(" "), { cwd: input.out }, (error) => {
|
|
191
|
+
if (error) {
|
|
192
|
+
reject(error);
|
|
193
|
+
}
|
|
194
|
+
resolve();
|
|
192
195
|
});
|
|
193
|
-
process.on("exit", () => resolve());
|
|
194
196
|
});
|
|
195
197
|
}
|
|
196
198
|
if (input.mode === "start") {
|
package/sst.mjs
CHANGED
|
@@ -4517,11 +4517,13 @@ var init_node = __esm({
|
|
|
4517
4517
|
input.props.architecture === "arm_64" ? "--arch=arm64" : "--arch=x64"
|
|
4518
4518
|
);
|
|
4519
4519
|
}
|
|
4520
|
-
await new Promise((resolve) => {
|
|
4521
|
-
|
|
4522
|
-
|
|
4520
|
+
await new Promise((resolve, reject) => {
|
|
4521
|
+
exec2(cmd.join(" "), { cwd: input.out }, (error2) => {
|
|
4522
|
+
if (error2) {
|
|
4523
|
+
reject(error2);
|
|
4524
|
+
}
|
|
4525
|
+
resolve();
|
|
4523
4526
|
});
|
|
4524
|
-
process2.on("exit", () => resolve());
|
|
4525
4527
|
});
|
|
4526
4528
|
}
|
|
4527
4529
|
if (input.mode === "start") {
|
|
@@ -5362,17 +5364,14 @@ import {
|
|
|
5362
5364
|
App,
|
|
5363
5365
|
DefaultStackSynthesizer,
|
|
5364
5366
|
CfnOutput,
|
|
5365
|
-
Duration,
|
|
5366
5367
|
Tags,
|
|
5367
5368
|
Stack,
|
|
5368
5369
|
RemovalPolicy
|
|
5369
5370
|
} from "aws-cdk-lib/core";
|
|
5370
5371
|
import { Function, Runtime as Runtime2, Code } from "aws-cdk-lib/aws-lambda";
|
|
5371
|
-
import { SqsEventSource } from "aws-cdk-lib/aws-lambda-event-sources";
|
|
5372
5372
|
import { PolicyStatement } from "aws-cdk-lib/aws-iam";
|
|
5373
|
-
import { Queue } from "aws-cdk-lib/aws-sqs";
|
|
5374
5373
|
import { Rule } from "aws-cdk-lib/aws-events";
|
|
5375
|
-
import {
|
|
5374
|
+
import { LambdaFunction } from "aws-cdk-lib/aws-events-targets";
|
|
5376
5375
|
import {
|
|
5377
5376
|
BlockPublicAccess,
|
|
5378
5377
|
Bucket,
|
|
@@ -5422,7 +5421,8 @@ async function loadSSTStatus() {
|
|
|
5422
5421
|
}
|
|
5423
5422
|
throw e;
|
|
5424
5423
|
}
|
|
5425
|
-
let version2
|
|
5424
|
+
let version2;
|
|
5425
|
+
let bucket;
|
|
5426
5426
|
(result.Stacks[0].Outputs || []).forEach((o) => {
|
|
5427
5427
|
if (o.OutputKey === OUTPUT_VERSION) {
|
|
5428
5428
|
version2 = o.OutputValue;
|
|
@@ -5433,6 +5433,15 @@ async function loadSSTStatus() {
|
|
|
5433
5433
|
if (!version2 || !bucket) {
|
|
5434
5434
|
return null;
|
|
5435
5435
|
}
|
|
5436
|
+
const latestParts = LATEST_VERSION.split(".");
|
|
5437
|
+
const latestMajor = parseInt(latestParts[0]);
|
|
5438
|
+
const latestMinor = parseInt(latestParts[1] || "0");
|
|
5439
|
+
const currentParts = version2.split(".");
|
|
5440
|
+
const currentMajor = parseInt(currentParts[0]);
|
|
5441
|
+
const currentMinor = parseInt(currentParts[1] || "0");
|
|
5442
|
+
if (currentMajor < latestMajor || currentMajor > latestMajor || currentMinor < latestMinor) {
|
|
5443
|
+
return null;
|
|
5444
|
+
}
|
|
5436
5445
|
return { version: version2, bucket };
|
|
5437
5446
|
}
|
|
5438
5447
|
async function bootstrapSST() {
|
|
@@ -5460,6 +5469,7 @@ async function bootstrapSST() {
|
|
|
5460
5469
|
encryption: BucketEncryption.S3_MANAGED,
|
|
5461
5470
|
removalPolicy: RemovalPolicy.DESTROY,
|
|
5462
5471
|
autoDeleteObjects: true,
|
|
5472
|
+
enforceSSL: true,
|
|
5463
5473
|
blockPublicAccess: cdk?.publicAccessBlockConfiguration !== false ? BlockPublicAccess.BLOCK_ALL : void 0
|
|
5464
5474
|
});
|
|
5465
5475
|
const fn = new Function(stack, "MetadataHandler", {
|
|
@@ -5488,11 +5498,6 @@ async function bootstrapSST() {
|
|
|
5488
5498
|
})
|
|
5489
5499
|
]
|
|
5490
5500
|
});
|
|
5491
|
-
const queue = new Queue(stack, "MetadataQueue", {
|
|
5492
|
-
visibilityTimeout: Duration.seconds(30),
|
|
5493
|
-
retentionPeriod: Duration.minutes(2)
|
|
5494
|
-
});
|
|
5495
|
-
fn.addEventSource(new SqsEventSource(queue));
|
|
5496
5501
|
const rule = new Rule(stack, "MetadataRule", {
|
|
5497
5502
|
eventPattern: {
|
|
5498
5503
|
source: ["aws.cloudformation"],
|
|
@@ -5510,11 +5515,7 @@ async function bootstrapSST() {
|
|
|
5510
5515
|
}
|
|
5511
5516
|
}
|
|
5512
5517
|
});
|
|
5513
|
-
rule.addTarget(
|
|
5514
|
-
new SqsQueue(queue, {
|
|
5515
|
-
retryAttempts: 10
|
|
5516
|
-
})
|
|
5517
|
-
);
|
|
5518
|
+
rule.addTarget(new LambdaFunction(fn));
|
|
5518
5519
|
new CfnOutput(stack, OUTPUT_VERSION, { value: LATEST_VERSION });
|
|
5519
5520
|
new CfnOutput(stack, OUTPUT_BUCKET, { value: bucket.bucketName });
|
|
5520
5521
|
const asm = app.synth();
|
|
@@ -5595,7 +5596,7 @@ var init_bootstrap = __esm({
|
|
|
5595
5596
|
SST_STACK_NAME = "SSTBootstrap";
|
|
5596
5597
|
OUTPUT_VERSION = "Version";
|
|
5597
5598
|
OUTPUT_BUCKET = "BucketName";
|
|
5598
|
-
LATEST_VERSION = "7";
|
|
5599
|
+
LATEST_VERSION = "7.1";
|
|
5599
5600
|
__dirname2 = url8.fileURLToPath(new URL(".", import.meta.url));
|
|
5600
5601
|
useBootstrap = Context.memo(async () => {
|
|
5601
5602
|
Logger.debug("Initializing bootstrap context");
|
|
@@ -5605,7 +5606,7 @@ var init_bootstrap = __esm({
|
|
|
5605
5606
|
]);
|
|
5606
5607
|
Logger.debug("Loaded bootstrap status");
|
|
5607
5608
|
const needToBootstrapCDK = !cdkStatus;
|
|
5608
|
-
const needToBootstrapSST = !sstStatus
|
|
5609
|
+
const needToBootstrapSST = !sstStatus;
|
|
5609
5610
|
if (needToBootstrapCDK || needToBootstrapSST) {
|
|
5610
5611
|
const spinner = createSpinner(
|
|
5611
5612
|
"Deploying bootstrap stack, this only needs to happen once"
|