-
Notifications
You must be signed in to change notification settings - Fork 0
/
deploy.js
48 lines (48 loc) · 7.07 KB
/
deploy.js
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
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.MyWebStack = void 0;
const cdk = require("@aws-cdk/core");
const aws_cdk_static_website_1 = require("aws-cdk-static-website");
class MyWebStack extends aws_cdk_static_website_1.StaticWebsiteStack {
constructor(scope, id) {
super(scope, id, props);
}
}
exports.MyWebStack = MyWebStack;
const workingPath = process.cwd();
const pkg = require(`${workingPath}/package.json`);
if (!pkg.webdeploy) {
console.error('Error, package.json should have a "webdeploy" configuration section.');
process.exit(2);
}
let props, stackName;
if (process.env['WEBDEPLOY_CONFIG_NAME'] && pkg.webdeploy[process.env['WEBDEPLOY_CONFIG_NAME'] || '']) {
const configName = process.env['WEBDEPLOY_CONFIG_NAME'];
console.log('Using web deploy configuration:', configName);
stackName = pkg.webdeploy[configName].stackName;
props = {
websiteDistPath: pkg.webdeploy[configName].distPath || pkg.webdeploy[configName].websiteDistPath,
deploymentVersion: pkg.webdeploy[configName].deploymentVersion || pkg.version,
resourcePrefix: pkg.webdeploy[configName].resourcePrefix,
indexDocument: pkg.webdeploy[configName].indexDocument || 'index.html',
certificateArn: pkg.webdeploy[configName].certificateArn,
domainNames: pkg.webdeploy[configName].domainNames,
};
}
else {
stackName = pkg.webdeploy.stackName;
props = {
websiteDistPath: pkg.webdeploy.distPath || pkg.webdeploy.websiteDistPath,
deploymentVersion: pkg.webdeploy.deploymentVersion || pkg.version,
resourcePrefix: pkg.webdeploy.resourcePrefix,
indexDocument: pkg.webdeploy.indexDocument || 'index.html',
certificateArn: pkg.webdeploy.certificateArn,
domainNames: pkg.webdeploy.domainNames,
};
}
console.log('Using the following properties for deployment:');
console.table(props);
const app = new cdk.App();
const stack = new MyWebStack(app, stackName || pkg.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