@axway/axway-central-cli 2.17.0 → 2.18.0-rc.0

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.
Files changed (58) hide show
  1. package/dist/cli.js +6 -28
  2. package/dist/commands/apply/index.js +9 -24
  3. package/dist/commands/completion/index.js +3 -9
  4. package/dist/commands/config/common/index.js +2 -11
  5. package/dist/commands/config/index.js +2 -7
  6. package/dist/commands/config/list.js +2 -6
  7. package/dist/commands/config/set.js +4 -31
  8. package/dist/commands/config/unset.js +2 -12
  9. package/dist/commands/create/agentResource.js +12 -32
  10. package/dist/commands/create/environment.js +6 -16
  11. package/dist/commands/create/index.js +9 -26
  12. package/dist/commands/create/serviceAccount.js +2 -6
  13. package/dist/commands/delete/index.js +15 -33
  14. package/dist/commands/edit/environment.js +6 -21
  15. package/dist/commands/edit/index.js +4 -8
  16. package/dist/commands/get/index.js +27 -44
  17. package/dist/commands/install/agents.js +44 -73
  18. package/dist/commands/install/apigeexSaasAgents.js +35 -98
  19. package/dist/commands/install/awsAgents.js +89 -139
  20. package/dist/commands/install/awsSaasAgents.js +50 -142
  21. package/dist/commands/install/azureAgents.js +39 -79
  22. package/dist/commands/install/edgeAgents.js +17 -110
  23. package/dist/commands/install/gitHubSaasAgents.js +286 -0
  24. package/dist/commands/install/helpers/creators.js +17 -70
  25. package/dist/commands/install/helpers/deleters.js +2 -11
  26. package/dist/commands/install/helpers/getters.js +4 -30
  27. package/dist/commands/install/helpers/index.js +13 -48
  28. package/dist/commands/install/helpers/inputs.js +26 -98
  29. package/dist/commands/install/helpers/regex.js +29 -34
  30. package/dist/commands/install/helpers/templates/awsTemplates.js +6 -23
  31. package/dist/commands/install/helpers/templates/azureTemplates.js +5 -24
  32. package/dist/commands/install/helpers/templates/edgeTemplates.js +7 -38
  33. package/dist/commands/install/helpers/templates/istioTemplates.js +5 -16
  34. package/dist/commands/install/index.js +4 -10
  35. package/dist/commands/install/istioAgents.js +40 -117
  36. package/dist/commands/install/platform.js +20 -52
  37. package/dist/commands/proxies/create.js +2 -18
  38. package/dist/commands/proxies/index.js +4 -8
  39. package/dist/commands/proxies/promote.js +2 -21
  40. package/dist/common/ApiServerClient.js +64 -173
  41. package/dist/common/CacheController.js +11 -32
  42. package/dist/common/CliConfigManager.js +14 -27
  43. package/dist/common/CompositeError.js +6 -30
  44. package/dist/common/CoreConfigController.js +18 -40
  45. package/dist/common/DefinitionsManager.js +29 -76
  46. package/dist/common/Kubectl.js +2 -25
  47. package/dist/common/PlatformClient.js +19 -63
  48. package/dist/common/Renderer.js +25 -87
  49. package/dist/common/TmpFile.js +11 -28
  50. package/dist/common/bashCommands.js +3 -22
  51. package/dist/common/basicPrompts.js +8 -43
  52. package/dist/common/dataService.js +22 -50
  53. package/dist/common/errorHandler.js +0 -9
  54. package/dist/common/resultsRenderers.js +10 -42
  55. package/dist/common/types.js +116 -341
  56. package/dist/common/utils.js +37 -99
  57. package/dist/main.js +0 -2
  58. package/package.json +2 -2
@@ -4,48 +4,32 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.testables = exports.installPreprocess = exports.gatewayConnectivity = exports.completeInstall = exports.askConfigType = exports.askBundleType = exports.DeploymentTypes = exports.ConfigFiles = exports.AWSPrompts = exports.AWSInstallMethods = void 0;
7
-
8
7
  var _chalk = _interopRequireDefault(require("chalk"));
9
-
10
8
  var _fs = _interopRequireDefault(require("fs"));
11
-
12
9
  var _snooplogg = _interopRequireDefault(require("snooplogg"));
13
-
14
10
  var _basicPrompts = require("../../common/basicPrompts");
15
-
16
11
  var _dataService = require("../../common/dataService");
17
-
18
12
  var _types = require("../../common/types");
19
-
20
13
  var _utils = require("../../common/utils");
21
-
22
14
  var helpers = _interopRequireWildcard(require("./helpers"));
23
-
24
- function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
25
-
26
- function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
27
-
15
+ function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
16
+ function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && Object.prototype.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
28
17
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
29
-
30
18
  const {
31
19
  log
32
20
  } = (0, _snooplogg.default)('central: install: agents: aws');
33
21
  const daImage = `${_types.PublicDockerRepoBaseUrl}${_types.BasePaths.DockerAgentPublicRepo}/${_types.AgentNames.AWS_DA}`;
