forked from anomalyco/sst
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdeploy.mjs
More file actions
51 lines (43 loc) · 1.15 KB
/
Copy pathdeploy.mjs
File metadata and controls
51 lines (43 loc) · 1.15 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
"use strict";
import path from "path";
import paths from "./util/paths.mjs";
import {
synth,
deploy,
writeOutputsFile,
validatePropsForJs,
} from "./util/cdkHelpers.mjs";
import {
Bootstrap,
STACK_DEPLOY_STATUS
} from "@serverless-stack/core";
export default async function (argv, config, cliInfo) {
// Normalize stack name
const stackPrefix = `${config.stage}-${config.name}-`;
let stackId = argv.stack;
if (stackId) {
stackId = stackId.startsWith(stackPrefix)
? stackId
: `${stackPrefix}${stackId}`;
}
// Deploy bootstrap stack
await Bootstrap.bootstrap(config, cliInfo);
// Run CDK Synth
await synth(cliInfo.cdkOptions);
validatePropsForJs(config);
// Run CDK Deploy
const stacksData = await deploy(cliInfo.cdkOptions, stackId);
// Write outputsFile
if (argv.outputsFile) {
await writeOutputsFile(
stacksData,
path.resolve(paths.appPath, argv.outputsFile),
cliInfo.cdkOptions
);
}
// Check all stacks deployed successfully
if (stacksData.some(({ status }) => status === STACK_DEPLOY_STATUS.FAILED)) {
throw new Error(`Failed to deploy the app`);
}
return stacksData;
}