@fishawack/lab-env 5.6.1 → 5.7.0-beta.10
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/CHANGELOG.md +136 -0
- package/_Test/boilerplate-adonis.js +1 -1
- package/_Test/boilerplate-craftcms.js +1 -1
- package/_Test/boilerplate-drupal.js +1 -1
- package/_Test/boilerplate-laravel.js +1 -1
- package/_Test/boilerplate-python.js +1 -1
- package/_Test/boilerplate-wordpress.js +1 -1
- package/_Test/boilerplate.js +1 -1
- package/_Test/provision.js +4 -9
- package/_Test/prune.js +8 -5
- package/bitbucket-pipelines.yml +2 -2
- package/cli.js +2 -0
- package/commands/create/cmds/dekey.js +13 -9
- package/commands/create/cmds/deprovision.js +66 -6
- package/commands/create/cmds/diagnose.js +10 -0
- package/commands/create/cmds/key.js +74 -41
- package/commands/create/cmds/provision.js +641 -22
- package/commands/create/cmds/rekey.js +283 -0
- package/commands/create/cmds/sync-secrets.js +198 -0
- package/commands/create/libs/output-credentials.js +59 -0
- package/commands/create/libs/parallel-runner.js +296 -0
- package/commands/create/libs/resolve-operator.js +59 -0
- package/commands/create/libs/utilities.js +75 -8
- package/commands/create/libs/vars.js +273 -377
- package/commands/create/services/aws/acm.js +61 -0
- package/commands/create/services/aws/cloudfront.js +51 -45
- package/commands/create/services/aws/ec2.js +781 -5
- package/commands/create/services/aws/elasticache.js +159 -0
- package/commands/create/services/aws/elasticbeanstalk.js +200 -48
- package/commands/create/services/aws/iam.js +430 -82
- package/commands/create/services/aws/index.js +1598 -100
- package/commands/create/services/aws/opensearch.js +155 -0
- package/commands/create/services/aws/rds.js +272 -0
- package/commands/create/services/aws/s3.js +52 -31
- package/commands/create/services/aws/secretsmanager.js +82 -0
- package/commands/create/services/aws/ses.js +203 -0
- package/commands/create/templates/elasticbeanstalk/.ebextensions/laravel/cron.config +45 -0
- package/commands/create/templates/elasticbeanstalk/.ebextensions/laravel/queue-worker.config +29 -0
- package/commands/create/templates/elasticbeanstalk/.ebextensions/laravel/rds-ssl.config +5 -0
- package/commands/create/templates/elasticbeanstalk/.ebextensions/laravel/software.config +12 -0
- package/commands/create/templates/elasticbeanstalk/.ebextensions/misc/setvars.config +1 -0
- package/commands/create/templates/elasticbeanstalk/.platform/confighooks/postdeploy/restart_queue.sh +4 -0
- package/commands/create/templates/elasticbeanstalk/.platform/confighooks/postdeploy/rewrite-flush.sh +1 -1
- package/commands/create/templates/elasticbeanstalk/.platform/confighooks/prebuild/setvars.sh +19 -0
- package/commands/create/templates/elasticbeanstalk/.platform/hooks/postdeploy/restart_queue.sh +4 -0
- package/commands/create/templates/elasticbeanstalk/.platform/hooks/prebuild/setvars.sh +19 -0
- package/commands/scan.js +1 -1
- package/core/1/CHANGELOG.md +41 -0
- package/core/1/Dockerfile +3 -3
- package/core/1/bitbucket-pipelines.yml +5 -5
- package/core/1/package.json +1 -1
- package/globals.js +4 -0
- package/package.json +9 -2
|
@@ -0,0 +1,159 @@
|
|
|
1
|
+
const {
|
|
2
|
+
ElastiCacheClient,
|
|
3
|
+
CreateCacheSubnetGroupCommand,
|
|
4
|
+
CreateReplicationGroupCommand,
|
|
5
|
+
DeleteReplicationGroupCommand,
|
|
6
|
+
DescribeCacheSubnetGroupsCommand,
|
|
7
|
+
DescribeReplicationGroupsCommand,
|
|
8
|
+
} = require("@aws-sdk/client-elasticache");
|
|
9
|
+
const { Spinner, poll } = require("../../libs/utilities");
|
|
10
|
+
const { awsClientConfig } = require("../../libs/vars");
|
|
11
|
+
|
|
12
|
+
const getClient = () => new ElastiCacheClient(awsClientConfig);
|
|
13
|
+
|
|
14
|
+
module.exports.ensureCacheSubnetGroup = async (privateSubnetIds) => {
|
|
15
|
+
const name = "fw-auto-private-cache-subnet-group";
|
|
16
|
+
|
|
17
|
+
try {
|
|
18
|
+
await getClient().send(
|
|
19
|
+
new DescribeCacheSubnetGroupsCommand({
|
|
20
|
+
CacheSubnetGroupName: name,
|
|
21
|
+
}),
|
|
22
|
+
);
|
|
23
|
+
|
|
24
|
+
return name;
|
|
25
|
+
} catch (e) {
|
|
26
|
+
if (e.name !== "CacheSubnetGroupNotFoundFault") {
|
|
27
|
+
throw e;
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
await Spinner.prototype.simple(
|
|
32
|
+
`Creating cache subnet group ${name}`,
|
|
33
|
+
() => {
|
|
34
|
+
return getClient().send(
|
|
35
|
+
new CreateCacheSubnetGroupCommand({
|
|
36
|
+
CacheSubnetGroupName: name,
|
|
37
|
+
CacheSubnetGroupDescription:
|
|
38
|
+
"Private subnets for lab-env ElastiCache clusters",
|
|
39
|
+
SubnetIds: privateSubnetIds,
|
|
40
|
+
}),
|
|
41
|
+
);
|
|
42
|
+
},
|
|
43
|
+
);
|
|
44
|
+
|
|
45
|
+
return name;
|
|
46
|
+
};
|
|
47
|
+
|
|
48
|
+
module.exports.createCacheCluster = async (
|
|
49
|
+
name,
|
|
50
|
+
securityGroupId,
|
|
51
|
+
subnetGroupName,
|
|
52
|
+
authToken,
|
|
53
|
+
tags = [],
|
|
54
|
+
) => {
|
|
55
|
+
const res = await Spinner.prototype.simple(
|
|
56
|
+
`Creating ElastiCache cluster ${name}`,
|
|
57
|
+
() => {
|
|
58
|
+
return getClient().send(
|
|
59
|
+
new CreateReplicationGroupCommand({
|
|
60
|
+
ReplicationGroupId: name,
|
|
61
|
+
ReplicationGroupDescription: `lab-env Valkey cluster for ${name}`,
|
|
62
|
+
Engine: "valkey",
|
|
63
|
+
EngineVersion: "8.0",
|
|
64
|
+
CacheNodeType: "cache.t3.small",
|
|
65
|
+
NumCacheClusters: 1,
|
|
66
|
+
Port: 6380,
|
|
67
|
+
TransitEncryptionEnabled: true,
|
|
68
|
+
AuthToken: authToken,
|
|
69
|
+
CacheSubnetGroupName: subnetGroupName,
|
|
70
|
+
SecurityGroupIds: [securityGroupId],
|
|
71
|
+
Tags: [
|
|
72
|
+
{ Key: "client", Value: process.env.AWS_PROFILE },
|
|
73
|
+
].concat(tags),
|
|
74
|
+
}),
|
|
75
|
+
);
|
|
76
|
+
},
|
|
77
|
+
);
|
|
78
|
+
|
|
79
|
+
return res;
|
|
80
|
+
};
|
|
81
|
+
|
|
82
|
+
module.exports.waitForCacheCluster = async (name) => {
|
|
83
|
+
const res = await Spinner.prototype.simple(
|
|
84
|
+
`Waiting for ElastiCache cluster to become available`,
|
|
85
|
+
(spinner) => {
|
|
86
|
+
return poll(
|
|
87
|
+
async () => {
|
|
88
|
+
const { ReplicationGroups } = await getClient().send(
|
|
89
|
+
new DescribeReplicationGroupsCommand({
|
|
90
|
+
ReplicationGroupId: name,
|
|
91
|
+
}),
|
|
92
|
+
);
|
|
93
|
+
return ReplicationGroups[0];
|
|
94
|
+
},
|
|
95
|
+
(group) => group.Status !== "available",
|
|
96
|
+
undefined,
|
|
97
|
+
spinner,
|
|
98
|
+
);
|
|
99
|
+
},
|
|
100
|
+
);
|
|
101
|
+
|
|
102
|
+
return res;
|
|
103
|
+
};
|
|
104
|
+
|
|
105
|
+
module.exports.describeCacheCluster = async (name) => {
|
|
106
|
+
const res = await Spinner.prototype.simple(
|
|
107
|
+
`Describing ElastiCache cluster ${name}`,
|
|
108
|
+
() => {
|
|
109
|
+
return getClient().send(
|
|
110
|
+
new DescribeReplicationGroupsCommand({
|
|
111
|
+
ReplicationGroupId: name,
|
|
112
|
+
}),
|
|
113
|
+
);
|
|
114
|
+
},
|
|
115
|
+
);
|
|
116
|
+
|
|
117
|
+
return res.ReplicationGroups[0];
|
|
118
|
+
};
|
|
119
|
+
|
|
120
|
+
module.exports.deleteCacheCluster = async (name) => {
|
|
121
|
+
await Spinner.prototype.simple(
|
|
122
|
+
`Deleting ElastiCache cluster ${name}`,
|
|
123
|
+
() => {
|
|
124
|
+
return getClient().send(
|
|
125
|
+
new DeleteReplicationGroupCommand({
|
|
126
|
+
ReplicationGroupId: name,
|
|
127
|
+
}),
|
|
128
|
+
);
|
|
129
|
+
},
|
|
130
|
+
);
|
|
131
|
+
};
|
|
132
|
+
|
|
133
|
+
module.exports.waitForCacheDeletion = async (name) => {
|
|
134
|
+
await Spinner.prototype.simple(
|
|
135
|
+
`Waiting for ElastiCache cluster to be deleted`,
|
|
136
|
+
(spinner) => {
|
|
137
|
+
return poll(
|
|
138
|
+
async () => {
|
|
139
|
+
try {
|
|
140
|
+
const { ReplicationGroups } = await getClient().send(
|
|
141
|
+
new DescribeReplicationGroupsCommand({
|
|
142
|
+
ReplicationGroupId: name,
|
|
143
|
+
}),
|
|
144
|
+
);
|
|
145
|
+
return ReplicationGroups[0];
|
|
146
|
+
} catch (e) {
|
|
147
|
+
if (e.name === "ReplicationGroupNotFoundFault") {
|
|
148
|
+
return { deleted: true };
|
|
149
|
+
}
|
|
150
|
+
throw e;
|
|
151
|
+
}
|
|
152
|
+
},
|
|
153
|
+
(group) => !group.deleted,
|
|
154
|
+
undefined,
|
|
155
|
+
spinner,
|
|
156
|
+
);
|
|
157
|
+
},
|
|
158
|
+
);
|
|
159
|
+
};
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
const fs = require("fs-extra");
|
|
2
|
+
const crypto = require("crypto");
|
|
2
3
|
const glob = require("glob");
|
|
4
|
+
const inquirer = require("inquirer");
|
|
3
5
|
const {
|
|
4
6
|
ElasticBeanstalkClient,
|
|
5
7
|
CreateApplicationCommand,
|
|
@@ -10,20 +12,30 @@ const {
|
|
|
10
12
|
DescribeEnvironmentsCommand,
|
|
11
13
|
DescribeApplicationsCommand,
|
|
12
14
|
DescribeApplicationVersionsCommand,
|
|
15
|
+
DescribeConfigurationSettingsCommand,
|
|
16
|
+
UpdateEnvironmentCommand,
|
|
13
17
|
CreateApplicationVersionCommand,
|
|
14
18
|
ListAvailableSolutionStacksCommand,
|
|
19
|
+
ListTagsForResourceCommand,
|
|
20
|
+
RestartAppServerCommand,
|
|
15
21
|
} = require("@aws-sdk/client-elastic-beanstalk");
|
|
16
22
|
const { Spinner, poll } = require("../../libs/utilities");
|
|
17
|
-
const { eb } = require("../../libs/vars");
|
|
23
|
+
const { eb, secretGroups, awsClientConfig } = require("../../libs/vars");
|
|
24
|
+
const { template } = require("lodash");
|
|
18
25
|
|
|
19
|
-
|
|
20
|
-
const client = new ElasticBeanstalkClient({});
|
|
26
|
+
const getClient = () => new ElasticBeanstalkClient(awsClientConfig);
|
|
21
27
|
|
|
28
|
+
module.exports.createElasticBeanstalkApplication = async (name, tags = []) => {
|
|
22
29
|
let res = await Spinner.prototype.simple(
|
|
23
30
|
`Creating elasticbeanstalk application ${name}`,
|
|
24
31
|
() => {
|
|
25
|
-
return
|
|
26
|
-
new CreateApplicationCommand({
|
|
32
|
+
return getClient().send(
|
|
33
|
+
new CreateApplicationCommand({
|
|
34
|
+
ApplicationName: name,
|
|
35
|
+
Tags: [
|
|
36
|
+
{ Key: "client", Value: process.env.AWS_PROFILE },
|
|
37
|
+
].concat(tags),
|
|
38
|
+
}),
|
|
27
39
|
);
|
|
28
40
|
},
|
|
29
41
|
);
|
|
@@ -31,6 +43,37 @@ module.exports.createElasticBeanstalkApplication = async (name) => {
|
|
|
31
43
|
return res;
|
|
32
44
|
};
|
|
33
45
|
|
|
46
|
+
module.exports.describeEnvironment = async (name) => {
|
|
47
|
+
return getClient().send(
|
|
48
|
+
new DescribeEnvironmentsCommand({
|
|
49
|
+
EnvironmentNames: [name],
|
|
50
|
+
}),
|
|
51
|
+
);
|
|
52
|
+
};
|
|
53
|
+
|
|
54
|
+
module.exports.listEnvironments = async (applicationName) => {
|
|
55
|
+
const res = await Spinner.prototype.simple(
|
|
56
|
+
`Retrieving environments for ${applicationName}`,
|
|
57
|
+
() => {
|
|
58
|
+
return getClient().send(
|
|
59
|
+
new DescribeEnvironmentsCommand({
|
|
60
|
+
ApplicationName: applicationName,
|
|
61
|
+
IncludeDeleted: false,
|
|
62
|
+
}),
|
|
63
|
+
);
|
|
64
|
+
},
|
|
65
|
+
);
|
|
66
|
+
|
|
67
|
+
return (res.Environments || []).filter((e) => e.Status !== "Terminated");
|
|
68
|
+
};
|
|
69
|
+
|
|
70
|
+
module.exports.getEnvironmentTags = async (environmentArn) => {
|
|
71
|
+
const res = await getClient().send(
|
|
72
|
+
new ListTagsForResourceCommand({ ResourceArn: environmentArn }),
|
|
73
|
+
);
|
|
74
|
+
return res.ResourceTags || [];
|
|
75
|
+
};
|
|
76
|
+
|
|
34
77
|
module.exports.createElasticBeanstalkEnvironment = async (
|
|
35
78
|
name,
|
|
36
79
|
{ language },
|
|
@@ -38,13 +81,12 @@ module.exports.createElasticBeanstalkEnvironment = async (
|
|
|
38
81
|
OptionSettings,
|
|
39
82
|
CNAMEPrefix,
|
|
40
83
|
tags = [],
|
|
84
|
+
versionLabel,
|
|
41
85
|
) => {
|
|
42
|
-
const client = new ElasticBeanstalkClient({});
|
|
43
|
-
|
|
44
86
|
const solutions = await Spinner.prototype.simple(
|
|
45
87
|
`Retrieving available solution stacks`,
|
|
46
88
|
() => {
|
|
47
|
-
return
|
|
89
|
+
return getClient().send(new ListAvailableSolutionStacksCommand());
|
|
48
90
|
},
|
|
49
91
|
);
|
|
50
92
|
|
|
@@ -62,21 +104,23 @@ module.exports.createElasticBeanstalkEnvironment = async (
|
|
|
62
104
|
d.includes(stackName),
|
|
63
105
|
)[0];
|
|
64
106
|
|
|
107
|
+
const createParams = {
|
|
108
|
+
ApplicationName,
|
|
109
|
+
EnvironmentName: name,
|
|
110
|
+
SolutionStackName,
|
|
111
|
+
OptionSettings,
|
|
112
|
+
CNAMEPrefix,
|
|
113
|
+
Tags: [{ Key: "client", Value: process.env.AWS_PROFILE }].concat(tags),
|
|
114
|
+
};
|
|
115
|
+
|
|
116
|
+
if (versionLabel) {
|
|
117
|
+
createParams.VersionLabel = versionLabel;
|
|
118
|
+
}
|
|
119
|
+
|
|
65
120
|
await Spinner.prototype.simple(
|
|
66
121
|
`Creating elasticbeanstalk environment ${name}`,
|
|
67
122
|
() => {
|
|
68
|
-
return
|
|
69
|
-
new CreateEnvironmentCommand({
|
|
70
|
-
ApplicationName,
|
|
71
|
-
EnvironmentName: name,
|
|
72
|
-
SolutionStackName,
|
|
73
|
-
OptionSettings,
|
|
74
|
-
CNAMEPrefix,
|
|
75
|
-
Tags: [
|
|
76
|
-
{ Key: "client", Value: process.env.AWS_PROFILE },
|
|
77
|
-
].concat(tags),
|
|
78
|
-
}),
|
|
79
|
-
);
|
|
123
|
+
return getClient().send(new CreateEnvironmentCommand(createParams));
|
|
80
124
|
},
|
|
81
125
|
);
|
|
82
126
|
|
|
@@ -99,12 +143,10 @@ module.exports.waitForElasticBeanstalkEnvironment = async (
|
|
|
99
143
|
waitFor = "Ready",
|
|
100
144
|
failIf,
|
|
101
145
|
) => {
|
|
102
|
-
const client = new ElasticBeanstalkClient({});
|
|
103
|
-
|
|
104
146
|
const res = await poll(
|
|
105
147
|
async () =>
|
|
106
148
|
(
|
|
107
|
-
await
|
|
149
|
+
await getClient().send(
|
|
108
150
|
new DescribeEnvironmentsCommand({
|
|
109
151
|
EnvironmentNames: [name],
|
|
110
152
|
}),
|
|
@@ -118,12 +160,10 @@ module.exports.waitForElasticBeanstalkEnvironment = async (
|
|
|
118
160
|
};
|
|
119
161
|
|
|
120
162
|
module.exports.removeElasticBeanstalkApplication = async (name) => {
|
|
121
|
-
const client = new ElasticBeanstalkClient({});
|
|
122
|
-
|
|
123
163
|
await Spinner.prototype.simple(
|
|
124
164
|
`Removing elasticbeanstalk application ${name}`,
|
|
125
165
|
() => {
|
|
126
|
-
return
|
|
166
|
+
return getClient().send(
|
|
127
167
|
new DeleteApplicationCommand({ ApplicationName: name }),
|
|
128
168
|
);
|
|
129
169
|
},
|
|
@@ -131,12 +171,10 @@ module.exports.removeElasticBeanstalkApplication = async (name) => {
|
|
|
131
171
|
};
|
|
132
172
|
|
|
133
173
|
module.exports.removeElasticBeanstalkEnvironment = async (name) => {
|
|
134
|
-
const client = new ElasticBeanstalkClient({});
|
|
135
|
-
|
|
136
174
|
await Spinner.prototype.simple(
|
|
137
175
|
`Removing elasticbeanstalk environment ${name}`,
|
|
138
176
|
() => {
|
|
139
|
-
return
|
|
177
|
+
return getClient().send(
|
|
140
178
|
new TerminateEnvironmentCommand({ EnvironmentName: name }),
|
|
141
179
|
);
|
|
142
180
|
},
|
|
@@ -148,30 +186,99 @@ module.exports.removeElasticBeanstalkEnvironment = async (name) => {
|
|
|
148
186
|
return module.exports.waitForElasticBeanstalkEnvironment(
|
|
149
187
|
name,
|
|
150
188
|
"Terminated",
|
|
189
|
+
"Ready",
|
|
151
190
|
);
|
|
152
191
|
},
|
|
153
192
|
);
|
|
154
193
|
};
|
|
155
194
|
|
|
156
|
-
module.exports.copyElasticBeanstalkConfigs = async (configurations) => {
|
|
195
|
+
module.exports.copyElasticBeanstalkConfigs = async (configurations, branch) => {
|
|
157
196
|
const templates = `${__dirname}/../../templates/elasticbeanstalk`;
|
|
197
|
+
const templateData = {
|
|
198
|
+
...process.env,
|
|
199
|
+
SECRET_GROUPS: secretGroups.join(" "),
|
|
200
|
+
};
|
|
201
|
+
|
|
202
|
+
const checksumPath = `_IaC/${branch}/.lab-env-checksums.json`;
|
|
203
|
+
const checksums = fs.existsSync(checksumPath)
|
|
204
|
+
? JSON.parse(fs.readFileSync(checksumPath, "utf8"))
|
|
205
|
+
: {};
|
|
206
|
+
|
|
207
|
+
for (const globbed of configurations) {
|
|
208
|
+
const files = glob.sync(globbed, { cwd: `${templates}` });
|
|
209
|
+
|
|
210
|
+
for (const config of files) {
|
|
211
|
+
const content = fs.readFileSync(`${templates}/${config}`, "utf8");
|
|
212
|
+
const output = content.includes("<%=")
|
|
213
|
+
? template(content, { interpolate: /<%=([\s\S]+?)%>/g })(
|
|
214
|
+
templateData,
|
|
215
|
+
)
|
|
216
|
+
: content;
|
|
217
|
+
|
|
218
|
+
const dest = `_IaC/${branch}/${config}`;
|
|
219
|
+
const newHash = crypto
|
|
220
|
+
.createHash("md5")
|
|
221
|
+
.update(output)
|
|
222
|
+
.digest("hex");
|
|
223
|
+
|
|
224
|
+
if (fs.existsSync(dest)) {
|
|
225
|
+
const existing = fs.readFileSync(dest, "utf8");
|
|
226
|
+
|
|
227
|
+
if (existing === output) {
|
|
228
|
+
checksums[config] = newHash;
|
|
229
|
+
continue;
|
|
230
|
+
}
|
|
231
|
+
|
|
232
|
+
const existingHash = crypto
|
|
233
|
+
.createHash("md5")
|
|
234
|
+
.update(existing)
|
|
235
|
+
.digest("hex");
|
|
236
|
+
|
|
237
|
+
let shouldOverwrite;
|
|
238
|
+
|
|
239
|
+
if (checksums[config] && existingHash === checksums[config]) {
|
|
240
|
+
const { overwrite } = await inquirer.prompt([
|
|
241
|
+
{
|
|
242
|
+
type: "confirm",
|
|
243
|
+
name: "overwrite",
|
|
244
|
+
message: `${dest} has an updated template, overwrite?`,
|
|
245
|
+
default: true,
|
|
246
|
+
},
|
|
247
|
+
]);
|
|
248
|
+
shouldOverwrite = overwrite;
|
|
249
|
+
} else {
|
|
250
|
+
const { overwrite } = await inquirer.prompt([
|
|
251
|
+
{
|
|
252
|
+
type: "confirm",
|
|
253
|
+
name: "overwrite",
|
|
254
|
+
message: `${dest} has been modified, overwrite?`,
|
|
255
|
+
default: false,
|
|
256
|
+
},
|
|
257
|
+
]);
|
|
258
|
+
shouldOverwrite = overwrite;
|
|
259
|
+
}
|
|
260
|
+
|
|
261
|
+
if (!shouldOverwrite) continue;
|
|
262
|
+
}
|
|
263
|
+
|
|
264
|
+
fs.outputFileSync(dest, output);
|
|
265
|
+
checksums[config] = newHash;
|
|
266
|
+
}
|
|
267
|
+
}
|
|
158
268
|
|
|
159
|
-
|
|
160
|
-
glob.sync(globbed, { cwd: `${templates}` }).forEach((config) =>
|
|
161
|
-
fs.copySync(`${templates}/${config}`, config),
|
|
162
|
-
);
|
|
163
|
-
});
|
|
269
|
+
fs.outputFileSync(checksumPath, JSON.stringify(checksums, null, 4) + "\n");
|
|
164
270
|
|
|
165
|
-
fs.outputFileSync(
|
|
271
|
+
fs.outputFileSync(
|
|
272
|
+
`_IaC/${branch}/.elasticbeanstalk/config.yml`,
|
|
273
|
+
eb.config(),
|
|
274
|
+
);
|
|
166
275
|
};
|
|
167
276
|
|
|
168
277
|
module.exports.listApplications = async () => {
|
|
169
|
-
const client = new ElasticBeanstalkClient({});
|
|
170
|
-
|
|
171
278
|
const res = await Spinner.prototype.simple(
|
|
172
279
|
`Retrieving elasticbeanstalk applications`,
|
|
173
280
|
() => {
|
|
174
|
-
return
|
|
281
|
+
return getClient().send(new DescribeApplicationsCommand({}));
|
|
175
282
|
},
|
|
176
283
|
);
|
|
177
284
|
|
|
@@ -179,13 +286,11 @@ module.exports.listApplications = async () => {
|
|
|
179
286
|
};
|
|
180
287
|
|
|
181
288
|
module.exports.listApplicationVersions = async (applicationName) => {
|
|
182
|
-
const client = new ElasticBeanstalkClient({});
|
|
183
|
-
|
|
184
289
|
let versions = [];
|
|
185
290
|
let nextToken;
|
|
186
291
|
|
|
187
292
|
do {
|
|
188
|
-
const res = await
|
|
293
|
+
const res = await getClient().send(
|
|
189
294
|
new DescribeApplicationVersionsCommand({
|
|
190
295
|
ApplicationName: applicationName,
|
|
191
296
|
...(nextToken ? { NextToken: nextToken } : {}),
|
|
@@ -203,9 +308,7 @@ module.exports.createApplicationVersion = async (
|
|
|
203
308
|
applicationName,
|
|
204
309
|
versionLabel,
|
|
205
310
|
) => {
|
|
206
|
-
const
|
|
207
|
-
|
|
208
|
-
const res = await client.send(
|
|
311
|
+
const res = await getClient().send(
|
|
209
312
|
new CreateApplicationVersionCommand({
|
|
210
313
|
ApplicationName: applicationName,
|
|
211
314
|
VersionLabel: versionLabel,
|
|
@@ -220,9 +323,7 @@ module.exports.deleteApplicationVersion = async (
|
|
|
220
323
|
applicationName,
|
|
221
324
|
versionLabel,
|
|
222
325
|
) => {
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
await client.send(
|
|
326
|
+
await getClient().send(
|
|
226
327
|
new DeleteApplicationVersionCommand({
|
|
227
328
|
ApplicationName: applicationName,
|
|
228
329
|
VersionLabel: versionLabel,
|
|
@@ -230,3 +331,54 @@ module.exports.deleteApplicationVersion = async (
|
|
|
230
331
|
}),
|
|
231
332
|
);
|
|
232
333
|
};
|
|
334
|
+
|
|
335
|
+
module.exports.describeConfigurationSettings = async (
|
|
336
|
+
applicationName,
|
|
337
|
+
environmentName,
|
|
338
|
+
) => {
|
|
339
|
+
const res = await Spinner.prototype.simple(
|
|
340
|
+
`Retrieving configuration for ${environmentName}`,
|
|
341
|
+
() => {
|
|
342
|
+
return getClient().send(
|
|
343
|
+
new DescribeConfigurationSettingsCommand({
|
|
344
|
+
ApplicationName: applicationName,
|
|
345
|
+
EnvironmentName: environmentName,
|
|
346
|
+
}),
|
|
347
|
+
);
|
|
348
|
+
},
|
|
349
|
+
);
|
|
350
|
+
|
|
351
|
+
return res.ConfigurationSettings[0]?.OptionSettings || [];
|
|
352
|
+
};
|
|
353
|
+
|
|
354
|
+
module.exports.updateEnvironmentSettings = async (
|
|
355
|
+
environmentName,
|
|
356
|
+
optionSettings = [],
|
|
357
|
+
optionsToRemove = [],
|
|
358
|
+
) => {
|
|
359
|
+
await Spinner.prototype.simple(
|
|
360
|
+
`Updating environment ${environmentName}`,
|
|
361
|
+
() => {
|
|
362
|
+
return getClient().send(
|
|
363
|
+
new UpdateEnvironmentCommand({
|
|
364
|
+
EnvironmentName: environmentName,
|
|
365
|
+
OptionSettings: optionSettings,
|
|
366
|
+
OptionsToRemove: optionsToRemove,
|
|
367
|
+
}),
|
|
368
|
+
);
|
|
369
|
+
},
|
|
370
|
+
);
|
|
371
|
+
};
|
|
372
|
+
|
|
373
|
+
module.exports.restartAppServer = async (environmentName) => {
|
|
374
|
+
await Spinner.prototype.simple(
|
|
375
|
+
`Restarting app server for ${environmentName}`,
|
|
376
|
+
() => {
|
|
377
|
+
return getClient().send(
|
|
378
|
+
new RestartAppServerCommand({
|
|
379
|
+
EnvironmentName: environmentName,
|
|
380
|
+
}),
|
|
381
|
+
);
|
|
382
|
+
},
|
|
383
|
+
);
|
|
384
|
+
};
|