34
- const taImage = `${_types.PublicDockerRepoBaseUrl}${_types.BasePaths.DockerAgentPublicRepo}/${_types.AgentNames.AWS_TA}`; // DeploymentTypes - ways the agents may be deployed with an AWS APIGW setup
35
-
36
- let DeploymentTypes; // EC2InstanceTypes - instance types allowed in cloud formation document
37
-
38
- exports.DeploymentTypes = DeploymentTypes;
22
+ const taImage = `${_types.PublicDockerRepoBaseUrl}${_types.BasePaths.DockerAgentPublicRepo}/${_types.AgentNames.AWS_TA}`;
39
23
 
40
- (function (DeploymentTypes) {
24
+ // DeploymentTypes - ways the agents may be deployed with an AWS APIGW setup
25
+ let DeploymentTypes = exports.DeploymentTypes = /*#__PURE__*/function (DeploymentTypes) {
41
26
  DeploymentTypes["EC2"] = "EC2";
42
27
  DeploymentTypes["ECS_FARGATE"] = "ECS Fargate";
43
28
  DeploymentTypes["OTHER"] = "Other";
44
- })(DeploymentTypes || (exports.DeploymentTypes = DeploymentTypes = {}));
45
-
46
- var EC2InstanceTypes;
47
-
48
- (function (EC2InstanceTypes) {
29
+ return DeploymentTypes;
30
+ }({}); //Docker Container Only
31
+ // EC2InstanceTypes - instance types allowed in cloud formation document
32
+ var EC2InstanceTypes = /*#__PURE__*/function (EC2InstanceTypes) {
49
33
  EC2InstanceTypes["T3_MICRO"] = "t3.micro";
50
34
  EC2InstanceTypes["T3_NAN0"] = "t3.nano";
51
35
  EC2InstanceTypes["T3_SMALL"] = "t3.small";
@@ -53,16 +37,17 @@ var EC2InstanceTypes;
53
37
  EC2InstanceTypes["T3_LARGE"] = "t3.large";
54
38
  EC2InstanceTypes["T3_XLARGE"] = "t3.xlarge";
55
39
  EC2InstanceTypes["T3_2XLARGE"] = "t3.2xlarge";
56
- })(EC2InstanceTypes || (EC2InstanceTypes = {}));
57
-
40
+ return EC2InstanceTypes;
41
+ }(EC2InstanceTypes || {});
58
42
  const InvalidMsg = {
59
43
  S3_BUCKET: `S3 Bucket Name can contain digits '0-9', lower case letters 'a-z', hyphens '-', and periods '.' with 3-63 characters. Must begin and end with number or letter`,
60
44
  LOG_GROUP: `Log Group Name can contain digits '0-9', letters 'a-z' and 'A-Z', underscores '_', hyphens '-', forward slash '/', and periods '.' with a maximum length of 512 characters`,
61
45
  SQS_QUEUE: `SQS Queue Name can contain digits '0-9', letters 'a-z' and 'A-Z', underscores '_', and hyphens '-' with a maximum length of 80 characters`,
62
46
  CLUSTER_NAME: `ECS fargate cluster name can contain digits '0-9', letters 'a-z' and 'A-Z', underscores '_', and hyphens '-' with a maximum length of 255 characters`
63
- }; // ConfigFiles - all the config file that are used in the setup
47
+ };
64
48
 
65
- const ConfigFiles = {
49
+ // ConfigFiles - all the config file that are used in the setup
50
+ const ConfigFiles = exports.ConfigFiles = {
66
51
  ContinuousZip: 'cloudformation-continuous-discovery.zip',
67
52
  SynchronousZip: 'cloudformation-synchronous-discovery.zip',
68
53
  DeployAllYAML: 'amplify-agents-deploy-all.yaml',
@@ -74,10 +59,10 @@ const ConfigFiles = {
74
59
  DAEnvVars: `${helpers.configFiles.DA_ENV_VARS}`,
75
60
  TAEnvVars: `${helpers.configFiles.TA_ENV_VARS}`,
76
61
  CFProperties: 'cloudformation_properties.json'
77
- }; // AWSPrompts - all prompts to the user for input
62
+ };
78
63
 
79
- exports.ConfigFiles = ConfigFiles;
80
- const AWSPrompts = {
64
+ // AWSPrompts - all prompts to the user for input
65
+ const AWSPrompts = exports.AWSPrompts = {
81
66
  APIGW_LOG_GROUP: 'Enter the Log Group name to track API Gateway traffic events',
82
67
  CLUSTER_NAME: 'Enter the ECS fargate cluster name to deploy the ECS task for the agents',
83
68
  CONFIG_BUCKET: 'Enter the S3 bucket the config service will use to track config changes',
@@ -100,23 +85,18 @@ const AWSPrompts = {
100
85
  TA_QUEUE: 'Enter the traceability queue name',
101
86
  VPC_ID: 'Enter the VPC ID to deploy the EC2 instance to. Leave blank to create entire infrastructure'
102
87
  };
103
- exports.AWSPrompts = AWSPrompts;
104
-
105
88
  const askBundleType = async () => {
106
89
  return _types.BundleType.ALL_AGENTS;
107
90
  };
108
-
109
91
  exports.askBundleType = askBundleType;
110
-
111
92
  const askConfigType = async () => {
112
93
  return _types.AgentConfigTypes.DOCKERIZED;
113
- }; //
94
+ };
95
+
96
+ //
114
97
  // Complex prompts
115
98
  //
116
-
117
-
118
99
  exports.askConfigType = askConfigType;
119
-
120
100
  const askDeployment = async () => {
121
101
  return (0, _basicPrompts.askList)({
122
102
  msg: AWSPrompts.DEPLOYMENT,
@@ -132,9 +112,9 @@ const askDeployment = async () => {
132
112
  }],
133
113
  default: DeploymentTypes.EC2
134
114
  });
135
- }; // askToCreateRoleSetup - asks a Yes/No question for creating the APIGW IAM role, returns a True/False string for CloudFormation parameters
136
-
115
+ };
137
116
 
