sst 2.1.28 → 2.1.30
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.d.ts +1 -1
- package/bootstrap.js +64 -50
- package/cli/sst.js +0 -2
- package/constructs/Api.d.ts +1 -1
- package/constructs/Stack.d.ts +1 -0
- package/constructs/Stack.js +13 -0
- package/package.json +1 -1
- package/project.d.ts +10 -0
- package/project.js +2 -0
- package/sst.mjs +70 -111
- package/cli/commands/bootstrap.d.ts +0 -19
- package/cli/commands/bootstrap.js +0 -31
package/bootstrap.d.ts
CHANGED
|
@@ -2,4 +2,4 @@ export declare const useBootstrap: () => Promise<{
|
|
|
2
2
|
version: string;
|
|
3
3
|
bucket: string;
|
|
4
4
|
}>;
|
|
5
|
-
export declare function bootstrapSST(
|
|
5
|
+
export declare function bootstrapSST(): Promise<void>;
|
package/bootstrap.js
CHANGED
|
@@ -18,7 +18,8 @@ import { useAWSClient, useAWSCredentials, useSTSIdentity, } from "./credentials.
|
|
|
18
18
|
import { VisibleError } from "./error.js";
|
|
19
19
|
import { Logger } from "./logger.js";
|
|
20
20
|
import { Stacks } from "./stacks/index.js";
|
|
21
|
-
const
|
|
21
|
+
const CDK_STACK_NAME = "CDKToolkit";
|
|
22
|
+
const SST_STACK_NAME = "SSTBootstrap";
|
|
22
23
|
const OUTPUT_VERSION = "Version";
|
|
23
24
|
const OUTPUT_BUCKET = "BucketName";
|
|
24
25
|
const LATEST_VERSION = "7";
|
|
@@ -50,11 +51,11 @@ export const useBootstrap = Context.memo(async () => {
|
|
|
50
51
|
return sstStatus;
|
|
51
52
|
}, "Bootstrap");
|
|
52
53
|
async function loadCDKStatus() {
|
|
54
|
+
const { cdk } = useProject().config;
|
|
53
55
|
const client = useAWSClient(CloudFormationClient);
|
|
56
|
+
const stackName = cdk?.toolkitStackName || CDK_STACK_NAME;
|
|
54
57
|
try {
|
|
55
|
-
const { Stacks: stacks } = await client.send(new DescribeStacksCommand({
|
|
56
|
-
StackName: "CDKToolkit",
|
|
57
|
-
}));
|
|
58
|
+
const { Stacks: stacks } = await client.send(new DescribeStacksCommand({ StackName: stackName }));
|
|
58
59
|
// Check CDK bootstrap stack exists
|
|
59
60
|
if (!stacks || stacks.length === 0)
|
|
60
61
|
return false;
|
|
@@ -73,7 +74,7 @@ async function loadCDKStatus() {
|
|
|
73
74
|
}
|
|
74
75
|
catch (e) {
|
|
75
76
|
if (e.name === "ValidationError" &&
|
|
76
|
-
e.message ===
|
|
77
|
+
e.message === `Stack with id ${stackName} does not exist`) {
|
|
77
78
|
return false;
|
|
78
79
|
}
|
|
79
80
|
else {
|
|
@@ -81,32 +82,63 @@ async function loadCDKStatus() {
|
|
|
81
82
|
}
|
|
82
83
|
}
|
|
83
84
|
}
|
|
84
|
-
|
|
85
|
-
//
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
85
|
+
async function loadSSTStatus() {
|
|
86
|
+
// Get bootstrap CloudFormation stack
|
|
87
|
+
const { bootstrap } = useProject().config;
|
|
88
|
+
const cf = useAWSClient(CloudFormationClient);
|
|
89
|
+
const stackName = bootstrap?.stackName || SST_STACK_NAME;
|
|
90
|
+
let result;
|
|
91
|
+
try {
|
|
92
|
+
result = await cf.send(new DescribeStacksCommand({
|
|
93
|
+
StackName: stackName,
|
|
94
|
+
}));
|
|
95
|
+
}
|
|
96
|
+
catch (e) {
|
|
97
|
+
if (e.Code === "ValidationError" &&
|
|
98
|
+
e.message === `Stack with id ${stackName} does not exist`) {
|
|
99
|
+
return null;
|
|
100
|
+
}
|
|
101
|
+
throw e;
|
|
102
|
+
}
|
|
103
|
+
// Parse stack outputs
|
|
104
|
+
let version, bucket;
|
|
105
|
+
(result.Stacks[0].Outputs || []).forEach((o) => {
|
|
106
|
+
if (o.OutputKey === OUTPUT_VERSION) {
|
|
107
|
+
version = o.OutputValue;
|
|
108
|
+
}
|
|
109
|
+
else if (o.OutputKey === OUTPUT_BUCKET) {
|
|
110
|
+
bucket = o.OutputValue;
|
|
111
|
+
}
|
|
112
|
+
});
|
|
113
|
+
if (!version || !bucket) {
|
|
114
|
+
return null;
|
|
115
|
+
}
|
|
116
|
+
return { version, bucket };
|
|
117
|
+
}
|
|
118
|
+
export async function bootstrapSST() {
|
|
119
|
+
const { region, bootstrap, cdk } = useProject().config;
|
|
89
120
|
// Create bootstrap stack
|
|
90
|
-
const project = useProject();
|
|
91
121
|
const app = new App();
|
|
92
|
-
const
|
|
122
|
+
const stackName = bootstrap?.stackName || SST_STACK_NAME;
|
|
123
|
+
const stack = new Stack(app, stackName, {
|
|
93
124
|
env: {
|
|
94
|
-
region
|
|
125
|
+
region,
|
|
95
126
|
},
|
|
96
127
|
synthesizer: new DefaultStackSynthesizer({
|
|
97
|
-
qualifier,
|
|
128
|
+
qualifier: cdk?.qualifier,
|
|
129
|
+
fileAssetsBucketName: cdk?.fileAssetsBucketName,
|
|
98
130
|
}),
|
|
99
131
|
});
|
|
100
132
|
// Add tags to stack
|
|
101
|
-
for (const [key, value] of Object.entries(tags)) {
|
|
133
|
+
for (const [key, value] of Object.entries(bootstrap?.tags || {})) {
|
|
102
134
|
Tags.of(app).add(key, value);
|
|
103
135
|
}
|
|
104
136
|
// Create S3 bucket to store stacks metadata
|
|
105
|
-
const bucket = new Bucket(stack,
|
|
137
|
+
const bucket = new Bucket(stack, region, {
|
|
106
138
|
encryption: BucketEncryption.S3_MANAGED,
|
|
107
139
|
removalPolicy: RemovalPolicy.DESTROY,
|
|
108
140
|
autoDeleteObjects: true,
|
|
109
|
-
blockPublicAccess: publicAccessBlockConfiguration
|
|
141
|
+
blockPublicAccess: cdk?.publicAccessBlockConfiguration !== false
|
|
110
142
|
? BlockPublicAccess.BLOCK_ALL
|
|
111
143
|
: undefined,
|
|
112
144
|
});
|
|
@@ -114,7 +146,7 @@ export async function bootstrapSST(tags, publicAccessBlockConfiguration, qualifi
|
|
|
114
146
|
const fn = new Function(stack, "MetadataHandler", {
|
|
115
147
|
code: Code.fromAsset(path.resolve(__dirname, "support/bootstrap-metadata-function")),
|
|
116
148
|
handler: "index.handler",
|
|
117
|
-
runtime:
|
|
149
|
+
runtime: region?.startsWith("us-gov-")
|
|
118
150
|
? Runtime.NODEJS_16_X
|
|
119
151
|
: Runtime.NODEJS_18_X,
|
|
120
152
|
environment: {
|
|
@@ -175,7 +207,8 @@ export async function bootstrapSST(tags, publicAccessBlockConfiguration, qualifi
|
|
|
175
207
|
async function bootstrapCDK() {
|
|
176
208
|
const identity = await useSTSIdentity();
|
|
177
209
|
const credentials = await useAWSCredentials();
|
|
178
|
-
const { region, profile } = useProject().config;
|
|
210
|
+
const { region, profile, cdk } = useProject().config;
|
|
211
|
+
cdk || {};
|
|
179
212
|
await new Promise((resolve, reject) => {
|
|
180
213
|
const proc = spawn([
|
|
181
214
|
"npx",
|
|
@@ -183,6 +216,18 @@ async function bootstrapCDK() {
|
|
|
183
216
|
"bootstrap",
|
|
184
217
|
`aws://${identity.Account}/${region}`,
|
|
185
218
|
"--no-version-reporting",
|
|
219
|
+
...(cdk?.publicAccessBlockConfiguration === false
|
|
220
|
+
? ["--public-access-block-configuration", "false"]
|
|
221
|
+
: cdk?.publicAccessBlockConfiguration === true
|
|
222
|
+
? ["--public-access-block-configuration", "false"]
|
|
223
|
+
: []),
|
|
224
|
+
...(cdk?.toolkitStackName
|
|
225
|
+
? ["--toolkit-stack-name", cdk.toolkitStackName]
|
|
226
|
+
: []),
|
|
227
|
+
...(cdk?.qualifier ? ["--qualifier", cdk.qualifier] : []),
|
|
228
|
+
...(cdk?.fileAssetsBucketName
|
|
229
|
+
? ["--toolkit-bucket-name", cdk.fileAssetsBucketName]
|
|
230
|
+
: []),
|
|
186
231
|
].join(" "), {
|
|
187
232
|
env: {
|
|
188
233
|
...process.env,
|
|
@@ -215,34 +260,3 @@ async function bootstrapCDK() {
|
|
|
215
260
|
});
|
|
216
261
|
});
|
|
217
262
|
}
|
|
218
|
-
async function loadSSTStatus() {
|
|
219
|
-
// Get bootstrap CloudFormation stack
|
|
220
|
-
const cf = useAWSClient(CloudFormationClient);
|
|
221
|
-
let result;
|
|
222
|
-
try {
|
|
223
|
-
result = await cf.send(new DescribeStacksCommand({
|
|
224
|
-
StackName: STACK_NAME,
|
|
225
|
-
}));
|
|
226
|
-
}
|
|
227
|
-
catch (e) {
|
|
228
|
-
if (e.Code === "ValidationError" &&
|
|
229
|
-
e.message === `Stack with id ${STACK_NAME} does not exist`) {
|
|
230
|
-
return null;
|
|
231
|
-
}
|
|
232
|
-
throw e;
|
|
233
|
-
}
|
|
234
|
-
// Parse stack outputs
|
|
235
|
-
let version, bucket;
|
|
236
|
-
(result.Stacks[0].Outputs || []).forEach((o) => {
|
|
237
|
-
if (o.OutputKey === OUTPUT_VERSION) {
|
|
238
|
-
version = o.OutputValue;
|
|
239
|
-
}
|
|
240
|
-
else if (o.OutputKey === OUTPUT_BUCKET) {
|
|
241
|
-
bucket = o.OutputValue;
|
|
242
|
-
}
|
|
243
|
-
});
|
|
244
|
-
if (!version || !bucket) {
|
|
245
|
-
return null;
|
|
246
|
-
}
|
|
247
|
-
return { version, bucket };
|
|
248
|
-
}
|
package/cli/sst.js
CHANGED
|
@@ -25,7 +25,6 @@ import { transform } from "./commands/transform.js";
|
|
|
25
25
|
import { diff } from "./commands/diff.js";
|
|
26
26
|
import { version } from "./commands/version.js";
|
|
27
27
|
import { telemetry } from "./commands/telemetry.js";
|
|
28
|
-
import { bootstrap } from "./commands/bootstrap.js";
|
|
29
28
|
dev(program);
|
|
30
29
|
deploy(program);
|
|
31
30
|
build(program);
|
|
@@ -39,7 +38,6 @@ consoleCommand(program);
|
|
|
39
38
|
diff(program);
|
|
40
39
|
version(program);
|
|
41
40
|
telemetry(program);
|
|
42
|
-
bootstrap(program);
|
|
43
41
|
if ("setSourceMapsEnabled" in process) {
|
|
44
42
|
// @ts-expect-error
|
|
45
43
|
process.setSourceMapsEnabled(true);
|
package/constructs/Api.d.ts
CHANGED
|
@@ -445,7 +445,7 @@ export interface ApiFunctionRouteProps<AuthorizersKeys = string> extends ApiBase
|
|
|
445
445
|
* type: "aws",
|
|
446
446
|
* cdk: {
|
|
447
447
|
* integration: {
|
|
448
|
-
* subtype:
|
|
448
|
+
* subtype: apig.HttpIntegrationSubtype.EVENTBRIDGE_PUT_EVENTS,
|
|
449
449
|
* parameterMapping: ParameterMapping.fromObject({
|
|
450
450
|
* Source: MappingValue.custom("$request.body.source"),
|
|
451
451
|
* DetailType: MappingValue.custom("$request.body.detailType"),
|
package/constructs/Stack.d.ts
CHANGED
|
@@ -113,6 +113,7 @@ export declare class Stack extends cdk.Stack {
|
|
|
113
113
|
*/
|
|
114
114
|
addOutputs(outputs: Record<string, string | cdk.CfnOutputProps>): void;
|
|
115
115
|
private createCustomResourceHandler;
|
|
116
|
+
private static buildSynthesizer;
|
|
116
117
|
private static checkForPropsIsConstruct;
|
|
117
118
|
private static checkForEnvInProps;
|
|
118
119
|
}
|
package/constructs/Stack.js
CHANGED
|
@@ -3,6 +3,7 @@ import url from "url";
|
|
|
3
3
|
import * as path from "path";
|
|
4
4
|
import * as cdk from "aws-cdk-lib";
|
|
5
5
|
import * as lambda from "aws-cdk-lib/aws-lambda";
|
|
6
|
+
import { useProject } from "../project.js";
|
|
6
7
|
import { Function as Fn } from "./Function.js";
|
|
7
8
|
import { isConstruct } from "./Construct.js";
|
|
8
9
|
const __dirname = path.dirname(url.fileURLToPath(import.meta.url));
|
|
@@ -43,6 +44,7 @@ export class Stack extends cdk.Stack {
|
|
|
43
44
|
account: root.account,
|
|
44
45
|
region: root.region,
|
|
45
46
|
},
|
|
47
|
+
synthesizer: props?.synthesizer || Stack.buildSynthesizer(),
|
|
46
48
|
});
|
|
47
49
|
this.stage = root.stage;
|
|
48
50
|
this.defaultFunctionProps = root.defaultFunctionProps.map((dfp) => typeof dfp === "function" ? dfp(this) : dfp);
|
|
@@ -192,6 +194,17 @@ export class Stack extends cdk.Stack {
|
|
|
192
194
|
memorySize: 1024,
|
|
193
195
|
});
|
|
194
196
|
}
|
|
197
|
+
static buildSynthesizer() {
|
|
198
|
+
const config = useProject().config;
|
|
199
|
+
const customSynethesizerKeys = Object.keys(config.cdk || {}).filter((key) => key.startsWith("qualifier"));
|
|
200
|
+
if (customSynethesizerKeys.length === 0) {
|
|
201
|
+
return;
|
|
202
|
+
}
|
|
203
|
+
return new cdk.DefaultStackSynthesizer({
|
|
204
|
+
qualifier: config.cdk?.qualifier,
|
|
205
|
+
fileAssetsBucketName: config.cdk?.fileAssetsBucketName,
|
|
206
|
+
});
|
|
207
|
+
}
|
|
195
208
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
196
209
|
static checkForPropsIsConstruct(id, props) {
|
|
197
210
|
// If a construct is passed in as stack props, let's detect it and throw a
|
package/package.json
CHANGED
package/project.d.ts
CHANGED
|
@@ -11,6 +11,16 @@ export interface ConfigOptions {
|
|
|
11
11
|
profile?: string;
|
|
12
12
|
role?: string;
|
|
13
13
|
ssmPrefix?: string;
|
|
14
|
+
bootstrap?: {
|
|
15
|
+
stackName?: string;
|
|
16
|
+
tags?: Record<string, string>;
|
|
17
|
+
};
|
|
18
|
+
cdk?: {
|
|
19
|
+
toolkitStackName?: string;
|
|
20
|
+
qualifier?: string;
|
|
21
|
+
fileAssetsBucketName?: string;
|
|
22
|
+
publicAccessBlockConfiguration?: boolean;
|
|
23
|
+
};
|
|
14
24
|
}
|
|
15
25
|
declare const DEFAULTS: {
|
|
16
26
|
readonly stage: undefined;
|
package/project.js
CHANGED
|
@@ -70,6 +70,8 @@ export async function initProject(globals) {
|
|
|
70
70
|
region: globals.region || config.region,
|
|
71
71
|
role: globals.role || config.role,
|
|
72
72
|
ssmPrefix: config.ssmPrefix || `/sst/${config.name}/${stage}/`,
|
|
73
|
+
bootstrap: config.bootstrap,
|
|
74
|
+
cdk: config.cdk,
|
|
73
75
|
},
|
|
74
76
|
stacks: sstConfig.stacks,
|
|
75
77
|
metafile,
|
package/sst.mjs
CHANGED
|
@@ -367,7 +367,9 @@ async function initProject(globals) {
|
|
|
367
367
|
profile: process.env.AWS_ACCESS_KEY_ID && process.env.AWS_SECRET_ACCESS_KEY ? void 0 : globals.profile || config.profile,
|
|
368
368
|
region: globals.region || config.region,
|
|
369
369
|
role: globals.role || config.role,
|
|
370
|
-
ssmPrefix: config.ssmPrefix || `/sst/${config.name}/${stage}
|
|
370
|
+
ssmPrefix: config.ssmPrefix || `/sst/${config.name}/${stage}/`,
|
|
371
|
+
bootstrap: config.bootstrap,
|
|
372
|
+
cdk: config.cdk
|
|
371
373
|
},
|
|
372
374
|
stacks: sstConfig.stacks,
|
|
373
375
|
metafile,
|
|
@@ -2767,11 +2769,6 @@ var init_iot2 = __esm({
|
|
|
2767
2769
|
});
|
|
2768
2770
|
|
|
2769
2771
|
// src/bootstrap.ts
|
|
2770
|
-
var bootstrap_exports = {};
|
|
2771
|
-
__export(bootstrap_exports, {
|
|
2772
|
-
bootstrapSST: () => bootstrapSST,
|
|
2773
|
-
useBootstrap: () => useBootstrap
|
|
2774
|
-
});
|
|
2775
2772
|
import url3 from "url";
|
|
2776
2773
|
import path8 from "path";
|
|
2777
2774
|
import { bold, dim } from "colorette";
|
|
@@ -2801,12 +2798,12 @@ import {
|
|
|
2801
2798
|
BucketEncryption
|
|
2802
2799
|
} from "aws-cdk-lib/aws-s3";
|
|
2803
2800
|
async function loadCDKStatus() {
|
|
2801
|
+
const { cdk } = useProject().config;
|
|
2804
2802
|
const client = useAWSClient(CloudFormationClient);
|
|
2803
|
+
const stackName = cdk?.toolkitStackName || CDK_STACK_NAME;
|
|
2805
2804
|
try {
|
|
2806
2805
|
const { Stacks: stacks } = await client.send(
|
|
2807
|
-
new DescribeStacksCommand({
|
|
2808
|
-
StackName: "CDKToolkit"
|
|
2809
|
-
})
|
|
2806
|
+
new DescribeStacksCommand({ StackName: stackName })
|
|
2810
2807
|
);
|
|
2811
2808
|
if (!stacks || stacks.length === 0)
|
|
2812
2809
|
return false;
|
|
@@ -2820,41 +2817,71 @@ async function loadCDKStatus() {
|
|
|
2820
2817
|
return false;
|
|
2821
2818
|
return true;
|
|
2822
2819
|
} catch (e) {
|
|
2823
|
-
if (e.name === "ValidationError" && e.message ===
|
|
2820
|
+
if (e.name === "ValidationError" && e.message === `Stack with id ${stackName} does not exist`) {
|
|
2824
2821
|
return false;
|
|
2825
2822
|
} else {
|
|
2826
2823
|
throw e;
|
|
2827
2824
|
}
|
|
2828
2825
|
}
|
|
2829
2826
|
}
|
|
2830
|
-
async function
|
|
2831
|
-
|
|
2832
|
-
|
|
2833
|
-
const
|
|
2827
|
+
async function loadSSTStatus() {
|
|
2828
|
+
const { bootstrap } = useProject().config;
|
|
2829
|
+
const cf = useAWSClient(CloudFormationClient);
|
|
2830
|
+
const stackName = bootstrap?.stackName || SST_STACK_NAME;
|
|
2831
|
+
let result;
|
|
2832
|
+
try {
|
|
2833
|
+
result = await cf.send(
|
|
2834
|
+
new DescribeStacksCommand({
|
|
2835
|
+
StackName: stackName
|
|
2836
|
+
})
|
|
2837
|
+
);
|
|
2838
|
+
} catch (e) {
|
|
2839
|
+
if (e.Code === "ValidationError" && e.message === `Stack with id ${stackName} does not exist`) {
|
|
2840
|
+
return null;
|
|
2841
|
+
}
|
|
2842
|
+
throw e;
|
|
2843
|
+
}
|
|
2844
|
+
let version2, bucket;
|
|
2845
|
+
(result.Stacks[0].Outputs || []).forEach((o) => {
|
|
2846
|
+
if (o.OutputKey === OUTPUT_VERSION) {
|
|
2847
|
+
version2 = o.OutputValue;
|
|
2848
|
+
} else if (o.OutputKey === OUTPUT_BUCKET) {
|
|
2849
|
+
bucket = o.OutputValue;
|
|
2850
|
+
}
|
|
2851
|
+
});
|
|
2852
|
+
if (!version2 || !bucket) {
|
|
2853
|
+
return null;
|
|
2854
|
+
}
|
|
2855
|
+
return { version: version2, bucket };
|
|
2856
|
+
}
|
|
2857
|
+
async function bootstrapSST() {
|
|
2858
|
+
const { region, bootstrap, cdk } = useProject().config;
|
|
2834
2859
|
const app = new App();
|
|
2835
|
-
const
|
|
2860
|
+
const stackName = bootstrap?.stackName || SST_STACK_NAME;
|
|
2861
|
+
const stack = new Stack(app, stackName, {
|
|
2836
2862
|
env: {
|
|
2837
|
-
region
|
|
2863
|
+
region
|
|
2838
2864
|
},
|
|
2839
2865
|
synthesizer: new DefaultStackSynthesizer({
|
|
2840
|
-
qualifier
|
|
2866
|
+
qualifier: cdk?.qualifier,
|
|
2867
|
+
fileAssetsBucketName: cdk?.fileAssetsBucketName
|
|
2841
2868
|
})
|
|
2842
2869
|
});
|
|
2843
|
-
for (const [key, value] of Object.entries(tags)) {
|
|
2870
|
+
for (const [key, value] of Object.entries(bootstrap?.tags || {})) {
|
|
2844
2871
|
Tags.of(app).add(key, value);
|
|
2845
2872
|
}
|
|
2846
|
-
const bucket = new Bucket(stack,
|
|
2873
|
+
const bucket = new Bucket(stack, region, {
|
|
2847
2874
|
encryption: BucketEncryption.S3_MANAGED,
|
|
2848
2875
|
removalPolicy: RemovalPolicy.DESTROY,
|
|
2849
2876
|
autoDeleteObjects: true,
|
|
2850
|
-
blockPublicAccess: publicAccessBlockConfiguration ? BlockPublicAccess.BLOCK_ALL : void 0
|
|
2877
|
+
blockPublicAccess: cdk?.publicAccessBlockConfiguration !== false ? BlockPublicAccess.BLOCK_ALL : void 0
|
|
2851
2878
|
});
|
|
2852
2879
|
const fn = new Function(stack, "MetadataHandler", {
|
|
2853
2880
|
code: Code.fromAsset(
|
|
2854
2881
|
path8.resolve(__dirname, "support/bootstrap-metadata-function")
|
|
2855
2882
|
),
|
|
2856
2883
|
handler: "index.handler",
|
|
2857
|
-
runtime:
|
|
2884
|
+
runtime: region?.startsWith("us-gov-") ? Runtime.NODEJS_16_X : Runtime.NODEJS_18_X,
|
|
2858
2885
|
environment: {
|
|
2859
2886
|
BUCKET_NAME: bucket.bucketName
|
|
2860
2887
|
},
|
|
@@ -2920,7 +2947,8 @@ ${JSON.stringify(
|
|
|
2920
2947
|
async function bootstrapCDK() {
|
|
2921
2948
|
const identity = await useSTSIdentity();
|
|
2922
2949
|
const credentials = await useAWSCredentials();
|
|
2923
|
-
const { region, profile } = useProject().config;
|
|
2950
|
+
const { region, profile, cdk } = useProject().config;
|
|
2951
|
+
cdk || {};
|
|
2924
2952
|
await new Promise((resolve, reject) => {
|
|
2925
2953
|
const proc = spawn(
|
|
2926
2954
|
[
|
|
@@ -2928,7 +2956,11 @@ async function bootstrapCDK() {
|
|
|
2928
2956
|
"cdk",
|
|
2929
2957
|
"bootstrap",
|
|
2930
2958
|
`aws://${identity.Account}/${region}`,
|
|
2931
|
-
"--no-version-reporting"
|
|
2959
|
+
"--no-version-reporting",
|
|
2960
|
+
...cdk?.publicAccessBlockConfiguration === false ? ["--public-access-block-configuration", "false"] : cdk?.publicAccessBlockConfiguration === true ? ["--public-access-block-configuration", "false"] : [],
|
|
2961
|
+
...cdk?.toolkitStackName ? ["--toolkit-stack-name", cdk.toolkitStackName] : [],
|
|
2962
|
+
...cdk?.qualifier ? ["--qualifier", cdk.qualifier] : [],
|
|
2963
|
+
...cdk?.fileAssetsBucketName ? ["--toolkit-bucket-name", cdk.fileAssetsBucketName] : []
|
|
2932
2964
|
].join(" "),
|
|
2933
2965
|
{
|
|
2934
2966
|
env: {
|
|
@@ -2962,35 +2994,7 @@ async function bootstrapCDK() {
|
|
|
2962
2994
|
});
|
|
2963
2995
|
});
|
|
2964
2996
|
}
|
|
2965
|
-
|
|
2966
|
-
const cf = useAWSClient(CloudFormationClient);
|
|
2967
|
-
let result;
|
|
2968
|
-
try {
|
|
2969
|
-
result = await cf.send(
|
|
2970
|
-
new DescribeStacksCommand({
|
|
2971
|
-
StackName: STACK_NAME
|
|
2972
|
-
})
|
|
2973
|
-
);
|
|
2974
|
-
} catch (e) {
|
|
2975
|
-
if (e.Code === "ValidationError" && e.message === `Stack with id ${STACK_NAME} does not exist`) {
|
|
2976
|
-
return null;
|
|
2977
|
-
}
|
|
2978
|
-
throw e;
|
|
2979
|
-
}
|
|
2980
|
-
let version2, bucket;
|
|
2981
|
-
(result.Stacks[0].Outputs || []).forEach((o) => {
|
|
2982
|
-
if (o.OutputKey === OUTPUT_VERSION) {
|
|
2983
|
-
version2 = o.OutputValue;
|
|
2984
|
-
} else if (o.OutputKey === OUTPUT_BUCKET) {
|
|
2985
|
-
bucket = o.OutputValue;
|
|
2986
|
-
}
|
|
2987
|
-
});
|
|
2988
|
-
if (!version2 || !bucket) {
|
|
2989
|
-
return null;
|
|
2990
|
-
}
|
|
2991
|
-
return { version: version2, bucket };
|
|
2992
|
-
}
|
|
2993
|
-
var STACK_NAME, OUTPUT_VERSION, OUTPUT_BUCKET, LATEST_VERSION, __dirname, useBootstrap;
|
|
2997
|
+
var CDK_STACK_NAME, SST_STACK_NAME, OUTPUT_VERSION, OUTPUT_BUCKET, LATEST_VERSION, __dirname, useBootstrap;
|
|
2994
2998
|
var init_bootstrap = __esm({
|
|
2995
2999
|
"src/bootstrap.ts"() {
|
|
2996
3000
|
"use strict";
|
|
@@ -3001,7 +3005,8 @@ var init_bootstrap = __esm({
|
|
|
3001
3005
|
init_error();
|
|
3002
3006
|
init_logger();
|
|
3003
3007
|
init_stacks();
|
|
3004
|
-
|
|
3008
|
+
CDK_STACK_NAME = "CDKToolkit";
|
|
3009
|
+
SST_STACK_NAME = "SSTBootstrap";
|
|
3005
3010
|
OUTPUT_VERSION = "Version";
|
|
3006
3011
|
OUTPUT_BUCKET = "BucketName";
|
|
3007
3012
|
LATEST_VERSION = "7";
|
|
@@ -3045,7 +3050,7 @@ import {
|
|
|
3045
3050
|
} from "@aws-sdk/client-s3";
|
|
3046
3051
|
async function metadata() {
|
|
3047
3052
|
Logger.debug("Fetching app metadata");
|
|
3048
|
-
const [project, credentials,
|
|
3053
|
+
const [project, credentials, bootstrap] = await Promise.all([
|
|
3049
3054
|
useProject(),
|
|
3050
3055
|
useAWSCredentials(),
|
|
3051
3056
|
useBootstrap()
|
|
@@ -3058,7 +3063,7 @@ async function metadata() {
|
|
|
3058
3063
|
const result = await s3.send(
|
|
3059
3064
|
new GetObjectCommand({
|
|
3060
3065
|
Key: useS3Key(),
|
|
3061
|
-
Bucket:
|
|
3066
|
+
Bucket: bootstrap.bucket
|
|
3062
3067
|
})
|
|
3063
3068
|
);
|
|
3064
3069
|
const body = await result.Body.transformToString();
|
|
@@ -3069,7 +3074,7 @@ async function metadata() {
|
|
|
3069
3074
|
}
|
|
3070
3075
|
async function saveAppMetadata(data2) {
|
|
3071
3076
|
Logger.debug("Saving app metadata");
|
|
3072
|
-
const [project, credentials,
|
|
3077
|
+
const [project, credentials, bootstrap] = await Promise.all([
|
|
3073
3078
|
useProject(),
|
|
3074
3079
|
useAWSCredentials(),
|
|
3075
3080
|
useBootstrap()
|
|
@@ -3082,7 +3087,7 @@ async function saveAppMetadata(data2) {
|
|
|
3082
3087
|
await s3.send(
|
|
3083
3088
|
new PutObjectCommand({
|
|
3084
3089
|
Key: useS3Key(),
|
|
3085
|
-
Bucket:
|
|
3090
|
+
Bucket: bootstrap.bucket,
|
|
3086
3091
|
Body: JSON.stringify(data2)
|
|
3087
3092
|
})
|
|
3088
3093
|
);
|
|
@@ -3092,7 +3097,7 @@ async function saveAppMetadata(data2) {
|
|
|
3092
3097
|
}
|
|
3093
3098
|
async function clearAppMetadata() {
|
|
3094
3099
|
Logger.debug("Clearing app metadata");
|
|
3095
|
-
const [project, credentials,
|
|
3100
|
+
const [project, credentials, bootstrap] = await Promise.all([
|
|
3096
3101
|
useProject(),
|
|
3097
3102
|
useAWSCredentials(),
|
|
3098
3103
|
useBootstrap()
|
|
@@ -3104,7 +3109,7 @@ async function clearAppMetadata() {
|
|
|
3104
3109
|
await s3.send(
|
|
3105
3110
|
new DeleteObjectCommand({
|
|
3106
3111
|
Key: useS3Key(),
|
|
3107
|
-
Bucket:
|
|
3112
|
+
Bucket: bootstrap.bucket
|
|
3108
3113
|
})
|
|
3109
3114
|
);
|
|
3110
3115
|
}
|
|
@@ -4673,7 +4678,7 @@ import {
|
|
|
4673
4678
|
async function metadata2() {
|
|
4674
4679
|
Logger.debug("Fetching all metadata");
|
|
4675
4680
|
const project = useProject();
|
|
4676
|
-
const [credentials,
|
|
4681
|
+
const [credentials, bootstrap] = await Promise.all([
|
|
4677
4682
|
useAWSCredentials(),
|
|
4678
4683
|
useBootstrap()
|
|
4679
4684
|
]);
|
|
@@ -4685,7 +4690,7 @@ async function metadata2() {
|
|
|
4685
4690
|
const list2 = await s3.send(
|
|
4686
4691
|
new ListObjectsV2Command({
|
|
4687
4692
|
Prefix: key,
|
|
4688
|
-
Bucket:
|
|
4693
|
+
Bucket: bootstrap.bucket
|
|
4689
4694
|
})
|
|
4690
4695
|
);
|
|
4691
4696
|
const result = Object.fromEntries(
|
|
@@ -4695,7 +4700,7 @@ async function metadata2() {
|
|
|
4695
4700
|
const result2 = await s3.send(
|
|
4696
4701
|
new GetObjectCommand2({
|
|
4697
4702
|
Key: obj.Key,
|
|
4698
|
-
Bucket:
|
|
4703
|
+
Bucket: bootstrap.bucket
|
|
4699
4704
|
})
|
|
4700
4705
|
);
|
|
4701
4706
|
const body = await result2.Body.transformToString();
|
|
@@ -4707,7 +4712,7 @@ async function metadata2() {
|
|
|
4707
4712
|
return result;
|
|
4708
4713
|
}
|
|
4709
4714
|
async function metadataForStack(stackID) {
|
|
4710
|
-
const [project, credentials,
|
|
4715
|
+
const [project, credentials, bootstrap] = await Promise.all([
|
|
4711
4716
|
useProject(),
|
|
4712
4717
|
useAWSCredentialsProvider(),
|
|
4713
4718
|
useBootstrap()
|
|
@@ -4717,12 +4722,12 @@ async function metadataForStack(stackID) {
|
|
|
4717
4722
|
credentials
|
|
4718
4723
|
});
|
|
4719
4724
|
const key = `stackMetadata/app.${project.config.name}/stage.${project.config.stage}/stack.${stackID}.json`;
|
|
4720
|
-
Logger.debug("Getting metadata", key, "from",
|
|
4725
|
+
Logger.debug("Getting metadata", key, "from", bootstrap.bucket);
|
|
4721
4726
|
try {
|
|
4722
4727
|
const result = await s3.send(
|
|
4723
4728
|
new GetObjectCommand2({
|
|
4724
4729
|
Key: key,
|
|
4725
|
-
Bucket:
|
|
4730
|
+
Bucket: bootstrap.bucket
|
|
4726
4731
|
})
|
|
4727
4732
|
);
|
|
4728
4733
|
const body = await result.Body.transformToString();
|
|
@@ -7824,51 +7829,6 @@ var telemetry = (program2) => program2.command(
|
|
|
7824
7829
|
}
|
|
7825
7830
|
);
|
|
7826
7831
|
|
|
7827
|
-
// src/cli/commands/bootstrap.ts
|
|
7828
|
-
var bootstrap = (program2) => program2.command(
|
|
7829
|
-
"bootstrap",
|
|
7830
|
-
"Create the SST bootstrap stack",
|
|
7831
|
-
(yargs2) => yargs2.option("tags", {
|
|
7832
|
-
type: "array",
|
|
7833
|
-
string: true,
|
|
7834
|
-
describe: "Tags to add for the bootstrap stack"
|
|
7835
|
-
}).option("qualifier", {
|
|
7836
|
-
type: "string",
|
|
7837
|
-
describe: "A string that is added to the names of all resources in the bootstrap stack"
|
|
7838
|
-
}).option("public-access-block-configuration", {
|
|
7839
|
-
type: "boolean",
|
|
7840
|
-
default: true,
|
|
7841
|
-
describe: "Block public access configuration on SST bootstrap bucket"
|
|
7842
|
-
}),
|
|
7843
|
-
async (args) => {
|
|
7844
|
-
const { createSpinner: createSpinner2 } = await Promise.resolve().then(() => (init_spinner(), spinner_exports));
|
|
7845
|
-
const { Colors: Colors2 } = await Promise.resolve().then(() => (init_colors(), colors_exports));
|
|
7846
|
-
const { useProject: useProject2 } = await Promise.resolve().then(() => (init_project(), project_exports));
|
|
7847
|
-
const { bootstrapSST: bootstrapSST2 } = await Promise.resolve().then(() => (init_bootstrap(), bootstrap_exports));
|
|
7848
|
-
const { useSTSIdentity: useSTSIdentity2 } = await Promise.resolve().then(() => (init_credentials(), credentials_exports));
|
|
7849
|
-
const project = useProject2();
|
|
7850
|
-
const identity = await useSTSIdentity2();
|
|
7851
|
-
const tags = Object.fromEntries(
|
|
7852
|
-
args.tags?.map((t) => t.split("=")) || []
|
|
7853
|
-
);
|
|
7854
|
-
if (args.tags?.length) {
|
|
7855
|
-
Colors2.line(`${Colors2.primary(`\u279C`)} Using tags`, tags);
|
|
7856
|
-
}
|
|
7857
|
-
const spinner = createSpinner2(" Deploying bootstrap stack").start();
|
|
7858
|
-
await bootstrapSST2(
|
|
7859
|
-
tags,
|
|
7860
|
-
args.publicAccessBlockConfiguration,
|
|
7861
|
-
args.qualifier
|
|
7862
|
-
);
|
|
7863
|
-
spinner.succeed(
|
|
7864
|
-
Colors2.bold(
|
|
7865
|
-
` Bootstrapped account ${identity.Account} in region ${project.config.region}`
|
|
7866
|
-
)
|
|
7867
|
-
);
|
|
7868
|
-
process.exit(0);
|
|
7869
|
-
}
|
|
7870
|
-
);
|
|
7871
|
-
|
|
7872
7832
|
// src/cli/sst.ts
|
|
7873
7833
|
dotenv2.config({
|
|
7874
7834
|
override: true
|
|
@@ -7890,7 +7850,6 @@ consoleCommand(program);
|
|
|
7890
7850
|
diff2(program);
|
|
7891
7851
|
version(program);
|
|
7892
7852
|
telemetry(program);
|
|
7893
|
-
bootstrap(program);
|
|
7894
7853
|
if ("setSourceMapsEnabled" in process) {
|
|
7895
7854
|
process.setSourceMapsEnabled(true);
|
|
7896
7855
|
}
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
/// <reference types="yargs" />
|
|
2
|
-
import type { Program } from "../program.js";
|
|
3
|
-
export declare const bootstrap: (program: Program) => import("yargs").Argv<{
|
|
4
|
-
stage: string | undefined;
|
|
5
|
-
} & {
|
|
6
|
-
profile: string | undefined;
|
|
7
|
-
} & {
|
|
8
|
-
region: string | undefined;
|
|
9
|
-
} & {
|
|
10
|
-
verbose: boolean | undefined;
|
|
11
|
-
} & {
|
|
12
|
-
role: string | undefined;
|
|
13
|
-
} & {
|
|
14
|
-
tags: string[] | undefined;
|
|
15
|
-
} & {
|
|
16
|
-
qualifier: string | undefined;
|
|
17
|
-
} & {
|
|
18
|
-
"public-access-block-configuration": boolean;
|
|
19
|
-
}>;
|
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
export const bootstrap = (program) => program.command("bootstrap", "Create the SST bootstrap stack", (yargs) => yargs
|
|
2
|
-
.option("tags", {
|
|
3
|
-
type: "array",
|
|
4
|
-
string: true,
|
|
5
|
-
describe: "Tags to add for the bootstrap stack",
|
|
6
|
-
})
|
|
7
|
-
.option("qualifier", {
|
|
8
|
-
type: "string",
|
|
9
|
-
describe: "A string that is added to the names of all resources in the bootstrap stack",
|
|
10
|
-
})
|
|
11
|
-
.option("public-access-block-configuration", {
|
|
12
|
-
type: "boolean",
|
|
13
|
-
default: true,
|
|
14
|
-
describe: "Block public access configuration on SST bootstrap bucket",
|
|
15
|
-
}), async (args) => {
|
|
16
|
-
const { createSpinner } = await import("../spinner.js");
|
|
17
|
-
const { Colors } = await import("../colors.js");
|
|
18
|
-
const { useProject } = await import("../../project.js");
|
|
19
|
-
const { bootstrapSST } = await import("../../bootstrap.js");
|
|
20
|
-
const { useSTSIdentity } = await import("../../credentials.js");
|
|
21
|
-
const project = useProject();
|
|
22
|
-
const identity = await useSTSIdentity();
|
|
23
|
-
const tags = Object.fromEntries(args.tags?.map((t) => t.split("=")) || []);
|
|
24
|
-
if (args.tags?.length) {
|
|
25
|
-
Colors.line(`${Colors.primary(`➜`)} Using tags`, tags);
|
|
26
|
-
}
|
|
27
|
-
const spinner = createSpinner(" Deploying bootstrap stack").start();
|
|
28
|
-
await bootstrapSST(tags, args.publicAccessBlockConfiguration, args.qualifier);
|
|
29
|
-
spinner.succeed(Colors.bold(` Bootstrapped account ${identity.Account} in region ${project.config.region}`));
|
|
30
|
-
process.exit(0);
|
|
31
|
-
});
|