@axway/axway-central-cli 4.5.0 → 4.6.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 (83) hide show
  1. package/.security-profile-branches.json +18 -0
  2. package/package.json +1 -1
  3. package/dist/cli.js +0 -71
  4. package/dist/commands/apply/index.js +0 -112
  5. package/dist/commands/completion/index.js +0 -100
  6. package/dist/commands/config/common/index.js +0 -28
  7. package/dist/commands/config/index.js +0 -20
  8. package/dist/commands/config/list.js +0 -24
  9. package/dist/commands/config/set.js +0 -102
  10. package/dist/commands/config/unset.js +0 -48
  11. package/dist/commands/create/agentResource.js +0 -108
  12. package/dist/commands/create/environment.js +0 -62
  13. package/dist/commands/create/index.js +0 -109
  14. package/dist/commands/create/serviceAccount.js +0 -15
  15. package/dist/commands/delete/index.js +0 -196
  16. package/dist/commands/edit/environment.js +0 -101
  17. package/dist/commands/edit/index.js +0 -28
  18. package/dist/commands/get/index.js +0 -272
  19. package/dist/commands/install/agents.js +0 -290
  20. package/dist/commands/install/apigeexAgents.js +0 -223
  21. package/dist/commands/install/apigeexSaasAgents.js +0 -300
  22. package/dist/commands/install/awsAgents.js +0 -525
  23. package/dist/commands/install/awsSaasAgents.js +0 -508
  24. package/dist/commands/install/azureAgents.js +0 -242
  25. package/dist/commands/install/azureSaasAgents.js +0 -519
  26. package/dist/commands/install/backstageAgents.js +0 -167
  27. package/dist/commands/install/edgeAgents.js +0 -409
  28. package/dist/commands/install/gitHubSaasAgents.js +0 -294
  29. package/dist/commands/install/gitLabAgents.js +0 -178
  30. package/dist/commands/install/graylogAgent.js +0 -147
  31. package/dist/commands/install/helpers/creators.js +0 -359
  32. package/dist/commands/install/helpers/deleters.js +0 -36
  33. package/dist/commands/install/helpers/getters.js +0 -95
  34. package/dist/commands/install/helpers/index.js +0 -267
  35. package/dist/commands/install/helpers/inputs.js +0 -593
  36. package/dist/commands/install/helpers/regex.js +0 -67
  37. package/dist/commands/install/helpers/templates/apigeexTemplates.js +0 -109
  38. package/dist/commands/install/helpers/templates/awsTemplates.js +0 -129
  39. package/dist/commands/install/helpers/templates/azureTemplates.js +0 -125
  40. package/dist/commands/install/helpers/templates/backstageTemplates.js +0 -95
  41. package/dist/commands/install/helpers/templates/edgeTemplates.js +0 -360
  42. package/dist/commands/install/helpers/templates/gitLabTemplates.js +0 -66
  43. package/dist/commands/install/helpers/templates/graylogTemplates.js +0 -75
  44. package/dist/commands/install/helpers/templates/ibmAPIConnectTemplates.js +0 -116
  45. package/dist/commands/install/helpers/templates/istioTemplates.js +0 -214
  46. package/dist/commands/install/helpers/templates/kafkaTemplates.js +0 -194
  47. package/dist/commands/install/helpers/templates/sapApiPortalTemplates.js +0 -114
  48. package/dist/commands/install/helpers/templates/softwareAGWebMethodsTemplates.js +0 -93
  49. package/dist/commands/install/helpers/templates/traceableTemplates.js +0 -135
  50. package/dist/commands/install/helpers/templates/wso2Templates.js +0 -85
  51. package/dist/commands/install/helpers/util.js +0 -26
  52. package/dist/commands/install/ibmAPIConnectAgents.js +0 -213
  53. package/dist/commands/install/index.js +0 -36
  54. package/dist/commands/install/istioAgents.js +0 -346
  55. package/dist/commands/install/kafkaAgents.js +0 -303
  56. package/dist/commands/install/platform.js +0 -175
  57. package/dist/commands/install/sapApiPortalAgents.js +0 -198
  58. package/dist/commands/install/softwareAGWebMethodsAgents.js +0 -161
  59. package/dist/commands/install/swaggerHubSaasAgents.js +0 -272
  60. package/dist/commands/install/traceableAgents.js +0 -257
  61. package/dist/commands/install/traceableSaasAgents.js +0 -275
  62. package/dist/commands/install/wso2Agents.js +0 -163
  63. package/dist/commands/productize/helpers/productizationHelper.js +0 -408
  64. package/dist/commands/productize/index.js +0 -99
  65. package/dist/common/ApiServerClient.js +0 -1109
  66. package/dist/common/CacheController.js +0 -146
  67. package/dist/common/CliConfigManager.js +0 -76
  68. package/dist/common/CompositeError.js +0 -95
  69. package/dist/common/CoreConfigController.js +0 -174
  70. package/dist/common/DefinitionsManager.js +0 -298
  71. package/dist/common/Kubectl.js +0 -68
  72. package/dist/common/PlatformClient.js +0 -128
  73. package/dist/common/Renderer.js +0 -409
  74. package/dist/common/TmpFile.js +0 -96
  75. package/dist/common/bashCommands.js +0 -97
  76. package/dist/common/basicPrompts.js +0 -160
  77. package/dist/common/dataService.js +0 -312
  78. package/dist/common/errorHandler.js +0 -46
  79. package/dist/common/modules.d.js +0 -1
  80. package/dist/common/resultsRenderers.js +0 -164
  81. package/dist/common/types.js +0 -746
  82. package/dist/common/utils.js +0 -476
  83. package/dist/main.js +0 -8