117
+ // askToCreateRoleSetup - asks a Yes/No question for creating the APIGW IAM role, returns a True/False string for CloudFormation parameters
138
118
  const askToCreateRoleSetup = async () => {
139
119
  return (await (0, _basicPrompts.askList)({
140
120
  msg: AWSPrompts.SETUP_APIGW_CW,
@@ -142,21 +122,18 @@ const askToCreateRoleSetup = async () => {
142
122
  default: _types.YesNo.Yes
143
123
  })) === _types.YesNo.Yes ? _types.TrueFalse.True.toLowerCase() : _types.TrueFalse.False.toLowerCase();
144
124
  };
145
-
146
125
  const askConfigSvcSetup = async awsAgentValues => {
147
126
  awsAgentValues.cloudFormationConfig.ConfigServiceSetup = (await (0, _basicPrompts.askList)({
148
127
  msg: AWSPrompts.CONFIG_SERVICE,
149
128
  choices: _types.YesNoChoices,
150
129
  default: _types.YesNo.Yes
151
130
  })) === _types.YesNo.Yes ? _types.TrueFalse.True.toLowerCase() : _types.TrueFalse.False.toLowerCase();
152
-
153
131
  if (awsAgentValues.cloudFormationConfig.ConfigServiceSetup === _types.TrueFalse.True.toLowerCase()) {
154
132
  awsAgentValues.cloudFormationConfig.ConfigBucketName = await (0, _basicPrompts.askInput)({
155
133
  msg: AWSPrompts.CONFIG_BUCKET,
156
134
  defaultValue: awsAgentValues.cloudFormationConfig.AgentResourcesBucket,
157
135
  validate: (0, _basicPrompts.validateRegex)(helpers.AWSRegexPatterns.AWS_REGEXP, InvalidMsg.S3_BUCKET)
158
136
  });
159
-
160
137
  if (awsAgentValues.cloudFormationConfig.ConfigBucketName !== awsAgentValues.cloudFormationConfig.AgentResourcesBucket) {
161
138
  awsAgentValues.cloudFormationConfig.ConfigBucketExists = (await (0, _basicPrompts.askList)({
162
139
  msg: AWSPrompts.CONFIG_BUCKET_EXISTS,
@@ -165,11 +142,10 @@ const askConfigSvcSetup = async awsAgentValues => {
165
142
  })) === _types.YesNo.Yes ? _types.TrueFalse.True.toLowerCase() : _types.TrueFalse.False.toLowerCase();
166
143
  }
167
144
  }
168
-
169
145
  return awsAgentValues;
170
- }; // askToUsePublicIpAddress - asks a Yes/No question for setting a public IP address, returns a True/False string for CloudFormation parameters
171
-
146
+ };
172
147
 
148
+ // askToUsePublicIpAddress - asks a Yes/No question for setting a public IP address, returns a True/False string for CloudFormation parameters
173
149
  const askToUsePublicIpAddress = async () => {
174
150
  return (await (0, _basicPrompts.askList)({
175
151
  msg: AWSPrompts.PUBLIC_IP,
@@ -177,7 +153,6 @@ const askToUsePublicIpAddress = async () => {
177
153
  default: _types.YesNo.Yes
178
154
  })) === _types.YesNo.Yes ? _types.TrueFalse.True.toLowerCase() : _types.TrueFalse.False.toLowerCase();
179
155
  };
180
-
181
156
  const askEC2InstanceType = async () => {
182
157
  return await (0, _basicPrompts.askList)({
183
158
  msg: AWSPrompts.EC2_TYPE,
@@ -206,23 +181,19 @@ const askEC2InstanceType = async () => {
206
181
  default: EC2InstanceTypes.T3_MICRO
207
182
  });
208
183
  };
209
-
210
184
  const askEC2VPCConfig = async awsAgentValues => {
211
185
  awsAgentValues.cloudFormationConfig.EC2VPCID = await (0, _basicPrompts.askInput)({
212
186
  msg: AWSPrompts.VPC_ID,
213
187
  allowEmptyInput: true,
214
188
  validate: (0, _basicPrompts.validateRegex)(helpers.AWSRegexPatterns.AWS_REGEXP_VPC_ID, helpers.invalidValueExampleErrMsg('VPC ID', 'vpc-xxxxxxxxxx'))
215
189
  });
216
-
217
190
  if (awsAgentValues.cloudFormationConfig.EC2VPCID !== '') {
218
191
  // EC2 Public IP Address
219
192
  awsAgentValues.cloudFormationConfig.EC2PublicIPAddress = await askToUsePublicIpAddress();
220
193
  await askSecurityGroupAndSubnet(awsAgentValues);
221
194
  }
222
-
223
195
  return awsAgentValues;
224
196
  };
225
-
226
197
  const askSecurityGroupAndSubnet = async awsAgentValues => {
227
198
  awsAgentValues.cloudFormationConfig.SecurityGroup = await (0, _basicPrompts.askInput)({
228
199
  msg: AWSPrompts.SECURITY_GROUP,
@@ -234,98 +205,105 @@ const askSecurityGroupAndSubnet = async awsAgentValues => {
234
205
  });
235
206
  return awsAgentValues;
236
207
  };
237
-
238
208
  async function configureEC2Deployment(awsAgentValues) {
239
209
  // EC2 Instance type
240
- awsAgentValues.cloudFormationConfig.EC2InstanceType = await askEC2InstanceType(); // EC2 Key Name
210
+ awsAgentValues.cloudFormationConfig.EC2InstanceType = await askEC2InstanceType();
241
211
 
212
+ // EC2 Key Name
242
213
  console.log(_chalk.default.gray(`A SSH key pair is required to access the EC2 instance. An example CLI command will be given at the end, if needed`));
243
214
  awsAgentValues.cloudFormationConfig.EC2KeyName = await (0, _basicPrompts.askInput)({
244
215
  msg: AWSPrompts.KEY_PAIR
245
- }); // EC2 VPC Config
216
+ });
246
217
 
218
+ // EC2 VPC Config
247
219
  awsAgentValues = await askEC2VPCConfig(awsAgentValues);
248
220
  awsAgentValues.cloudFormationConfig.EC2SSHLocation = await (0, _basicPrompts.askInput)({
249
221
  msg: AWSPrompts.SSH_LOCATION,
250
222
  defaultValue: awsAgentValues.cloudFormationConfig.EC2SSHLocation,
251
223
  validate: (0, _basicPrompts.validateRegex)(helpers.AWSRegexPatterns.AWS_REGEXP_SSH_LOCATION, helpers.invalidValueExampleErrMsg('IP Range/Mask', '1.2.3.4/0'))
252
- }); // SSMPrivateKeyParameter
224
+ });
253
225
 
226
+ // SSMPrivateKeyParameter
254
227
  awsAgentValues.cloudFormationConfig.SSMPrivateKeyParameter = await (0, _basicPrompts.askInput)({
255
228
  msg: AWSPrompts.SSM_PRIVATE,
256
229
  defaultValue: awsAgentValues.cloudFormationConfig.SSMPrivateKeyParameter
257
- }); // SSMPublicKeyParameter
230
+ });
258
231
 
