@axway/axway-central-cli 3.10.0 → 3.11.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.
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": "1.0",
|
|
3
|
+
"project": "Amplify - APIC CLI",
|
|
4
|
+
"repo_url": "https://git.ecd.axway.org/apigov/apicentral-cli",
|
|
5
|
+
"security_guide": "https://docs.axway.com/bundle/axway_resources/page/amplify_api_management_platform_security_white_paper.html",
|
|
6
|
+
"requirements": {
|
|
7
|
+
"fortify": false,
|
|
8
|
+
"irius-risk": false,
|
|
9
|
+
"pentest": false,
|
|
10
|
+
"twistlock": false,
|
|
11
|
+
"blackduck": true,
|
|
12
|
+
"third-party-policy-violation": false,
|
|
13
|
+
"appspider": false,
|
|
14
|
+
"insightvm": false
|
|
15
|
+
},
|
|
16
|
+
"suppressions": [
|
|
17
|
+
]
|
|
18
|
+
}
|
|
@@ -20,6 +20,7 @@ const {
|
|
|
20
20
|
} = (0, _snooplogg.default)('central: install: agents: aws');
|
|
21
21
|
const daImage = `${_types.PublicDockerRepoBaseUrl}${_types.BasePaths.DockerAgentPublicRepo}/${_types.AgentNames.AWS_DA}`;
|
|
22
22
|
const taImage = `${_types.PublicDockerRepoBaseUrl}${_types.BasePaths.DockerAgentPublicRepo}/${_types.AgentNames.AWS_TA}`;
|
|
23
|
+
const STAGE_TAG_NAME_LENGTH = 127;
|
|
23
24
|
|
|
24
25
|
// DeploymentTypes - ways the agents may be deployed with an AWS APIGW setup
|
|
25
26
|
let DeploymentTypes = exports.DeploymentTypes = /*#__PURE__*/function (DeploymentTypes) {
|
|
@@ -66,6 +67,7 @@ const AWSPrompts = exports.AWSPrompts = {
|
|
|
66
67
|
CONFIG_BUCKET_EXISTS: 'Does this bucket already exist on AWS, or will you create beforehand?',
|
|
67
68
|
CONFIG_SERVICE: 'Do you want to setup config service?',
|
|
68
69
|
DA_LOG_GROUP: 'Enter the log group name the discovery agent will log to',
|
|
70
|
+
STAGE_TAG_NAME: 'Enter the name of the tag on AWS API Gateway Stage that holds mapped stage on Amplify Central',
|
|
69
71
|
DA_QUEUE: 'Enter the discovery queue name',
|
|
70
72
|
DEPLOYMENT: 'Select the type of deployment you wish to configure',
|
|
71
73
|
EC2_TYPE: 'Select the EC2 instance type',
|
|
@@ -276,6 +278,13 @@ const gatewayConnectivity = async installConfig => {
|
|
|
276
278
|
awsAgentValues.logGroup = apiGWTrafficLogGroupName;
|
|
277
279
|
awsAgentValues.cloudFormationConfig.APIGWTrafficLogGroupName = apiGWTrafficLogGroupName;
|
|
278
280
|
|
|
281
|
+
// StageTagName
|
|
282
|
+
const stageTagName = await (0, _basicPrompts.askInput)({
|
|
283
|
+
msg: AWSPrompts.STAGE_TAG_NAME,
|
|
284
|
+
validate: (0, _basicPrompts.validateInputLength)(STAGE_TAG_NAME_LENGTH, "Maximum length of 'stage tag name' is 127")
|
|
285
|
+
});
|
|
286
|
+
awsAgentValues.stageTagName = stageTagName;
|
|
287
|
+
|
|
279
288
|
// FullTransactionLogging
|
|
280
289
|
const fullTransactionLogging = (await (0, _basicPrompts.askList)({
|
|
281
290
|
msg: AWSPrompts.FULL_TRANSACTION_LOGGING,
|
|
@@ -21,6 +21,7 @@ function _toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e =
|
|
|
21
21
|
const {
|
|
22
22
|
log
|
|
23
23
|
} = (0, _snooplogg.default)('central: install: agents: saas');
|
|
24
|
+
const STAGE_TAG_NAME_LENGTH = 127;
|
|
24
25
|
class DataplaneConfig {
|
|
25
26
|
constructor(type) {
|
|
26
27
|
_defineProperty(this, "type", void 0);
|
|
@@ -28,12 +29,14 @@ class DataplaneConfig {
|
|
|
28
29
|
}
|
|
29
30
|
}
|
|
30
31
|
class AWSDataplaneConfig extends DataplaneConfig {
|
|
31
|
-
constructor(arn, enableFullTransactionLogging) {
|
|
32
|
+
constructor(arn, enableFullTransactionLogging, stageTagName) {
|
|
32
33
|
super('AWS');
|
|
33
34
|
_defineProperty(this, "accessLogARN", void 0);
|
|
34
35
|
_defineProperty(this, "fullTransactionLogging", void 0);
|
|
36
|
+
_defineProperty(this, "stageTagName", void 0);
|
|
35
37
|
this.accessLogARN = arn;
|
|
36
38
|
this.fullTransactionLogging = enableFullTransactionLogging;
|
|
39
|
+
this.stageTagName = stageTagName;
|
|
37
40
|
}
|
|
38
41
|
}
|
|
39
42
|
class Sampling {
|
|
@@ -108,6 +111,7 @@ class SaasAWSAgentValues extends SaasAgentValues {
|
|
|
108
111
|
_defineProperty(this, "externalID", void 0);
|
|
109
112
|
_defineProperty(this, "accessLogARN", void 0);
|
|
110
113
|
_defineProperty(this, "fullTransactionLogging", void 0);
|
|
114
|
+
_defineProperty(this, "stageTagName", void 0);
|
|
111
115
|
this.authType = AWSAuthType.ASSUME;
|
|
112
116
|
this.accessKey = '';
|
|
113
117
|
this.secretKey = '';
|
|
@@ -116,6 +120,7 @@ class SaasAWSAgentValues extends SaasAgentValues {
|
|
|
116
120
|
this.externalID = '';
|
|
117
121
|
this.accessLogARN = '';
|
|
118
122
|
this.fullTransactionLogging = false;
|
|
123
|
+
this.stageTagName = '';
|
|
119
124
|
}
|
|
120
125
|
getAccessData() {
|
|
121
126
|
let data = JSON.stringify({
|
|
@@ -150,6 +155,7 @@ const SaasPrompts = {
|
|
|
150
155
|
ASSUME_ROLE: 'Enter the Role ARN that the agent will Assume',
|
|
151
156
|
EXTERNAL_ID: 'Enter the External ID the Assume Role expects',
|
|
152
157
|
ACCESS_LOG_ARN: 'Enter the ARN for the Access Log that the Discovery will add and the Traceability will use',
|
|
158
|
+
STAGE_TAG_NAME: 'Enter the name of the tag on AWS API Gateway Stage that holds mapped stage on Amplify Central',
|
|
153
159
|
FULL_TRANSACTION_LOGGING: 'Do you want to enable Full Transaction Logging? Please note that CloudWatch costs would increase when Full Transaction Logging is enabled',
|
|
154
160
|
DA_FREQUENCY: 'How often should the discovery run, leave blank for integrating in CI/CD process',
|
|
155
161
|
DA_FILTER: 'Please enter the filter conditions for discovery of API Services based on tags',
|
|
@@ -335,6 +341,10 @@ const gatewayConnectivity = async installConfig => {
|
|
|
335
341
|
// AWS connection details
|
|
336
342
|
hostedAgentValues = new SaasAWSAgentValues();
|
|
337
343
|
hostedAgentValues = await askForAWSCredentials(hostedAgentValues);
|
|
344
|
+
hostedAgentValues.stageTagName = await (0, _basicPrompts.askInput)({
|
|
345
|
+
msg: SaasPrompts.STAGE_TAG_NAME,
|
|
346
|
+
validate: (0, _basicPrompts.validateInputLength)(STAGE_TAG_NAME_LENGTH, "Maximum length of 'stage tag name' is 127")
|
|
347
|
+
});
|
|
338
348
|
if (installConfig.switches.isTaEnabled) {
|
|
339
349
|
console.log(_chalk.default.gray('\nThe access log ARN is a cloud watch log group amazon resource name'));
|
|
340
350
|
hostedAgentValues.accessLogARN = await (0, _basicPrompts.askInput)({
|
|
@@ -403,33 +413,87 @@ const completeInstall = async (installConfig, apiServerClient, defsManager) => {
|
|
|
403
413
|
*/
|
|
404
414
|
console.log('\n');
|
|
405
415
|
let awsAgentValues = installConfig.gatewayConfig;
|
|
406
|
-
|
|
416
|
+
let resourceFuncsForCleanup = [];
|
|
417
|
+
let referencedIDPs = [];
|
|
418
|
+
let providedIDPs = installConfig.idpConfig[0];
|
|
419
|
+
let providedIDPAuths = installConfig.idpConfig[1];
|
|
420
|
+
// create Identity Provider resource
|
|
421
|
+
try {
|
|
422
|
+
for (let i = 0; i < providedIDPs.length; i++) {
|
|
423
|
+
let idpResource = await helpers.createNewIDPResource(apiServerClient, defsManager, providedIDPs[i]);
|
|
424
|
+
let cleanupFunc = async () => await helpers.deleteByResourceType(apiServerClient, defsManager, idpResource === null || idpResource === void 0 ? void 0 : idpResource.name, 'IdentityProvider', 'idp');
|
|
425
|
+
resourceFuncsForCleanup.push(cleanupFunc);
|
|
426
|
+
referencedIDPs.push({
|
|
427
|
+
name: idpResource === null || idpResource === void 0 ? void 0 : idpResource.name
|
|
428
|
+
});
|
|
429
|
+
log(idpResource);
|
|
430
|
+
let encryptedAccessData = await createEncryptedAccessData(providedIDPAuths[i], idpResource);
|
|
431
|
+
providedIDPAuths[i].setAccessData(encryptedAccessData);
|
|
432
|
+
let idpSecResource = await helpers.createNewIDPSecretResource(apiServerClient, defsManager, providedIDPAuths[i], idpResource);
|
|
433
|
+
let anotherCleanupFunc = async () => await helpers.deleteByResourceType(apiServerClient, defsManager, idpSecResource === null || idpSecResource === void 0 ? void 0 : idpSecResource.name, 'IdentityProviderSecret', 'idpsec', idpResource === null || idpResource === void 0 ? void 0 : idpResource.name);
|
|
434
|
+
resourceFuncsForCleanup.push(anotherCleanupFunc);
|
|
435
|
+
}
|
|
436
|
+
} catch (error) {
|
|
437
|
+
log(error);
|
|
438
|
+
console.log(_chalk.default.redBright('rolling back installation. Could not create the Identity Provider resources'));
|
|
439
|
+
await cleanResources(resourceFuncsForCleanup);
|
|
440
|
+
return;
|
|
441
|
+
}
|
|
442
|
+
let refIDPsSubResources = {
|
|
443
|
+
references: {
|
|
444
|
+
identityProviders: referencedIDPs
|
|
445
|
+
}
|
|
446
|
+
};
|
|
407
447
|
// create the environment, if necessary
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
448
|
+
if (installConfig.centralConfig.ampcEnvInfo.isNew) {
|
|
449
|
+
installConfig.centralConfig.environment = await helpers.createByResourceType(apiServerClient, defsManager, installConfig.centralConfig.ampcEnvInfo.name, 'Environment', 'env', {
|
|
450
|
+
axwayManaged: installConfig.centralConfig.axwayManaged,
|
|
451
|
+
production: installConfig.centralConfig.production
|
|
452
|
+
}, '', refIDPsSubResources);
|
|
453
|
+
let cleanupFunc = async () => await helpers.deleteByResourceType(apiServerClient, defsManager, installConfig.centralConfig.ampcEnvInfo.name, 'Environment', 'env');
|
|
454
|
+
resourceFuncsForCleanup.push(cleanupFunc);
|
|
455
|
+
} else {
|
|
456
|
+
// if the env exists, we simply update the references with the newly created IDPs, while preserving the existing IDP references
|
|
457
|
+
// In the case of any failure during the whole process, we return everything back to how it was before.
|
|
458
|
+
installConfig.centralConfig.environment = installConfig.centralConfig.ampcEnvInfo.name;
|
|
459
|
+
refIDPsSubResources.references.identityProviders.push(...installConfig.centralConfig.ampcEnvInfo.referencedIdentityProviders);
|
|
460
|
+
await helpers.updateSubResourceType(apiServerClient, defsManager, installConfig.centralConfig.ampcEnvInfo.name, 'Environment', 'env', '', refIDPsSubResources);
|
|
461
|
+
let oldIDPRef = {
|
|
462
|
+
references: {
|
|
463
|
+
identityProviders: installConfig.centralConfig.ampcEnvInfo.referencedIdentityProviders
|
|
464
|
+
}
|
|
465
|
+
};
|
|
466
|
+
let cleanupFunc = async () => await helpers.updateSubResourceType(apiServerClient, defsManager, installConfig.centralConfig.ampcEnvInfo.name, 'Environment', 'env', '', oldIDPRef);
|
|
467
|
+
resourceFuncsForCleanup.push(cleanupFunc);
|
|
468
|
+
}
|
|
412
469
|
if (installConfig.gatewayType === _types.GatewayTypes.AWS_GATEWAY) {
|
|
413
470
|
if (installConfig.switches.isTaEnabled) {
|
|
414
|
-
awsAgentValues.dataplaneConfig = new AWSDataplaneConfig(awsAgentValues.accessLogARN, awsAgentValues.fullTransactionLogging);
|
|
471
|
+
awsAgentValues.dataplaneConfig = new AWSDataplaneConfig(awsAgentValues.accessLogARN, awsAgentValues.fullTransactionLogging, awsAgentValues.stageTagName);
|
|
415
472
|
} else {
|
|
416
473
|
awsAgentValues.dataplaneConfig = new DataplaneConfig('AWS');
|
|
417
474
|
}
|
|
418
475
|
}
|
|
419
476
|
|
|
420
477
|
// create the data plane resource
|
|
421
|
-
let dataplaneRes
|
|
478
|
+
let dataplaneRes;
|
|
479
|
+
try {
|
|
480
|
+
dataplaneRes = await helpers.createNewDataPlaneResource(apiServerClient, defsManager, installConfig.centralConfig.environment, _types.GatewayTypeToDataPlane[installConfig.gatewayType], awsAgentValues.dataplaneConfig);
|
|
481
|
+
let cleanupFunc = async () => await helpers.deleteByResourceType(apiServerClient, defsManager, dataplaneRes.name, 'Dataplane', 'dp', installConfig.centralConfig.environment);
|
|
482
|
+
resourceFuncsForCleanup.push(cleanupFunc);
|
|
483
|
+
} catch (error) {
|
|
484
|
+
console.log(_chalk.default.redBright('rolling back installation. Please check the configuration data before re-running install'));
|
|
485
|
+
await cleanResources(resourceFuncsForCleanup);
|
|
486
|
+
return;
|
|
487
|
+
}
|
|
422
488
|
|
|
423
489
|
// create data plane secret resource
|
|
424
490
|
try {
|
|
425
|
-
await helpers.createNewDataPlaneSecretResource(apiServerClient, defsManager, installConfig.centralConfig.environment, _types.GatewayTypeToDataPlane[installConfig.gatewayType], dataplaneRes.name, await createEncryptedAccessData(awsAgentValues, dataplaneRes));
|
|
491
|
+
let dataplaneSecretRes = await helpers.createNewDataPlaneSecretResource(apiServerClient, defsManager, installConfig.centralConfig.environment, _types.GatewayTypeToDataPlane[installConfig.gatewayType], dataplaneRes.name, await createEncryptedAccessData(awsAgentValues, dataplaneRes));
|
|
492
|
+
let cleanupFunc = async () => await helpers.deleteByResourceType(apiServerClient, defsManager, dataplaneSecretRes === null || dataplaneSecretRes === void 0 ? void 0 : dataplaneSecretRes.name, 'DataplaneSecret', 'dps', installConfig.centralConfig.environment);
|
|
493
|
+
resourceFuncsForCleanup.push(cleanupFunc);
|
|
426
494
|
} catch (error) {
|
|
427
495
|
console.log(_chalk.default.redBright('rolling back installation. Please check the credential data before re-running install'));
|
|
428
|
-
|
|
429
|
-
await helpers.deleteByResourceType(apiServerClient, defsManager, installConfig.centralConfig.ampcEnvInfo.name, 'Environment', 'env');
|
|
430
|
-
} else {
|
|
431
|
-
await helpers.deleteByResourceType(apiServerClient, defsManager, dataplaneRes.name, 'Dataplane', 'dp', installConfig.centralConfig.environment);
|
|
432
|
-
}
|
|
496
|
+
await cleanResources(resourceFuncsForCleanup);
|
|
433
497
|
return;
|
|
434
498
|
}
|
|
435
499
|
|
|
@@ -450,6 +514,7 @@ const AWSSaaSInstallMethods = exports.AWSSaaSInstallMethods = {
|
|
|
450
514
|
GetBundleType: askBundleType,
|
|
451
515
|
GetDeploymentType: askConfigType,
|
|
452
516
|
AskGatewayQuestions: gatewayConnectivity,
|
|
517
|
+
AddIDP: true,
|
|
453
518
|
FinalizeGatewayInstall: completeInstall,
|
|
454
519
|
ConfigFiles: [],
|
|
455
520
|
AgentNameMap: {
|
|
@@ -466,4 +531,12 @@ const testables = exports.testables = {
|
|
|
466
531
|
AWSAuthType,
|
|
467
532
|
SaasPrompts,
|
|
468
533
|
ConfigFiles
|
|
534
|
+
};
|
|
535
|
+
// These are useful because there are multiple resources created in a specific order and in case of failure, this goes through
|
|
536
|
+
// everything that was created and deletes it one by one. It deletes the resources in opposite order because resources added
|
|
537
|
+
// at the beginning might be referred by resources added afterwards
|
|
538
|
+
const cleanResources = async cleanupFuncs => {
|
|
539
|
+
for (let i = cleanupFuncs.length - 1; i >= 0; i--) {
|
|
540
|
+
await cleanupFuncs[i]();
|
|
541
|
+
}
|
|
469
542
|
};
|
|
@@ -17,6 +17,7 @@ class AWSAgentValues {
|
|
|
17
17
|
_defineProperty(this, "accessKey", void 0);
|
|
18
18
|
_defineProperty(this, "secretKey", void 0);
|
|
19
19
|
_defineProperty(this, "logGroup", void 0);
|
|
20
|
+
_defineProperty(this, "stageTagName", void 0);
|
|
20
21
|
_defineProperty(this, "fullTransactionLogging", void 0);
|
|
21
22
|
_defineProperty(this, "region", void 0);
|
|
22
23
|
_defineProperty(this, "apigwAgentConfigZipFile", void 0);
|
|
@@ -36,6 +37,7 @@ class AWSAgentValues {
|
|
|
36
37
|
this.accessKey = awsDeployment === 'Other' ? '**Insert Access Key**' : '';
|
|
37
38
|
this.secretKey = awsDeployment === 'Other' ? '**Insert Secret Key**' : '';
|
|
38
39
|
this.logGroup = '';
|
|
40
|
+
this.stageTagName = '';
|
|
39
41
|
this.fullTransactionLogging = false;
|
|
40
42
|
this.region = '';
|
|
41
43
|
this.apigwAgentConfigZipFile = '';
|
|
@@ -107,6 +109,7 @@ AWS_AUTH_ACCESSKEY={{accessKey}}
|
|
|
107
109
|
AWS_AUTH_SECRETKEY={{secretKey}}
|
|
108
110
|
{{/if}}
|
|
109
111
|
AWS_LOGGROUP={{logGroup}}
|
|
112
|
+
AWS_STAGETAGNAME={{stageTagName}}
|
|
110
113
|
|
|
111
114
|
# Amplify Central configs
|
|
112
115
|
CENTRAL_AGENTNAME={{centralConfig.daAgentName}}
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.verifyApigeeXCredentialFile = exports.validateValueRange = exports.validateValidRegex = exports.validateRegex = exports.validateNonEmptyInput = exports.validateInputIsNew = exports.runValidations = exports.filterEmptyNumberInput = exports.askUsernameAndPassword = exports.askList = exports.askInputValidation = exports.askInput = exports.MAX_FILE_SIZE = void 0;
|
|
6
|
+
exports.verifyApigeeXCredentialFile = exports.validateValueRange = exports.validateValidRegex = exports.validateRegex = exports.validateNonEmptyInput = exports.validateInputLength = exports.validateInputIsNew = exports.runValidations = exports.filterEmptyNumberInput = exports.askUsernameAndPassword = exports.askList = exports.askInputValidation = exports.askInput = exports.MAX_FILE_SIZE = void 0;
|
|
7
7
|
var _inquirer = _interopRequireDefault(require("inquirer"));
|
|
8
8
|
var _fsExtra = require("fs-extra");
|
|
9
9
|
var _path = require("path");
|
|
@@ -30,6 +30,10 @@ const validateRegex = (regexp, message) => input => {
|
|
|
30
30
|
return input.toString().match(regexp) ? true : message;
|
|
31
31
|
};
|
|
32
32
|
exports.validateRegex = validateRegex;
|
|
33
|
+
const validateInputLength = (length, message) => input => {
|
|
34
|
+
return input.toString().length <= length ? true : message;
|
|
35
|
+
};
|
|
36
|
+
exports.validateInputLength = validateInputLength;
|
|
33
37
|
const MAX_FILE_SIZE = exports.MAX_FILE_SIZE = process.env.NODE_ENV === 'test' ? 1e5 : 20 * 1024 * 1024;
|
|
34
38
|
const verifyApigeeXCredentialFile = () => input => {
|
|
35
39
|
let stats;
|