@@ -1,525 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.testables = exports.installPreprocess = exports.gatewayConnectivity = exports.completeInstall = exports.askConfigType = exports.askBundleType = exports.DeploymentTypes = exports.ConfigFiles = exports.AWSPrompts = exports.AWSInstallMethods = void 0;
7
- var _chalk = _interopRequireDefault(require("chalk"));
8
- var _fs = _interopRequireDefault(require("fs"));
9
- var _snooplogg = _interopRequireDefault(require("snooplogg"));
10
- var _basicPrompts = require("../../common/basicPrompts");
11
- var _dataService = require("../../common/dataService");
12
- var _types = require("../../common/types");
13
- var _utils = require("../../common/utils");
14
- var helpers = _interopRequireWildcard(require("./helpers"));
15
- function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function (e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != typeof e && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (const t in e) "default" !== t && {}.hasOwnProperty.call(e, t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, t)) && (i.get || i.set) ? o(f, t, i) : f[t] = e[t]); return f; })(e, t); }
16
- function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
17
- const {
18
- log
19
- } = (0, _snooplogg.default)('engage: install: agents: aws');
20
- const daImage = `${_types.PublicDockerRepoBaseUrl}${_types.BasePaths.DockerAgentPublicRepo}/${_types.AgentNames.AWS_DA}`;
21
- const taImage = `${_types.PublicDockerRepoBaseUrl}${_types.BasePaths.DockerAgentPublicRepo}/${_types.AgentNames.AWS_TA}`;
22
- const STAGE_TAG_NAME_LENGTH = 127;
23
-
24
- // DeploymentTypes - ways the agents may be deployed with an AWS APIGW setup
25
- let DeploymentTypes = exports.DeploymentTypes = /*#__PURE__*/function (DeploymentTypes) {
26
- DeploymentTypes["EC2"] = "EC2";
27
- DeploymentTypes["ECS_FARGATE"] = "ECS Fargate";
28
- DeploymentTypes["OTHER"] = "Other";
29
- return DeploymentTypes;
30
- }({}); // EC2InstanceTypes - instance types allowed in cloud formation document
31
- var EC2InstanceTypes = /*#__PURE__*/function (EC2InstanceTypes) {
32
- EC2InstanceTypes["T3_MICRO"] = "t3.micro";
33
- EC2InstanceTypes["T3_NAN0"] = "t3.nano";
34
- EC2InstanceTypes["T3_SMALL"] = "t3.small";
35
- EC2InstanceTypes["T3_MEDIUM"] = "t3.medium";
36
- EC2InstanceTypes["T3_LARGE"] = "t3.large";
37
- EC2InstanceTypes["T3_XLARGE"] = "t3.xlarge";
38
- EC2InstanceTypes["T3_2XLARGE"] = "t3.2xlarge";
39
- return EC2InstanceTypes;
40
- }(EC2InstanceTypes || {});
41
- const InvalidMsg = {
42
- 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`,
43
- 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`,
44
- 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`,
45
- 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`
46
- };
47
-
48
- // ConfigFiles - all the config file that are used in the setup
49
- const ConfigFiles = exports.ConfigFiles = {
50
- DeployAllYAML: 'amplify-agents-deploy-all.yaml',
51
- ResourcesYAML: 'amplify-agents-setup.yaml',
52
- EC2DeployYAML: 'amplify-agents-ec2.yaml',
53
- FargateDeployYAML: 'amplify-agents-ecs-fargate.yaml',
54
- AgentConfigZip: 'aws_apigw_agent_config-latest.zip',
55
- DAEnvVars: `${helpers.configFiles.DA_ENV_VARS}`,
56
- TAEnvVars: `${helpers.configFiles.TA_ENV_VARS}`,
57
- CFProperties: 'cloudformation_properties.json'
58
- };
59
-
60
- // AWSPrompts - all prompts to the user for input
61
- const AWSPrompts = exports.AWSPrompts = {
62
- APIGW_LOG_GROUP: 'Enter the Log Group name to track API Gateway traffic events',
63
- CLUSTER_NAME: 'Enter the ECS fargate cluster name to deploy the ECS task for the agents',
64
- CONFIG_BUCKET: 'Enter the S3 bucket the config service will use to track config changes',
65
- CONFIG_BUCKET_EXISTS: 'Does this bucket already exist on AWS, or will you create beforehand?',
66
- CONFIG_SERVICE: 'Do you want to setup config service?',
67
- DA_LOG_GROUP: 'Enter the log group name the discovery agent will log to',
68
- STAGE_TAG_NAME: 'Enter the name of the tag on AWS API Gateway Stage that holds mapped stage on Amplify Engage',
69
- DA_QUEUE: 'Enter the discovery queue name',
70
- DEPLOYMENT: 'Select the type of deployment you wish to configure',
71
- EC2_TYPE: 'Select the EC2 instance type',
72
- KEY_PAIR: 'Enter the EC2 KeyPair name that will be used to connect via SSH to the EC2 instance',
73
- PUBLIC_IP: 'Assign a Public IP Address to this, only change if your VPC has a NAT Gateway',
74
- SECURITY_GROUP: 'Enter the Security Group for the EC2 Instance of ECS Container',
75
- SETUP_APIGW_CW: 'The Amazon API Gateway service requires a role to write usage logs to Cloud Watch. Do you want to configure that?',
76
- SSH_LOCATION: 'Enter the IP address range that can be used to SSH to the EC2 instances',
77
- SSM_PRIVATE: 'Enter the name of the SSM Parameter holding the Private Key',
78
- SSM_PUBLIC: 'Enter the name of the SSM Parameter holding the Public Key',
79
- SUBNET: 'Enter the Subnet for the EC2 Instance of ECS Container',
80
- S3_BUCKET: 'Enter the existing S3 bucket, within your region, where the agent resources will be uploaded',
81
- TA_LOG_GROUP: 'Enter the log group name the traceability agent will log to',
82
- FULL_TRANSACTION_LOGGING: 'Do you want to enable Full Transaction Logging? Please note that CloudWatch costs would increase when Full Transaction Logging is enabled',
83
- TA_QUEUE: 'Enter the traceability queue name',
84
- VPC_ID: 'Enter the VPC ID to deploy the EC2 instance to. Leave blank to create entire infrastructure'
85
- };
86
- const askBundleType = async () => {
87
- return _types.BundleType.ALL_AGENTS;
88
- };
89
- exports.askBundleType = askBundleType;
90
- const askConfigType = async () => {
91
- return _types.AgentConfigTypes.DOCKERIZED;
92
- };
93
-
94
- //
95
- // Complex prompts
96
- //
97
- exports.askConfigType = askConfigType;
98
- const askDeployment = async () => {
99
- return (0, _basicPrompts.askList)({
100
- msg: AWSPrompts.DEPLOYMENT,
101
- choices: [{
102
- name: DeploymentTypes.EC2,
103
- value: DeploymentTypes.EC2
104
- }, {
105
- name: DeploymentTypes.ECS_FARGATE,
106
- value: DeploymentTypes.ECS_FARGATE
107
- }, {
108
- name: 'Docker Container Only',
109
- value: DeploymentTypes.OTHER
110
- }],
111
- default: DeploymentTypes.EC2
112
- });
113
- };
114
-
115
- // askToCreateRoleSetup - asks a Yes/No question for creating the APIGW IAM role, returns a True/False string for CloudFormation parameters
116
- const askToCreateRoleSetup = async () => {
117
- return (await (0, _basicPrompts.askList)({
118
- msg: AWSPrompts.SETUP_APIGW_CW,
119
- choices: _types.YesNoChoices,
120
- default: _types.YesNo.Yes
121
- })) === _types.YesNo.Yes ? _types.TrueFalse.True.toLowerCase() : _types.TrueFalse.False.toLowerCase();
122
- };
123
-
124
- // askToUsePublicIpAddress - asks a Yes/No question for setting a public IP address, returns a True/False string for CloudFormation parameters
125
- const askToUsePublicIpAddress = async () => {
126
- return (await (0, _basicPrompts.askList)({
127
- msg: AWSPrompts.PUBLIC_IP,
128
- choices: _types.YesNoChoices,
129
- default: _types.YesNo.Yes
130
- })) === _types.YesNo.Yes ? _types.TrueFalse.True.toLowerCase() : _types.TrueFalse.False.toLowerCase();
131
- };
132
- const askEC2InstanceType = async () => {
133
- return await (0, _basicPrompts.askList)({
134
- msg: AWSPrompts.EC2_TYPE,
135
- choices: [{
136
- name: EC2InstanceTypes.T3_MICRO,
137
- value: EC2InstanceTypes.T3_MICRO
138
- }, {
139
- name: EC2InstanceTypes.T3_NAN0,
140
- value: EC2InstanceTypes.T3_NAN0
141
- }, {
142
- name: EC2InstanceTypes.T3_SMALL,
143
- value: EC2InstanceTypes.T3_SMALL
144
- }, {
145
- name: EC2InstanceTypes.T3_MEDIUM,
146
- value: EC2InstanceTypes.T3_MEDIUM
147
- }, {
148
- name: EC2InstanceTypes.T3_LARGE,
149
- value: EC2InstanceTypes.T3_LARGE
150
- }, {
151
- name: EC2InstanceTypes.T3_XLARGE,
152
- value: EC2InstanceTypes.T3_XLARGE
153
- }, {
154
- name: EC2InstanceTypes.T3_2XLARGE,
155
- value: EC2InstanceTypes.T3_2XLARGE
156
- }],
157
- default: EC2InstanceTypes.T3_MICRO
158
- });
159
- };
160
- const askEC2VPCConfig = async awsAgentValues => {
161
- awsAgentValues.cloudFormationConfig.EC2VPCID = await (0, _basicPrompts.askInput)({
162
- msg: AWSPrompts.VPC_ID,
163
- allowEmptyInput: true,
164
- validate: (0, _basicPrompts.validateRegex)(helpers.AWSRegexPatterns.AWS_REGEXP_VPC_ID, helpers.invalidValueExampleErrMsg('VPC ID', 'vpc-xxxxxxxxxx'))
165
- });
166
- if (awsAgentValues.cloudFormationConfig.EC2VPCID !== '') {
167
- // EC2 Public IP Address
168
- awsAgentValues.cloudFormationConfig.EC2PublicIPAddress = await askToUsePublicIpAddress();
169
- await askSecurityGroupAndSubnet(awsAgentValues);
170
- }
171
- return awsAgentValues;
172
- };
173
- const askSecurityGroupAndSubnet = async awsAgentValues => {
174
- awsAgentValues.cloudFormationConfig.SecurityGroup = await (0, _basicPrompts.askInput)({
175
- msg: AWSPrompts.SECURITY_GROUP,
176
- validate: (0, _basicPrompts.validateRegex)(helpers.AWSRegexPatterns.AWS_REGEXP_SECURITY_GROUP, helpers.invalidValueExampleErrMsg('security group', 'sg-xxxxxxxxxx'))
177
- });
178
- awsAgentValues.cloudFormationConfig.Subnet = await (0, _basicPrompts.askInput)({
179
- msg: AWSPrompts.SUBNET,
180
- validate: (0, _basicPrompts.validateRegex)(helpers.AWSRegexPatterns.AWS_REGEXP_SUBNET, helpers.invalidValueExampleErrMsg('subnet ID', 'subnet-xxxxxxxxxx'))
181
- });
182
- return awsAgentValues;
183
- };
184
- async function configureEC2Deployment(awsAgentValues) {
185
- // EC2 Instance type
186
- awsAgentValues.cloudFormationConfig.EC2InstanceType = await askEC2InstanceType();
187
-
188
- // EC2 Key Name
189
- 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`));
190
- awsAgentValues.cloudFormationConfig.EC2KeyName = await (0, _basicPrompts.askInput)({
191
- msg: AWSPrompts.KEY_PAIR
192
- });
193
-
194
- // EC2 VPC Config
195
- awsAgentValues = await askEC2VPCConfig(awsAgentValues);
196
- awsAgentValues.cloudFormationConfig.EC2SSHLocation = await (0, _basicPrompts.askInput)({
197
- msg: AWSPrompts.SSH_LOCATION,
198
- defaultValue: awsAgentValues.cloudFormationConfig.EC2SSHLocation,
199
- validate: (0, _basicPrompts.validateRegex)(helpers.AWSRegexPatterns.AWS_REGEXP_SSH_LOCATION, helpers.invalidValueExampleErrMsg('IP Range/Mask', '1.2.3.4/0'))
200
- });
201
-
202
- // SSMPrivateKeyParameter
203
- awsAgentValues.cloudFormationConfig.SSMPrivateKeyParameter = await (0, _basicPrompts.askInput)({
204
- msg: AWSPrompts.SSM_PRIVATE,
205
- defaultValue: awsAgentValues.cloudFormationConfig.SSMPrivateKeyParameter
206
- });
207
-
208
- // SSMPublicKeyParameter
209
- awsAgentValues.cloudFormationConfig.SSMPublicKeyParameter = await (0, _basicPrompts.askInput)({
210
- msg: AWSPrompts.SSM_PUBLIC,
211
- defaultValue: awsAgentValues.cloudFormationConfig.SSMPublicKeyParameter
212
- });
213
- return awsAgentValues;
214
- }
215
- async function configureECSDeployment(awsAgentValues) {
216
- // ECS Cluster name
217
- awsAgentValues.cloudFormationConfig.ECSClusterName = await (0, _basicPrompts.askInput)({
218
- msg: AWSPrompts.CLUSTER_NAME,
219
- validate: (0, _basicPrompts.validateRegex)(helpers.AWSRegexPatterns.AWS_REGEXP, InvalidMsg.CLUSTER_NAME)
220
- });
221
- awsAgentValues = await askSecurityGroupAndSubnet(awsAgentValues);
222
- // SSMPrivateKeyParameter
223
- awsAgentValues.cloudFormationConfig.SSMPrivateKeyParameter = await (0, _basicPrompts.askInput)({
224
- msg: AWSPrompts.SSM_PRIVATE,
225
- defaultValue: awsAgentValues.cloudFormationConfig.SSMPrivateKeyParameter
226
- });
227
-
228
- // SSMPublicKeyParameter
229
- awsAgentValues.cloudFormationConfig.SSMPublicKeyParameter = await (0, _basicPrompts.askInput)({
230
- msg: AWSPrompts.SSM_PUBLIC,
231
- defaultValue: awsAgentValues.cloudFormationConfig.SSMPublicKeyParameter
232
- });
233
- return awsAgentValues;
234
- }
235
-
236
- // @ts-ignore
237
- const gatewayConnectivity = async installConfig => {
238
- console.log('\nCONNECTION TO AMAZON API GATEWAY:');
239
- 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.\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 Business Insights.\n` + `We recommend to use two different set of credentials: one for AWS CLI and one for the agents`));
240
-
241
- // DeploymentType
242
- const deploymentType = await askDeployment();
243
- let awsAgentValues = new helpers.AWSAgentValues(deploymentType);
244
- awsAgentValues.cloudFormationConfig.DeploymentType = deploymentType;
245
- switch (awsAgentValues.cloudFormationConfig.DeploymentType) {
246
- case DeploymentTypes.ECS_FARGATE:
247
- {
248
- 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`));
249
- break;
250
- }
251
- case DeploymentTypes.OTHER:
252
- {
253
- console.log(_chalk.default.gray(`To access the AWS CLI, the AWS Access Key and AWS Secret Key credentials are required.\n`));
254
- break;
255
- }
256
- }
257
-
258
- // AWS Region
259
- awsAgentValues.region = await helpers.askAWSRegion();
260
-
261
- // S3 bucket
262
- awsAgentValues.cloudFormationConfig.AgentResourcesBucket = await (0, _basicPrompts.askInput)({
263
- msg: AWSPrompts.S3_BUCKET,
264
- validate: (0, _basicPrompts.validateRegex)(helpers.AWSRegexPatterns.AWS_REGEXP, InvalidMsg.S3_BUCKET)
265
- });
266
-
267
- // APIGWCWRoleSetup
268
- awsAgentValues.cloudFormationConfig.APIGWCWRoleSetup = await askToCreateRoleSetup();
269
-
270
- // APIGWTrafficLogGroupName
271
- const apiGWTrafficLogGroupName = await (0, _basicPrompts.askInput)({
272
- msg: AWSPrompts.APIGW_LOG_GROUP,
273
- defaultValue: awsAgentValues.cloudFormationConfig.APIGWTrafficLogGroupName,
274
- validate: (0, _basicPrompts.validateRegex)(helpers.AWSRegexPatterns.AWS_REGEXP_LOG_GROUP_NAME, InvalidMsg.LOG_GROUP)
275
- });
276
- awsAgentValues.logGroup = apiGWTrafficLogGroupName;
277
- awsAgentValues.cloudFormationConfig.APIGWTrafficLogGroupName = apiGWTrafficLogGroupName;
278
-
279
- // StageTagName
280
- const stageTagName = await (0, _basicPrompts.askInput)({
281
- msg: AWSPrompts.STAGE_TAG_NAME,
282
- validate: (0, _basicPrompts.validateInputLength)(STAGE_TAG_NAME_LENGTH, "Maximum length of 'stage tag name' is 127")
283
- });
284
- awsAgentValues.stageTagName = stageTagName;
285
-
286
- // FullTransactionLogging
287
- const fullTransactionLogging = (await (0, _basicPrompts.askList)({
288
- msg: AWSPrompts.FULL_TRANSACTION_LOGGING,
289
- choices: _types.YesNoChoices,
290
- default: _types.YesNo.No
291
- })) === _types.YesNo.Yes;
292
- awsAgentValues.fullTransactionLogging = fullTransactionLogging;
293
-
294
- // set agent versions
295
- awsAgentValues.cloudFormationConfig.DiscoveryAgentVersion = installConfig.daVersion;
296
- awsAgentValues.cloudFormationConfig.TraceabilityAgentVersion = installConfig.taVersion;
297
-
298
- // Configure appropriate Gateway type
299
- switch (awsAgentValues.cloudFormationConfig.DeploymentType) {
300
- case DeploymentTypes.ECS_FARGATE:
301
- {
302
- awsAgentValues = await configureECSDeployment(awsAgentValues);
303
- break;
304
- }
305
- case DeploymentTypes.EC2:
306
- {
307
- awsAgentValues = await configureEC2Deployment(awsAgentValues);
308
- break;
309
- }
310
- }
311
-
312
- // DiscoveryAgentLogGroupName
313
- awsAgentValues.cloudFormationConfig.DiscoveryAgentLogGroupName = await (0, _basicPrompts.askInput)({
314
- msg: AWSPrompts.DA_LOG_GROUP,
315
- defaultValue: awsAgentValues.cloudFormationConfig.DiscoveryAgentLogGroupName,
316
- validate: (0, _basicPrompts.validateRegex)(helpers.AWSRegexPatterns.AWS_REGEXP_LOG_GROUP_NAME, InvalidMsg.LOG_GROUP)
317
- });
318
-
319
- // TraceabilityAgentLogGroupName
320
- awsAgentValues.cloudFormationConfig.TraceabilityAgentLogGroupName = await (0, _basicPrompts.askInput)({
321
- msg: AWSPrompts.TA_LOG_GROUP,
322
- defaultValue: awsAgentValues.cloudFormationConfig.TraceabilityAgentLogGroupName,
323
- validate: (0, _basicPrompts.validateRegex)(helpers.AWSRegexPatterns.AWS_REGEXP_LOG_GROUP_NAME, InvalidMsg.LOG_GROUP)
324
- });
325
- return awsAgentValues;
326
- };
327
- exports.gatewayConnectivity = gatewayConnectivity;
328
- const generateOutput = async installConfig => {
329
- const awsAgentValues = installConfig.gatewayConfig;
330
- let s3BaseFiles = [ConfigFiles.DeployAllYAML, ConfigFiles.ResourcesYAML];
331
- let additionalSteps = '';
332
- let dockerEnvConfig = '';
333
- let runCommands = '';
334
- // Configure appropriate Gateway type
335
- switch (awsAgentValues.cloudFormationConfig.DeploymentType) {
336
- case DeploymentTypes.ECS_FARGATE:
337
- {
338
- // DeploymentTypes.ECS_FARGATE
339
- s3BaseFiles.push(ConfigFiles.FargateDeployYAML);
340
- additionalSteps = ` - Create the SSM parameter:
341
- ${_chalk.default.cyan(` aws ssm put-parameter --type SecureString --name ${awsAgentValues.cloudFormationConfig.SSMPrivateKeyParameter} --value "file:\/\/private_key.pem"`)}
342
- ${_chalk.default.cyan(` aws ssm put-parameter --type SecureString --name ${awsAgentValues.cloudFormationConfig.SSMPublicKeyParameter} --value "file:\/\/public_key.pem"`)}`;
343
- // Cleanup EC2 file
344
- _fs.default.unlinkSync(ConfigFiles.EC2DeployYAML);
345
- break;
346
- }
347
- case DeploymentTypes.OTHER:
348
- {
349
- // DeploymentTypes.OTHER for Docker Container Only
350
- // These files need to be put in a resources dir on S3
351
- let s3ResourcesIncludes = '';
352
- [ConfigFiles.DAEnvVars, ConfigFiles.TAEnvVars].forEach(value => s3ResourcesIncludes += `--include "${value}" `);
353
-
354
- // Cleanup EC2 file
355
- _fs.default.unlinkSync(ConfigFiles.EC2DeployYAML);
356
- // Cleanup ECS Fargate file
357
- _fs.default.unlinkSync(ConfigFiles.FargateDeployYAML);
358
- 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}):`;
359
- dockerEnvConfig = `Wait for the CloudFormation Stack to complete.
360
- - Create AWS Access and Secret Keys and copy resulting ${_chalk.default.yellow(`"AccessKeyId"`)} & ${_chalk.default.yellow(`"SecretAccessKey"`)}:
361
- ${_chalk.default.cyan(` aws iam create-access-key --user-name AxwayAmplifyAgentsUser-${awsAgentValues.region} ${helpers.eolChar}
362
- --query "AccessKey.{"AccessKeyId":AccessKeyId,"SecretAccessKey":SecretAccessKey}"`)}
363
- - Add "AccessKeyId" & "SecretAccessKey" variables to both agent .env files, ${ConfigFiles.DAEnvVars} & ${ConfigFiles.TAEnvVars}:
364
- AWS_AUTH_ACCESSKEY=${_chalk.default.yellow(`Your_AccessKeyId`)}
365
- AWS_AUTH_SECRETKEY=${_chalk.default.yellow(`Your_SecretAccessKey`)}`;
366
- runCommands = `${_chalk.default.whiteBright(info)}
367
-
368
- Pull the latest image of the Discovery Agent:
369
- ${_chalk.default.cyan(`docker pull ${daImage}:${installConfig.daVersion}`)}
370
-
371
- Pull the latest image of the Traceability Agent:
372
- ${_chalk.default.cyan(`docker pull ${taImage}:${installConfig.taVersion}`)}
373
- ${_utils.isWindows ? `
374
- Start the Discovery agent on Windows machine (cmd.exe):
375
- ${_chalk.default.cyan(`docker run --env-file ${helpers.pwdWin}/${ConfigFiles.DAEnvVars} -v ${helpers.pwdWin}:/keys ${helpers.eolCharWin}
376
- -v /data ${daImage}:${installConfig.daVersion}`)}` : `
377
- Start the Discovery agent on Linux based machine:
378
- ${_chalk.default.cyan(`docker run --env-file ${helpers.pwd}/${ConfigFiles.DAEnvVars} -v ${helpers.pwd}:/keys ${helpers.eolChar}
379
- -v /data ${daImage}:${installConfig.daVersion}`)}`}
380
- ${_utils.isWindows ? `
381
- Start the Traceability agent on Windows machine (cmd.exe):
382
- ${_chalk.default.cyan(`docker run --env-file ${helpers.pwdWin}/${ConfigFiles.TAEnvVars} -v ${helpers.pwdWin}:/keys ${helpers.eolCharWin}
383
- -v /data ${taImage}:${installConfig.taVersion}`)}` : `
384
- Start the Traceability agent on Linux based machine:
385
- ${_chalk.default.cyan(`docker run --env-file ${helpers.pwd}/${ConfigFiles.TAEnvVars} -v ${helpers.pwd}:/keys ${helpers.eolChar}
386
- -v /data ${taImage}:${installConfig.taVersion}`)}`}`;
387
- break;
388
- }
389
- default:
390
- {
391
- // DeploymentTypes.EC2
392
- s3BaseFiles.push(ConfigFiles.EC2DeployYAML);
393
- // These files need to be put in a resources dir on S3
394
- let s3ResourcesIncludes = '';
395
- [ConfigFiles.DAEnvVars, ConfigFiles.TAEnvVars].forEach(value => s3ResourcesIncludes += `--include "${value}" `);
396
- additionalSteps = `${_chalk.default.cyan(` aws s3 sync --exclude "*" ${s3ResourcesIncludes} ./ s3://${awsAgentValues.cloudFormationConfig.AgentResourcesBucket}/resources`)}
397
- - If necessary, create EC2 KeyPair, for EC2 login:
398
- ${_chalk.default.cyan(` aws ec2 create-key-pair --key-name ${awsAgentValues.cloudFormationConfig.EC2KeyName} --query KeyMaterial --output text > MyKeyPair.pem`)}
399
- - Create the SSM parameter:
400
- ${_chalk.default.cyan(` aws ssm put-parameter --type SecureString --name ${awsAgentValues.cloudFormationConfig.SSMPrivateKeyParameter} --value "file:\/\/private_key.pem"`)}
401
- ${_chalk.default.cyan(` aws ssm put-parameter --type SecureString --name ${awsAgentValues.cloudFormationConfig.SSMPublicKeyParameter} --value "file:\/\/public_key.pem"`)}`;
402
- // Cleanup Fargate file
403
- _fs.default.unlinkSync(ConfigFiles.FargateDeployYAML);
404
- break;
405
- }
406
- }
407
- let s3BaseIncludes = '';
408
- s3BaseFiles.forEach(value => s3BaseIncludes += `--include "${value}" `);
409
- // if region is AWS default, 'us-east-1', region unnecessary in cloudformation template url
410
- const s3Region = awsAgentValues.region === _types.AWSRegions.US_EAST_1 ? `s3` : `s3.${awsAgentValues.region}`;
411
- return `
412
- To complete the install, run the following AWS CLI command:
413
- - Create, if necessary, and upload all files to your S3 bucket
414
- ${_chalk.default.cyan(` aws s3api create-bucket --bucket ${awsAgentValues.cloudFormationConfig.AgentResourcesBucket} --create-bucket-configuration LocationConstraint=${awsAgentValues.region}`)}
415
- ${_chalk.default.cyan(` aws s3 sync --exclude "*" ${s3BaseIncludes} ./ s3://${awsAgentValues.cloudFormationConfig.AgentResourcesBucket}`)}
416
- ${additionalSteps}
417
- - Deploy the CloudFormation Stack:
418
- ${_chalk.default.cyan(` aws cloudformation create-stack --stack-name AxwayAmplifyAgents ${helpers.eolChar}
419
- --template-url https://${awsAgentValues.cloudFormationConfig.AgentResourcesBucket}.${s3Region}.amazonaws.com/${ConfigFiles.DeployAllYAML} ${helpers.eolChar}
420
- --capabilities CAPABILITY_IAM CAPABILITY_AUTO_EXPAND CAPABILITY_NAMED_IAM --parameters "file:\/\/${ConfigFiles.CFProperties}"`)}
421
- - Check the CloudFormation Stack:
422
- ${_chalk.default.cyan(` aws cloudformation describe-stacks --stack-name AxwayAmplifyAgents ${helpers.eolChar}
423
- --query "Stacks[].{\"Name\":StackName,\"Status\":StackStatus}"`)}
424
- ${dockerEnvConfig}
425
-
426
- ${runCommands}
427
-
428
- ${_chalk.default.gray(`Additional information about agent features can be found here:\n${helpers.agentsDocsUrl.AWS}`)}\n
429
- `;
430
- };
431
-
432
- // Download latest aws apigw config zip
433
- const downloadAPIGWAgentConfigZip = async () => {
434
- const url = `/aws_apigw_agent_config/latest/${ConfigFiles.AgentConfigZip}`;
435
- const service = await (0, _dataService.dataService)({
436
- baseUrl: _types.PublicRepoUrl,
437
- basePath: _types.BasePaths.AWSAgents
438
- });
439
- try {
440
- const {
441
- stream
442
- } = await service.download(url);
443
- await helpers.streamPipeline(stream, _fs.default.createWriteStream(ConfigFiles.AgentConfigZip));
444
- return ConfigFiles.AgentConfigZip;
445
- } catch (err) {
446
- throw new Error(`Failed to download the agent: ${err.message}`);
447
- }
448
- };
449
-
450
- // Unzip latest aws apigw config zip
451
- const unzipAPIGWAgentConfigZip = async zipFile => {
452
- await helpers.unzip(zipFile);
453
- _fs.default.unlinkSync(zipFile);
454
- const isCloudFormation = _fs.default.existsSync(ConfigFiles.DeployAllYAML);
455
- if (!isCloudFormation) {
456
- console.log(`${ConfigFiles.DeployAllYAML} was not extracted from ${ConfigFiles.AgentConfigZip}`);
457
- return false;
458
- }
459
- return true;
460
- };
461
- const installPreprocess = async installConfig => {
462
- // attempt to download the cloud formation files
463
- console.log(_chalk.default.gray(`Downloading the latest Cloud formation template...`));
464
- let apigwAgentConfigZipFile = await downloadAPIGWAgentConfigZip();
465
- if (apigwAgentConfigZipFile !== '') {
466
- console.log(_chalk.default.gray(`\nSuccess`));
467
- }
468
- installConfig.gatewayConfig.apigwAgentConfigZipFile = apigwAgentConfigZipFile;
469
- return installConfig;
470
- };
471
- exports.installPreprocess = installPreprocess;
472
- const completeInstall = async installConfig => {
473
- /**
474
- * Create agent resources
475
- */
476
- const awsAgentValues = installConfig.gatewayConfig;
477
-
478
- // Add final settings to awsAgentsValues
479
- awsAgentValues.centralConfig = installConfig.centralConfig;
480
- awsAgentValues.traceabilityConfig = installConfig.traceabilityConfig;
481
- const unpackZip = await unzipAPIGWAgentConfigZip(awsAgentValues.apigwAgentConfigZipFile);
482
- if (unpackZip) {
483
- console.log('\nCreating the agent environment files for AWS...');
484
- }
485
- console.log('Generating the configuration file(s)...');
486
- console.log('Generating the cloud formation parameters file...');
487
- let paramStrings = [];
488
- awsAgentValues.updateCloudFormationConfig();
489
- for (let [key, value] of Object.entries(awsAgentValues.cloudFormationConfig)) {
490
- paramStrings.push(`{"ParameterKey": "${key}", "ParameterValue": "${value}"}`);
491
- }
492
- (0, _utils.writeToFile)(ConfigFiles.CFProperties, `[\n${paramStrings.join(',\n')}\n]`);
493
- if (installConfig.switches.isDaEnabled && DeploymentTypes.ECS_FARGATE !== awsAgentValues.cloudFormationConfig.DeploymentType) {
494
- log('GENERATING DA TEMPLATE');
495
- (0, _utils.writeTemplates)(ConfigFiles.DAEnvVars, awsAgentValues, helpers.awsDAEnvVarTemplate);
496
- }
497
- if (installConfig.switches.isTaEnabled && DeploymentTypes.ECS_FARGATE !== awsAgentValues.cloudFormationConfig.DeploymentType) {
498
- log('GENERATING TA TEMPLATE');
499
- (0, _utils.writeTemplates)(ConfigFiles.TAEnvVars, awsAgentValues, helpers.awsTAEnvVarTemplate);
500
- }
501
- console.log('Configuration file(s) have been successfully created.\n');
502
- console.log(await generateOutput(installConfig));
503
- };
504
- exports.completeInstall = completeInstall;
505
- const AWSInstallMethods = exports.AWSInstallMethods = {
506
- GetBundleType: askBundleType,
507
- GetDeploymentType: askConfigType,
508
- AskGatewayQuestions: gatewayConnectivity,
509
- InstallPreprocess: installPreprocess,
510
- FinalizeGatewayInstall: completeInstall,
511
- ConfigFiles: Object.values(ConfigFiles),
512
- AgentNameMap: {
513
- [_types.AgentTypes.da]: _types.AgentNames.AWS_DA,
514
- [_types.AgentTypes.ta]: _types.AgentNames.AWS_TA
515
- },
516
- GatewayDisplay: _types.GatewayTypes.AWS_GATEWAY
517
- };
518
-
519
- // These are the items that are not exported, but need to be for testing
520
- const testables = exports.testables = {
521
- DeploymentTypes,
522
- AWSPrompts,
523
- EC2InstanceTypes,
524
- ConfigFiles
525
- };