232
+ // SSMPublicKeyParameter
259
233
  awsAgentValues.cloudFormationConfig.SSMPublicKeyParameter = await (0, _basicPrompts.askInput)({
260
234
  msg: AWSPrompts.SSM_PUBLIC,
261
235
  defaultValue: awsAgentValues.cloudFormationConfig.SSMPublicKeyParameter
262
236
  });
263
237
  return awsAgentValues;
264
238
  }
265
-
266
239
  async function configureECSDeployment(awsAgentValues) {
267
240
  // ECS Cluster name
268
241
  awsAgentValues.cloudFormationConfig.ECSClusterName = await (0, _basicPrompts.askInput)({
269
242
  msg: AWSPrompts.CLUSTER_NAME,
270
243
  validate: (0, _basicPrompts.validateRegex)(helpers.AWSRegexPatterns.AWS_REGEXP, InvalidMsg.CLUSTER_NAME)
271
244
  });
272
- awsAgentValues = await askSecurityGroupAndSubnet(awsAgentValues); // SSMPrivateKeyParameter
273
-
245
+ awsAgentValues = await askSecurityGroupAndSubnet(awsAgentValues);
246
+ // SSMPrivateKeyParameter
274
247
  awsAgentValues.cloudFormationConfig.SSMPrivateKeyParameter = await (0, _basicPrompts.askInput)({
275
248
  msg: AWSPrompts.SSM_PRIVATE,
276
249
  defaultValue: awsAgentValues.cloudFormationConfig.SSMPrivateKeyParameter
277
- }); // SSMPublicKeyParameter
250
+ });
278
251
 
252
+ // SSMPublicKeyParameter
279
253
  awsAgentValues.cloudFormationConfig.SSMPublicKeyParameter = await (0, _basicPrompts.askInput)({
280
254
  msg: AWSPrompts.SSM_PUBLIC,
281
255
  defaultValue: awsAgentValues.cloudFormationConfig.SSMPublicKeyParameter
282
256
  });
283
257
  return awsAgentValues;
284
- } // @ts-ignore
285
-
258
+ }
286
259
 
