sst 2.0.0-rc.36 → 2.0.0-rc.37
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 +5 -4
- package/bootstrap.js +51 -17
- package/cli/commands/bind.d.ts +2 -0
- package/cli/commands/build.d.ts +2 -0
- package/cli/commands/console.d.ts +2 -0
- package/cli/commands/deploy.d.ts +2 -0
- package/cli/commands/dev.d.ts +2 -0
- package/cli/commands/dev.js +1 -1
- package/cli/commands/diff.d.ts +2 -0
- package/cli/commands/env.d.ts +2 -0
- package/cli/commands/remove.d.ts +2 -0
- package/cli/commands/secrets/get.d.ts +2 -0
- package/cli/commands/secrets/list.d.ts +2 -0
- package/cli/commands/secrets/remove.d.ts +2 -0
- package/cli/commands/secrets/set.d.ts +2 -0
- package/cli/commands/update.d.ts +2 -0
- package/cli/commands/version.d.ts +2 -0
- package/cli/program.d.ts +2 -0
- package/cli/program.js +4 -0
- package/cli/sst.js +2 -2
- package/cli/ui/functions.js +4 -0
- package/constructs/App.d.ts +0 -4
- package/constructs/App.js +2 -4
- package/credentials.js +1 -0
- package/package.json +1 -1
- package/project.d.ts +2 -0
- package/project.js +3 -0
- package/sst.mjs +2806 -2743
- package/stacks/synth.js +1 -6
package/bootstrap.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
export declare const useBootstrap: () =>
|
|
2
|
-
version:
|
|
3
|
-
bucket:
|
|
4
|
-
}
|
|
1
|
+
export declare const useBootstrap: () => {
|
|
2
|
+
version: string;
|
|
3
|
+
bucket: string;
|
|
4
|
+
};
|
|
5
|
+
export declare function initBootstrap(): Promise<void>;
|
package/bootstrap.js
CHANGED
|
@@ -12,19 +12,25 @@ import { BlockPublicAccess, Bucket, BucketEncryption, } from "aws-cdk-lib/aws-s3
|
|
|
12
12
|
import { useProject } from "./project.js";
|
|
13
13
|
import { createSpinner } from "./cli/spinner.js";
|
|
14
14
|
import { Context } from "./context/context.js";
|
|
15
|
-
import { useAWSClient } from "./credentials.js";
|
|
15
|
+
import { useAWSClient, useAWSCredentials, useSTSIdentity, } from "./credentials.js";
|
|
16
16
|
import { VisibleError } from "./error.js";
|
|
17
17
|
import { Logger } from "./logger.js";
|
|
18
18
|
import { Stacks } from "./stacks/index.js";
|
|
19
|
+
import { spawnSync } from "child_process";
|
|
19
20
|
const STACK_NAME = "SSTBootstrap";
|
|
20
21
|
const OUTPUT_VERSION = "Version";
|
|
21
22
|
const OUTPUT_BUCKET = "BucketName";
|
|
22
23
|
const LATEST_VERSION = "5";
|
|
23
24
|
const __dirname = url.fileURLToPath(new URL(".", import.meta.url));
|
|
24
|
-
|
|
25
|
+
const BootstrapContext = Context.create();
|
|
26
|
+
export const useBootstrap = BootstrapContext.use;
|
|
27
|
+
export async function initBootstrap() {
|
|
25
28
|
Logger.debug("Initializing bootstrap context");
|
|
26
|
-
|
|
27
|
-
|
|
29
|
+
await assertCDKToolkit();
|
|
30
|
+
const status = await (async () => {
|
|
31
|
+
const status = await load();
|
|
32
|
+
if (status && status.version === LATEST_VERSION)
|
|
33
|
+
return status;
|
|
28
34
|
const project = useProject();
|
|
29
35
|
const spinner = createSpinner("Deploying bootstrap stack, this only needs to happen once").start();
|
|
30
36
|
// Create bootstrap stack
|
|
@@ -81,9 +87,9 @@ export const useBootstrap = Context.memo(async () => {
|
|
|
81
87
|
"ROLLBACK_COMPLETE",
|
|
82
88
|
"DELETE_COMPLETE",
|
|
83
89
|
],
|
|
84
|
-
}
|
|
85
|
-
}
|
|
86
|
-
}
|
|
90
|
+
},
|
|
91
|
+
},
|
|
92
|
+
},
|
|
87
93
|
});
|
|
88
94
|
rule.addTarget(new SqsQueue(queue, {
|
|
89
95
|
retryAttempts: 10,
|
|
@@ -99,15 +105,43 @@ export const useBootstrap = Context.memo(async () => {
|
|
|
99
105
|
}
|
|
100
106
|
spinner.succeed();
|
|
101
107
|
// Fetch bootstrap status
|
|
102
|
-
|
|
103
|
-
if (!
|
|
104
|
-
throw new VisibleError("Failed to
|
|
105
|
-
|
|
108
|
+
const ret = await load();
|
|
109
|
+
if (!ret)
|
|
110
|
+
throw new VisibleError("Failed to load bootstrap stack status");
|
|
111
|
+
return ret;
|
|
112
|
+
})();
|
|
113
|
+
BootstrapContext.provide(status);
|
|
114
|
+
Logger.debug("Bootstrap context initialized", status);
|
|
115
|
+
}
|
|
116
|
+
async function assertCDKToolkit() {
|
|
117
|
+
const client = useAWSClient(CloudFormationClient);
|
|
118
|
+
const { Stacks: stacks } = await client.send(new DescribeStacksCommand({
|
|
119
|
+
StackName: "CDKToolkit",
|
|
120
|
+
}));
|
|
121
|
+
if (!stacks || stacks.length === 0) {
|
|
122
|
+
const identity = await useSTSIdentity();
|
|
123
|
+
const credentials = await useAWSCredentials();
|
|
124
|
+
const project = useProject();
|
|
125
|
+
spawnSync([
|
|
126
|
+
"npx",
|
|
127
|
+
"cdk",
|
|
128
|
+
"bootstrap",
|
|
129
|
+
`aws://${identity.Account}/${useProject().config.region}`,
|
|
130
|
+
].join(" "), {
|
|
131
|
+
env: {
|
|
132
|
+
...process.env,
|
|
133
|
+
AWS_ACCESS_KEY_ID: credentials.accessKeyId,
|
|
134
|
+
AWS_SECRET_ACCESS_KEY: credentials.secretAccessKey,
|
|
135
|
+
AWS_SESSION_TOKEN: credentials.sessionToken,
|
|
136
|
+
AWS_REGION: project.config.region,
|
|
137
|
+
AWS_PROFILE: project.config.profile,
|
|
138
|
+
},
|
|
139
|
+
stdio: "inherit",
|
|
140
|
+
shell: process.env.SHELL || true,
|
|
141
|
+
});
|
|
106
142
|
}
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
});
|
|
110
|
-
async function loadBootstrapStatus() {
|
|
143
|
+
}
|
|
144
|
+
async function load() {
|
|
111
145
|
// Get bootstrap CloudFormation stack
|
|
112
146
|
const cf = useAWSClient(CloudFormationClient);
|
|
113
147
|
let result;
|
|
@@ -117,8 +151,8 @@ async function loadBootstrapStatus() {
|
|
|
117
151
|
}));
|
|
118
152
|
}
|
|
119
153
|
catch (e) {
|
|
120
|
-
if (e.Code === "ValidationError"
|
|
121
|
-
|
|
154
|
+
if (e.Code === "ValidationError" &&
|
|
155
|
+
e.message === `Stack with id ${STACK_NAME} does not exist`) {
|
|
122
156
|
return null;
|
|
123
157
|
}
|
|
124
158
|
throw e;
|
package/cli/commands/bind.d.ts
CHANGED
package/cli/commands/build.d.ts
CHANGED
package/cli/commands/deploy.d.ts
CHANGED
package/cli/commands/dev.d.ts
CHANGED
package/cli/commands/dev.js
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import chalk from "chalk";
|
|
2
2
|
import { Colors } from "../colors.js";
|
|
3
|
-
import { Functions } from "../ui/functions.js";
|
|
4
3
|
export const dev = (program) => program.command(["dev", "start"], "Work on your app locally", (yargs) => yargs, async (args) => {
|
|
5
4
|
const { useRuntimeWorkers } = await import("../../runtime/workers.js");
|
|
6
5
|
const { useIOTBridge } = await import("../../runtime/iot.js");
|
|
@@ -28,6 +27,7 @@ export const dev = (program) => program.command(["dev", "start"], "Work on your
|
|
|
28
27
|
const { useRDSWarmer } = await import("./plugins/warmer.js");
|
|
29
28
|
const { useProject } = await import("../../project.js");
|
|
30
29
|
const { useMetadata } = await import("../../stacks/metadata.js");
|
|
30
|
+
const { Functions } = await import("../ui/functions.js");
|
|
31
31
|
if (args._[0] === "start") {
|
|
32
32
|
console.log(yellow(`Warning: ${bold(`sst start`)} has been renamed to ${bold(`sst dev`)}`));
|
|
33
33
|
}
|
package/cli/commands/diff.d.ts
CHANGED
package/cli/commands/env.d.ts
CHANGED
package/cli/commands/remove.d.ts
CHANGED
package/cli/commands/update.d.ts
CHANGED
package/cli/program.d.ts
CHANGED
package/cli/program.js
CHANGED
|
@@ -17,6 +17,10 @@ export const program = yargs(hideBin(process.argv))
|
|
|
17
17
|
.option("verbose", {
|
|
18
18
|
type: "boolean",
|
|
19
19
|
describe: "Print verbose logs",
|
|
20
|
+
})
|
|
21
|
+
.option("role", {
|
|
22
|
+
type: "string",
|
|
23
|
+
describe: "ARN of the IAM role to use when invoking AWS",
|
|
20
24
|
})
|
|
21
25
|
.group(["stage", "profile", "region", "help"], "Global:")
|
|
22
26
|
.middleware(async (argv) => {
|
package/cli/sst.js
CHANGED
|
@@ -3,8 +3,9 @@ import { blue, red } from "colorette";
|
|
|
3
3
|
import { program } from "./program.js";
|
|
4
4
|
import { VisibleError } from "../error.js";
|
|
5
5
|
import { useSpinners } from "./spinner.js";
|
|
6
|
-
import dotenv from "dotenv";
|
|
7
6
|
import { Logger } from "../logger.js";
|
|
7
|
+
import dotenv from "dotenv";
|
|
8
|
+
dotenv.config();
|
|
8
9
|
import { env } from "./commands/env.js";
|
|
9
10
|
import { dev } from "./commands/dev.js";
|
|
10
11
|
import { bind } from "./commands/bind.js";
|
|
@@ -15,7 +16,6 @@ import { consoleCommand } from "./commands/console.js";
|
|
|
15
16
|
import { secrets } from "./commands/secrets/secrets.js";
|
|
16
17
|
import { update } from "./commands/update.js";
|
|
17
18
|
import { diff } from "./commands/diff.js";
|
|
18
|
-
dotenv.config();
|
|
19
19
|
dev(program);
|
|
20
20
|
deploy(program);
|
|
21
21
|
build(program);
|
package/cli/ui/functions.js
CHANGED
|
@@ -60,6 +60,8 @@ export function Functions() {
|
|
|
60
60
|
}
|
|
61
61
|
setFunctions((functions) => {
|
|
62
62
|
const { [evt.properties.requestID]: existing, ...next } = functions;
|
|
63
|
+
if (!existing)
|
|
64
|
+
return functions;
|
|
63
65
|
const diff = Date.now() - existing.started;
|
|
64
66
|
if (diff > 500 && diff < 1500) {
|
|
65
67
|
setTimeout(() => {
|
|
@@ -91,6 +93,8 @@ export function Functions() {
|
|
|
91
93
|
}
|
|
92
94
|
setFunctions((functions) => {
|
|
93
95
|
const { [evt.properties.requestID]: existing, ...next } = functions;
|
|
96
|
+
if (!existing)
|
|
97
|
+
return functions;
|
|
94
98
|
const diff = Date.now() - existing.started;
|
|
95
99
|
if (diff > 500 && diff < 1500) {
|
|
96
100
|
setTimeout(() => {
|
package/constructs/App.d.ts
CHANGED
|
@@ -7,7 +7,6 @@ import * as Config from "./Config.js";
|
|
|
7
7
|
import { Permissions } from "./util/permission.js";
|
|
8
8
|
import { StackProps } from "./Stack.js";
|
|
9
9
|
import { FunctionalStack } from "./FunctionalStack.js";
|
|
10
|
-
import { useBootstrap } from "../bootstrap.js";
|
|
11
10
|
/**
|
|
12
11
|
* @internal
|
|
13
12
|
*/
|
|
@@ -40,7 +39,6 @@ export interface AppDeployProps {
|
|
|
40
39
|
readonly debugBridge?: string;
|
|
41
40
|
readonly debugIncreaseTimeout?: boolean;
|
|
42
41
|
readonly mode: "deploy" | "dev" | "remove";
|
|
43
|
-
readonly bootstrap: Awaited<ReturnType<typeof useBootstrap>>;
|
|
44
42
|
}
|
|
45
43
|
type AppRemovalPolicy = Lowercase<keyof typeof cdk.RemovalPolicy>;
|
|
46
44
|
export type AppProps = cdk.AppProps;
|
|
@@ -87,8 +85,6 @@ export declare class App extends cdk.App {
|
|
|
87
85
|
/** @internal */
|
|
88
86
|
readonly appPath: string;
|
|
89
87
|
/** @internal */
|
|
90
|
-
readonly bootstrap: AppDeployProps["bootstrap"];
|
|
91
|
-
/** @internal */
|
|
92
88
|
defaultFunctionProps: (FunctionProps | ((stack: cdk.Stack) => FunctionProps))[];
|
|
93
89
|
private _defaultRemovalPolicy?;
|
|
94
90
|
/** @internal */
|
package/constructs/App.js
CHANGED
|
@@ -14,6 +14,7 @@ import { createRequire } from "module";
|
|
|
14
14
|
import { Auth } from "./Auth.js";
|
|
15
15
|
import { useDeferredTasks } from "./deferred_task.js";
|
|
16
16
|
import { AppContext } from "./context.js";
|
|
17
|
+
import { useBootstrap } from "../bootstrap.js";
|
|
17
18
|
import { useProject } from "../project.js";
|
|
18
19
|
import { Logger } from "../logger.js";
|
|
19
20
|
import { SiteEnv } from "../site-env.js";
|
|
@@ -65,8 +66,6 @@ export class App extends cdk.App {
|
|
|
65
66
|
/** @internal */
|
|
66
67
|
appPath;
|
|
67
68
|
/** @internal */
|
|
68
|
-
bootstrap;
|
|
69
|
-
/** @internal */
|
|
70
69
|
defaultFunctionProps;
|
|
71
70
|
_defaultRemovalPolicy;
|
|
72
71
|
/** @internal */
|
|
@@ -93,7 +92,6 @@ export class App extends cdk.App {
|
|
|
93
92
|
super(props);
|
|
94
93
|
AppContext.provide(this);
|
|
95
94
|
SiteEnv.reset();
|
|
96
|
-
this.bootstrap = deployProps.bootstrap;
|
|
97
95
|
this.appPath = process.cwd();
|
|
98
96
|
this.mode = deployProps.mode;
|
|
99
97
|
this.local = this.mode === "dev";
|
|
@@ -309,7 +307,7 @@ export class App extends cdk.App {
|
|
|
309
307
|
app: this.name,
|
|
310
308
|
stage: this.stage,
|
|
311
309
|
version: useProject().version,
|
|
312
|
-
bootstrapBucket:
|
|
310
|
+
bootstrapBucket: useBootstrap().bucket,
|
|
313
311
|
metadata: byStack[stackName] || [],
|
|
314
312
|
}),
|
|
315
313
|
});
|
package/credentials.js
CHANGED
|
@@ -10,6 +10,7 @@ export const useAWSCredentialsProvider = Context.memo(() => {
|
|
|
10
10
|
Logger.debug("Using AWS profile", project.config.profile);
|
|
11
11
|
const provider = fromNodeProviderChain({
|
|
12
12
|
profile: project.config.profile,
|
|
13
|
+
roleArn: project.config.role,
|
|
13
14
|
});
|
|
14
15
|
return provider;
|
|
15
16
|
});
|
package/package.json
CHANGED
package/project.d.ts
CHANGED
|
@@ -9,6 +9,7 @@ export interface ConfigOptions {
|
|
|
9
9
|
region?: string;
|
|
10
10
|
stage?: string;
|
|
11
11
|
profile?: string;
|
|
12
|
+
role?: string;
|
|
12
13
|
ssmPrefix?: string;
|
|
13
14
|
}
|
|
14
15
|
declare const DEFAULTS: {
|
|
@@ -36,6 +37,7 @@ export declare const ProjectContext: {
|
|
|
36
37
|
export declare function useProject(): Project;
|
|
37
38
|
interface GlobalOptions {
|
|
38
39
|
profile?: string;
|
|
40
|
+
role?: string;
|
|
39
41
|
stage?: string;
|
|
40
42
|
root?: string;
|
|
41
43
|
region?: string;
|
package/project.js
CHANGED
|
@@ -64,6 +64,7 @@ export async function initProject(globals) {
|
|
|
64
64
|
stage,
|
|
65
65
|
profile: config.profile || globals.profile,
|
|
66
66
|
region: config.region || globals.region,
|
|
67
|
+
role: config.role || globals.role,
|
|
67
68
|
ssmPrefix: config.ssmPrefix || `/sst/${config.name}/${stage}/`,
|
|
68
69
|
},
|
|
69
70
|
stacks: sstConfig.stacks,
|
|
@@ -76,6 +77,8 @@ export async function initProject(globals) {
|
|
|
76
77
|
},
|
|
77
78
|
};
|
|
78
79
|
ProjectContext.provide(project);
|
|
80
|
+
const { initBootstrap } = await import("./bootstrap.js");
|
|
81
|
+
await initBootstrap();
|
|
79
82
|
dotenv.config({
|
|
80
83
|
path: path.join(project.paths.root, `.env.${project.config.stage}`),
|
|
81
84
|
});
|