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