260
+ // @ts-ignore
287
261
  const gatewayConnectivity = async installConfig => {
288
262
  console.log('\nCONNECTION TO AMAZON API GATEWAY:');
289
- console.log(_chalk.default.gray(`You need credentials for executing the AWS CLI commands.\n` + `The Discovery Agent needs to connect to the Amazon (AWS) API Gateway to discover API's for publishing to Amplify Central and/or the Unified Catalog.\n` + `The Traceability Agent needs to connect to the AWS API Gateway for the collection of transaction headers.\n` + `These headers will be formatted and forwarded to the Amplify Central Observer.\n` + `We recommend to use two different set of credentials: one for AWS CLI and one for the agents`)); // DeploymentType
263
+ console.log(_chalk.default.gray(`You need credentials for executing the AWS CLI commands.\n` + `The Discovery Agent needs to connect to the Amazon (AWS) API Gateway to discover API's for publishing to Amplify Central and/or the Unified Catalog.\n` + `The Traceability Agent needs to connect to the AWS API Gateway for the collection of transaction headers.\n` + `These headers will be formatted and forwarded to the Amplify Central Observer.\n` + `We recommend to use two different set of credentials: one for AWS CLI and one for the agents`));
290
264
 
265
+ // DeploymentType
291
266
  const deploymentType = await askDeployment();
292
267
  let awsAgentValues = new helpers.AWSAgentValues(deploymentType);
293
268
  awsAgentValues.cloudFormationConfig.DeploymentType = deploymentType;
294
-
295
269
  switch (awsAgentValues.cloudFormationConfig.DeploymentType) {
296
270
  case DeploymentTypes.ECS_FARGATE:
297
271
  {
298
272
  console.log(_chalk.default.gray(`To deploy the Agents to ECS Fargate you will need an ECS Cluster Name, Security Group, and Subnet. The coming questions will ask those values.\n`));
299
273
  break;
300
274
  }
301
-
302
275
  case DeploymentTypes.OTHER:
303
276
  {
304
277
  console.log(_chalk.default.gray(`To access the AWS CLI, the AWS Access Key and AWS Secret Key credentials are required.\n`));
305
278
  break;
306
279
  }
307
- } // AWS Region
308
-
280
+ }
309
281
 
310
- awsAgentValues.region = await helpers.askAWSRegion(); // S3 bucket
282
+ // AWS Region
283
+ awsAgentValues.region = await helpers.askAWSRegion();
311
284
 
285
+ // S3 bucket
312
286
  awsAgentValues.cloudFormationConfig.AgentResourcesBucket = await (0, _basicPrompts.askInput)({
313
287
  msg: AWSPrompts.S3_BUCKET,
314
288
  validate: (0, _basicPrompts.validateRegex)(helpers.AWSRegexPatterns.AWS_REGEXP, InvalidMsg.S3_BUCKET)
315
- }); // APIGWCWRoleSetup
289
+ });
316
290
 
317
- awsAgentValues.cloudFormationConfig.APIGWCWRoleSetup = await askToCreateRoleSetup(); // APIGWTrafficLogGroupName
291
+ // APIGWCWRoleSetup
292
+ awsAgentValues.cloudFormationConfig.APIGWCWRoleSetup = await askToCreateRoleSetup();
318
293
 
294
+ // APIGWTrafficLogGroupName
319
295
  const apiGWTrafficLogGroupName = await (0, _basicPrompts.askInput)({
320
296
  msg: AWSPrompts.APIGW_LOG_GROUP,
321
297
  defaultValue: awsAgentValues.cloudFormationConfig.APIGWTrafficLogGroupName,
322
298
  validate: (0, _basicPrompts.validateRegex)(helpers.AWSRegexPatterns.AWS_REGEXP_LOG_GROUP_NAME, InvalidMsg.LOG_GROUP)
323
299
  });
324
300
  awsAgentValues.logGroup = apiGWTrafficLogGroupName;
325
- awsAgentValues.cloudFormationConfig.APIGWTrafficLogGroupName = apiGWTrafficLogGroupName; // ConfigServiceSetup
301
+ awsAgentValues.cloudFormationConfig.APIGWTrafficLogGroupName = apiGWTrafficLogGroupName;
326
302
 
327
- awsAgentValues = await askConfigSvcSetup(awsAgentValues); // DiscoveryQueueName
303
+ // ConfigServiceSetup
304
+ awsAgentValues = await askConfigSvcSetup(awsAgentValues);
328
305
 
306
+ // DiscoveryQueueName
329
307
  const discoveryQueueName = await (0, _basicPrompts.askInput)({
330
308
  msg: AWSPrompts.DA_QUEUE,
331
309
  defaultValue: awsAgentValues.cloudFormationConfig.DiscoveryQueueName,
@@ -333,8 +311,9 @@ const gatewayConnectivity = async installConfig => {
333
311
  });
334
312
  awsAgentValues.daQueueName = discoveryQueueName;
335
313
  awsAgentValues.cloudFormationConfig.DiscoveryQueueName = discoveryQueueName;
336
- awsAgentValues.cloudFormationConfig.DiscoveryAgentVersion = installConfig.daVersion; // TraceabilityQueueName
314
+ awsAgentValues.cloudFormationConfig.DiscoveryAgentVersion = installConfig.daVersion;
337
315
 
316
+ // TraceabilityQueueName
338
317
  const traceabilityQueueName = await (0, _basicPrompts.askInput)({
339
318
  msg: AWSPrompts.TA_QUEUE,
340
319
  defaultValue: awsAgentValues.cloudFormationConfig.TraceabilityQueueName,
@@ -342,29 +321,30 @@ const gatewayConnectivity = async installConfig => {
342
321
  });
343
322
  awsAgentValues.taQueueName = traceabilityQueueName;
344
323
  awsAgentValues.cloudFormationConfig.TraceabilityQueueName = traceabilityQueueName;
345
- awsAgentValues.cloudFormationConfig.TraceabilityAgentVersion = installConfig.taVersion; // Configure appropriate Gateway type
324
+ awsAgentValues.cloudFormationConfig.TraceabilityAgentVersion = installConfig.taVersion;
346
325
 
326
+ // Configure appropriate Gateway type
347
327
  switch (awsAgentValues.cloudFormationConfig.DeploymentType) {
348
328
  case DeploymentTypes.ECS_FARGATE:
349
329
  {
350
330
  awsAgentValues = await configureECSDeployment(awsAgentValues);
351
331
  break;
352
332
  }
353
-
354
333
  case DeploymentTypes.EC2:
355
334
  {
356
335
  awsAgentValues = await configureEC2Deployment(awsAgentValues);
357
336
  break;
358
337
  }
359
- } // DiscoveryAgentLogGroupName
360
-
338
+ }
361
339
 
340
+ // DiscoveryAgentLogGroupName
362
341
  awsAgentValues.cloudFormationConfig.DiscoveryAgentLogGroupName = await (0, _basicPrompts.askInput)({
363
342
  msg: AWSPrompts.DA_LOG_GROUP,
364
343
  defaultValue: awsAgentValues.cloudFormationConfig.DiscoveryAgentLogGroupName,
365
344
  validate: (0, _basicPrompts.validateRegex)(helpers.AWSRegexPatterns.AWS_REGEXP_LOG_GROUP_NAME, InvalidMsg.LOG_GROUP)
366
- }); // TraceabilityQueueName
345
+ });
367
346
 
347
+ // TraceabilityQueueName
368
348
  awsAgentValues.cloudFormationConfig.TraceabilityAgentLogGroupName = await (0, _basicPrompts.askInput)({
369
349
  msg: AWSPrompts.TA_LOG_GROUP,
370
350
  defaultValue: awsAgentValues.cloudFormationConfig.TraceabilityAgentLogGroupName,
@@ -372,16 +352,14 @@ const gatewayConnectivity = async installConfig => {
372
352
  });
373
353
  return awsAgentValues;
374
354
  };
375
-
376
355
  exports.gatewayConnectivity = gatewayConnectivity;
377
-
378
356
  const generateOutput = async installConfig => {
379
357
  const awsAgentValues = installConfig.gatewayConfig;
380
358
  let s3BaseFiles = [ConfigFiles.LambdaZip, ConfigFiles.DeployAllYAML, ConfigFiles.ResourcesYAML];
381
359
  let additionalSteps = '';
382
360
  let dockerEnvConfig = '';
383
- let runCommands = ''; // Configure appropriate Gateway type
384
-
361
+ let runCommands = '';
362
+ // Configure appropriate Gateway type
385
363
  switch (awsAgentValues.cloudFormationConfig.DeploymentType) {
386
364
  case DeploymentTypes.ECS_FARGATE:
387
365
  {
@@ -389,25 +367,22 @@ const generateOutput = async installConfig => {
389
367
  s3BaseFiles.push(ConfigFiles.FargateDeployYAML);
390
368
  additionalSteps = ` - Create the SSM parameter:
391
369
  ${_chalk.default.cyan(` aws ssm put-parameter --type SecureString --name ${awsAgentValues.cloudFormationConfig.SSMPrivateKeyParameter} --value "file:\/\/private_key.pem"`)}
392
- ${_chalk.default.cyan(` aws ssm put-parameter --type SecureString --name ${awsAgentValues.cloudFormationConfig.SSMPublicKeyParameter} --value "file:\/\/public_key.pem"`)}`; // Cleanup EC2 file
393
-
370
+ ${_chalk.default.cyan(` aws ssm put-parameter --type SecureString --name ${awsAgentValues.cloudFormationConfig.SSMPublicKeyParameter} --value "file:\/\/public_key.pem"`)}`;
371
+ // Cleanup EC2 file
394
372
  _fs.default.unlinkSync(ConfigFiles.EC2DeployYAML);
395
-
396
373
  break;
397
374
  }
398
-
399
375
  case DeploymentTypes.OTHER:
400
376
  {
401
377
  // DeploymentTypes.OTHER for Docker Container Only
402
378
  // These files need to be put in a resources dir on S3
403
379
  let s3ResourcesIncludes = '';
404
- [ConfigFiles.DAEnvVars, ConfigFiles.TAEnvVars].forEach(value => s3ResourcesIncludes += `--include "${value}" `); // Cleanup EC2 file
405
-
406
- _fs.default.unlinkSync(ConfigFiles.EC2DeployYAML); // Cleanup ECS Fargate file
407
-
380
+ [ConfigFiles.DAEnvVars, ConfigFiles.TAEnvVars].forEach(value => s3ResourcesIncludes += `--include "${value}" `);
408
381
 
382
+ // Cleanup EC2 file
383
+ _fs.default.unlinkSync(ConfigFiles.EC2DeployYAML);
384
+ // Cleanup ECS Fargate file
409
385
  _fs.default.unlinkSync(ConfigFiles.FargateDeployYAML);
410
-
411
386
  const info = `To utilize the agents, pull the latest Docker images and run them using the appropriate supplied environment files, (${helpers.configFiles.DA_ENV_VARS} & ${helpers.configFiles.TA_ENV_VARS}):`;
412
387
  dockerEnvConfig = `Wait for the CloudFormation Stack to complete.
413
388
  - Create AWS Access and Secret Keys and copy resulting ${_chalk.default.yellow(`"AccessKeyId"`)} & ${_chalk.default.yellow(`"SecretAccessKey"`)}:
@@ -439,12 +414,11 @@ ${_chalk.default.cyan(`docker run --env-file ${helpers.pwd}/${ConfigFiles.TAEnvV
439
414
  -v /data ${taImage}:${installConfig.taVersion}`)}`}`;
440
415
  break;
441
416
  }
442
-
443
417
  default:
444
418
  {
445
419
  // DeploymentTypes.EC2
446
- s3BaseFiles.push(ConfigFiles.EC2DeployYAML); // These files need to be put in a resources dir on S3
447
-
420
+ s3BaseFiles.push(ConfigFiles.EC2DeployYAML);
421
+ // These files need to be put in a resources dir on S3
448
422
  let s3ResourcesIncludes = '';
449
423
  [ConfigFiles.DAEnvVars, ConfigFiles.TAEnvVars].forEach(value => s3ResourcesIncludes += `--include "${value}" `);
450
424
  additionalSteps = `${_chalk.default.cyan(` aws s3 sync --exclude "*" ${s3ResourcesIncludes} ./ s3://${awsAgentValues.cloudFormationConfig.AgentResourcesBucket}/resources`)}
@@ -452,17 +426,15 @@ ${_chalk.default.cyan(`docker run --env-file ${helpers.pwd}/${ConfigFiles.TAEnvV
452
426
  ${_chalk.default.cyan(` aws ec2 create-key-pair --key-name ${awsAgentValues.cloudFormationConfig.EC2KeyName} --query KeyMaterial --output text > MyKeyPair.pem`)}
453
427
  - Create the SSM parameter:
454
428
  ${_chalk.default.cyan(` aws ssm put-parameter --type SecureString --name ${awsAgentValues.cloudFormationConfig.SSMPrivateKeyParameter} --value "file:\/\/private_key.pem"`)}
455
- ${_chalk.default.cyan(` aws ssm put-parameter --type SecureString --name ${awsAgentValues.cloudFormationConfig.SSMPublicKeyParameter} --value "file:\/\/public_key.pem"`)}`; // Cleanup Fargate file
456
-
429
+ ${_chalk.default.cyan(` aws ssm put-parameter --type SecureString --name ${awsAgentValues.cloudFormationConfig.SSMPublicKeyParameter} --value "file:\/\/public_key.pem"`)}`;
430
+ // Cleanup Fargate file
457
431
  _fs.default.unlinkSync(ConfigFiles.FargateDeployYAML);
458
-
459
432
  break;
460
433
  }
461
434
  }
462
-
463
435
  let s3BaseIncludes = '';
464
- s3BaseFiles.forEach(value => s3BaseIncludes += `--include "${value}" `); // if region is AWS default, 'us-east-1', region unnecessary in cloudformation template url
465
-
436
+ s3BaseFiles.forEach(value => s3BaseIncludes += `--include "${value}" `);
437
+ // if region is AWS default, 'us-east-1', region unnecessary in cloudformation template url
466
438
  const s3Region = awsAgentValues.region === _types.AWSRegions.US_EAST_1 ? `s3` : `s3.${awsAgentValues.region}`;
467
439
  return `
468
440
  To complete the install, run the following AWS CLI command:
@@ -483,16 +455,15 @@ ${runCommands}
483
455
 
484
456
  ${_chalk.default.gray(`Additional information about agent features can be found here:\n${helpers.agentsDocsUrl.AWS}`)}\n
485
457
  `;
486
- }; // Download latest aws apigw config zip
487
-
458
+ };
488
459
 
460
+ // Download latest aws apigw config zip
489
461
  const downloadAPIGWAgentConfigZip = async () => {
490
462
  const url = `/aws_apigw_agent_config/latest/${ConfigFiles.AgentConfigZip}`;
491
463
  const service = await (0, _dataService.dataService)({
492
464
  baseUrl: _types.PublicRepoUrl,
493
465
  basePath: _types.BasePaths.AWSAgents
494
466
  });
495
-
496
467
  try {
497
468
  const {
498
469
  stream
@@ -502,27 +473,22 @@ const downloadAPIGWAgentConfigZip = async () => {
502
473
  } catch (err) {
503
474
  throw new Error(`Failed to download the agent: ${err.message}`);
504
475
  }
505
- }; // Unzip latest aws apigw config zip
506
-
476
+ };
507
477
 
478
+ // Unzip latest aws apigw config zip
508
479
  const unzipAPIGWAgentConfigZip = async zipFile => {
509
480
  await helpers.unzip(zipFile);
510
-
511
481
  _fs.default.unlinkSync(zipFile);
512
-
513
482
  _fs.default.existsSync(ConfigFiles.ContinuousZip);
514
-
515
483
  return await unzipCFContinuousDiscoveryZip(ConfigFiles.ContinuousZip);
516
- }; // Unzip Cloud Formation continuous zip
517
-
484
+ };
518
485
 
486
+ // Unzip Cloud Formation continuous zip
519
487
  const unzipCFContinuousDiscoveryZip = async zipFile => {
520
488
  await helpers.unzip(zipFile);
521
-
522
489
  try {
523
- _fs.default.unlinkSync(zipFile); // remove synchronous zip that was extracted from cloudformation-continuous-discovery.zip
524
-
525
-
490
+ _fs.default.unlinkSync(zipFile);
491
+ // remove synchronous zip that was extracted from cloudformation-continuous-discovery.zip
526
492
  if (_fs.default.existsSync(ConfigFiles.SynchronousZip)) {
527
493
  _fs.default.unlinkSync(ConfigFiles.SynchronousZip);
528
494
  }
@@ -530,73 +496,58 @@ const unzipCFContinuousDiscoveryZip = async zipFile => {
530
496
  // May need to manually remove - cloudformation-synchronous-discovery.zip, cloudformation-continuous-discovery.zip
531
497
  console.log(_chalk.default.gray(`The ${ConfigFiles.ContinuousZip} and / or the ${ConfigFiles.SynchronousZip} may not have been removed.\n` + ` You can manually remove them if you wish`));
532
498
  }
533
-
534
499
  const isCloudFormation = _fs.default.existsSync(ConfigFiles.DeployAllYAML);
535
-
536
500
  if (!isCloudFormation) {
537
501
  console.log(`${ConfigFiles.DeployAllYAML} was not extracted from ${ConfigFiles.ContinuousZip}`);
538
502
  return false;
539
503
  }
540
-
541
504
  return true;
542
505
  };
543
-
544
506
  const installPreprocess = async installConfig => {
545
507
  // attempt to download the cloud formation files
546
508
  console.log(_chalk.default.gray(`Downloading the latest Cloud formation template...`));
547
509
  let apigwAgentConfigZipFile = await downloadAPIGWAgentConfigZip();
548
-
549
510
  if (apigwAgentConfigZipFile !== '') {
550
511
  console.log(_chalk.default.gray(`\nSuccess`));
551
512
  }
552
-
553
513
  installConfig.gatewayConfig.apigwAgentConfigZipFile = apigwAgentConfigZipFile;
554
514
  return installConfig;
555
515
  };
556
-
557
516
  exports.installPreprocess = installPreprocess;
558
-
559
517
  const completeInstall = async installConfig => {
560
518
  /**
561
519
  * Create agent resources
562
520
  */
563
- const awsAgentValues = installConfig.gatewayConfig; // Add final settings to awsAgentsValues
521
+ const awsAgentValues = installConfig.gatewayConfig;
564
522
 
523
+ // Add final settings to awsAgentsValues
565
524
  awsAgentValues.centralConfig = installConfig.centralConfig;
566
525
  awsAgentValues.traceabilityConfig = installConfig.traceabilityConfig;
567
526
  const unpackZip = await unzipAPIGWAgentConfigZip(awsAgentValues.apigwAgentConfigZipFile);
568
-
569
527
  if (unpackZip) {
570
528
  console.log('\nCreating the agent environment files for AWS...');
571
529
  }
572
-
573
530
  console.log('Generating the configuration file(s)...');
574
531
  console.log('Generating the cloud formation parameters file...');
575
532
  let paramStrings = [];
576
533
  awsAgentValues.updateCloudFormationConfig();
577
-
578
534
  for (let [key, value] of Object.entries(awsAgentValues.cloudFormationConfig)) {
579
535
  paramStrings.push(`{"ParameterKey": "${key}", "ParameterValue": "${value}"}`);
580
536
  }
581
-
582
537
  (0, _utils.writeToFile)(ConfigFiles.CFProperties, `[\n${paramStrings.join(',\n')}\n]`);
583
-
584
538
  if (installConfig.switches.isDaEnabled && DeploymentTypes.ECS_FARGATE !== awsAgentValues.cloudFormationConfig.DeploymentType) {
585
539
  log('GENERATING DA TEMPLATE');
586
540
  (0, _utils.writeTemplates)(ConfigFiles.DAEnvVars, awsAgentValues, helpers.awsDAEnvVarTemplate);
587
541
  }
588
-
589
542
  if (installConfig.switches.isTaEnabled && DeploymentTypes.ECS_FARGATE !== awsAgentValues.cloudFormationConfig.DeploymentType) {
590
543
  log('GENERATING TA TEMPLATE');
591
544
  (0, _utils.writeTemplates)(ConfigFiles.TAEnvVars, awsAgentValues, helpers.awsTAEnvVarTemplate);
592
545
  }
593
-
594
546
  console.log('Configuration file(s) have been successfully created.\n');
595
547
  console.log(await generateOutput(installConfig));
596
548
  };
597
-
598
549
  exports.completeInstall = completeInstall;
599
- const AWSInstallMethods = {
550
+ const AWSInstallMethods = exports.AWSInstallMethods = {
600
551
  GetBundleType: askBundleType,
601
552
  GetDeploymentType: askConfigType,
602
553
  AskGatewayQuestions: gatewayConnectivity,
@@ -608,14 +559,13 @@ const AWSInstallMethods = {
608
559
  [_types.AgentTypes.ta]: _types.AgentNames.AWS_TA
609
560
  },
610
561
  GatewayDisplay: _types.GatewayTypes.AWS_GATEWAY
611
- }; // These are the items that are not exported, but need to be for testing
562
+ };
612
563
 
613
- exports.AWSInstallMethods = AWSInstallMethods;
614
- const testables = {
564
+ // These are the items that are not exported, but need to be for testing
565
+ const testables = exports.testables = {
615
566
  DeploymentTypes,
616
567
  AWSPrompts,
617
568
  EC2InstanceTypes,
618
569
  unzipCFContinuousDiscoveryZip,
619
570
  ConfigFiles
620
- };
621
- exports.testables = testables;
571
+ };