@axway/axway-central-cli 3.10.0 → 3.11.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.
@@ -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);
@@ -108,6 +109,7 @@ class SaasAWSAgentValues extends SaasAgentValues {
108
109
  _defineProperty(this, "externalID", void 0);
109
110
  _defineProperty(this, "accessLogARN", void 0);
110
111
  _defineProperty(this, "fullTransactionLogging", void 0);
112
+ _defineProperty(this, "stageTagName", void 0);
111
113
  this.authType = AWSAuthType.ASSUME;
112
114
  this.accessKey = '';
113
115
  this.secretKey = '';
@@ -116,6 +118,7 @@ class SaasAWSAgentValues extends SaasAgentValues {
116
118
  this.externalID = '';
117
119
  this.accessLogARN = '';
118
120
  this.fullTransactionLogging = false;
121
+ this.stageTagName = '';
119
122
  }
120
123
  getAccessData() {
121
124
  let data = JSON.stringify({
@@ -150,6 +153,7 @@ const SaasPrompts = {
150
153
  ASSUME_ROLE: 'Enter the Role ARN that the agent will Assume',
151
154
  EXTERNAL_ID: 'Enter the External ID the Assume Role expects',
152
155
  ACCESS_LOG_ARN: 'Enter the ARN for the Access Log that the Discovery will add and the Traceability will use',
156
+ STAGE_TAG_NAME: 'Enter the name of the tag on AWS API Gateway Stage that holds mapped stage on Amplify Central',
153
157
  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
158
  DA_FREQUENCY: 'How often should the discovery run, leave blank for integrating in CI/CD process',
155
159
  DA_FILTER: 'Please enter the filter conditions for discovery of API Services based on tags',
@@ -335,6 +339,10 @@ const gatewayConnectivity = async installConfig => {
335
339
  // AWS connection details
336
340
  hostedAgentValues = new SaasAWSAgentValues();
337
341
  hostedAgentValues = await askForAWSCredentials(hostedAgentValues);
342
+ hostedAgentValues.stageTagName = await (0, _basicPrompts.askInput)({
343
+ msg: SaasPrompts.STAGE_TAG_NAME,
344
+ validate: (0, _basicPrompts.validateInputLength)(STAGE_TAG_NAME_LENGTH, "Maximum length of 'stage tag name' is 127")
345
+ });
338
346
  if (installConfig.switches.isTaEnabled) {
339
347
  console.log(_chalk.default.gray('\nThe access log ARN is a cloud watch log group amazon resource name'));
340
348
  hostedAgentValues.accessLogARN = await (0, _basicPrompts.askInput)({
@@ -403,12 +411,59 @@ const completeInstall = async (installConfig, apiServerClient, defsManager) => {
403
411
  */
404
412
  console.log('\n');
405
413
  let awsAgentValues = installConfig.gatewayConfig;
406
-
414
+ let resourceFuncsForCleanup = [];
415
+ let referencedIDPs = [];
416
+ let providedIDPs = installConfig.idpConfig[0];
417
+ let providedIDPAuths = installConfig.idpConfig[1];
418
+ // create Identity Provider resource
419
+ try {
420
+ for (let i = 0; i < providedIDPs.length; i++) {
421
+ let idpResource = await helpers.createNewIDPResource(apiServerClient, defsManager, providedIDPs[i]);
422
+ let cleanupFunc = async () => await helpers.deleteByResourceType(apiServerClient, defsManager, idpResource === null || idpResource === void 0 ? void 0 : idpResource.name, 'IdentityProvider', 'idp');
423
+ resourceFuncsForCleanup.push(cleanupFunc);
424
+ referencedIDPs.push({
425
+ name: idpResource === null || idpResource === void 0 ? void 0 : idpResource.name
426
+ });
427
+ log(idpResource);
428
+ let encryptedAccessData = await createEncryptedAccessData(providedIDPAuths[i], idpResource);
429
+ providedIDPAuths[i].setAccessData(encryptedAccessData);
430
+ let idpSecResource = await helpers.createNewIDPSecretResource(apiServerClient, defsManager, providedIDPAuths[i], idpResource);
431
+ 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);
432
+ resourceFuncsForCleanup.push(anotherCleanupFunc);
433
+ }
434
+ } catch (error) {
435
+ log(error);
436
+ console.log(_chalk.default.redBright('rolling back installation. Could not create the Identity Provider resources'));
437
+ await cleanResources(resourceFuncsForCleanup);
438
+ return;
439
+ }
440
+ let refIDPsSubResources = {
441
+ references: {
442
+ identityProviders: referencedIDPs
443
+ }
444
+ };
407
445
  // create the environment, if necessary
408
- installConfig.centralConfig.environment = installConfig.centralConfig.ampcEnvInfo.isNew ? await helpers.createByResourceType(apiServerClient, defsManager, installConfig.centralConfig.ampcEnvInfo.name, 'Environment', 'env', {
409
- axwayManaged: installConfig.centralConfig.axwayManaged,
410
- production: installConfig.centralConfig.production
411
- }) : installConfig.centralConfig.ampcEnvInfo.name;
446
+ if (installConfig.centralConfig.ampcEnvInfo.isNew) {
447
+ installConfig.centralConfig.environment = await helpers.createByResourceType(apiServerClient, defsManager, installConfig.centralConfig.ampcEnvInfo.name, 'Environment', 'env', {
448
+ axwayManaged: installConfig.centralConfig.axwayManaged,
449
+ production: installConfig.centralConfig.production
450
+ }, '', refIDPsSubResources);
451
+ let cleanupFunc = async () => await helpers.deleteByResourceType(apiServerClient, defsManager, installConfig.centralConfig.ampcEnvInfo.name, 'Environment', 'env');
452
+ resourceFuncsForCleanup.push(cleanupFunc);
453
+ } else {
454
+ // if the env exists, we simply update the references with the newly created IDPs, while preserving the existing IDP references
455
+ // In the case of any failure during the whole process, we return everything back to how it was before.
456
+ installConfig.centralConfig.environment = installConfig.centralConfig.ampcEnvInfo.name;
457
+ refIDPsSubResources.references.identityProviders.push(...installConfig.centralConfig.ampcEnvInfo.referencedIdentityProviders);
458
+ await helpers.updateSubResourceType(apiServerClient, defsManager, installConfig.centralConfig.ampcEnvInfo.name, 'Environment', 'env', '', refIDPsSubResources);
459
+ let oldIDPRef = {
460
+ references: {
461
+ identityProviders: installConfig.centralConfig.ampcEnvInfo.referencedIdentityProviders
462
+ }
463
+ };
464
+ let cleanupFunc = async () => await helpers.updateSubResourceType(apiServerClient, defsManager, installConfig.centralConfig.ampcEnvInfo.name, 'Environment', 'env', '', oldIDPRef);
465
+ resourceFuncsForCleanup.push(cleanupFunc);
466
+ }
412
467
  if (installConfig.gatewayType === _types.GatewayTypes.AWS_GATEWAY) {
413
468
  if (installConfig.switches.isTaEnabled) {
414
469
  awsAgentValues.dataplaneConfig = new AWSDataplaneConfig(awsAgentValues.accessLogARN, awsAgentValues.fullTransactionLogging);
@@ -418,18 +473,25 @@ const completeInstall = async (installConfig, apiServerClient, defsManager) => {
418
473
  }
419
474
 
420
475
  // create the data plane resource
421
- let dataplaneRes = await helpers.createNewDataPlaneResource(apiServerClient, defsManager, installConfig.centralConfig.environment, _types.GatewayTypeToDataPlane[installConfig.gatewayType], awsAgentValues.dataplaneConfig);
476
+ let dataplaneRes;
477
+ try {
478
+ dataplaneRes = await helpers.createNewDataPlaneResource(apiServerClient, defsManager, installConfig.centralConfig.environment, _types.GatewayTypeToDataPlane[installConfig.gatewayType], awsAgentValues.dataplaneConfig);
479
+ let cleanupFunc = async () => await helpers.deleteByResourceType(apiServerClient, defsManager, dataplaneRes.name, 'Dataplane', 'dp', installConfig.centralConfig.environment);
480
+ resourceFuncsForCleanup.push(cleanupFunc);
481
+ } catch (error) {
482
+ console.log(_chalk.default.redBright('rolling back installation. Please check the configuration data before re-running install'));
483
+ await cleanResources(resourceFuncsForCleanup);
484
+ return;
485
+ }
422
486
 
423
487
  // create data plane secret resource
424
488
  try {
425
- await helpers.createNewDataPlaneSecretResource(apiServerClient, defsManager, installConfig.centralConfig.environment, _types.GatewayTypeToDataPlane[installConfig.gatewayType], dataplaneRes.name, await createEncryptedAccessData(awsAgentValues, dataplaneRes));
489
+ let dataplaneSecretRes = await helpers.createNewDataPlaneSecretResource(apiServerClient, defsManager, installConfig.centralConfig.environment, _types.GatewayTypeToDataPlane[installConfig.gatewayType], dataplaneRes.name, await createEncryptedAccessData(awsAgentValues, dataplaneRes));
490
+ let cleanupFunc = async () => await helpers.deleteByResourceType(apiServerClient, defsManager, dataplaneSecretRes === null || dataplaneSecretRes === void 0 ? void 0 : dataplaneSecretRes.name, 'DataplaneSecret', 'dps', installConfig.centralConfig.environment);
491
+ resourceFuncsForCleanup.push(cleanupFunc);
426
492
  } catch (error) {
427
493
  console.log(_chalk.default.redBright('rolling back installation. Please check the credential data before re-running install'));
428
- if (installConfig.centralConfig.ampcEnvInfo.isNew) {
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
- }
494
+ await cleanResources(resourceFuncsForCleanup);
433
495
  return;
434
496
  }
435
497
 
@@ -450,6 +512,7 @@ const AWSSaaSInstallMethods = exports.AWSSaaSInstallMethods = {
450
512
  GetBundleType: askBundleType,
451
513
  GetDeploymentType: askConfigType,
452
514
  AskGatewayQuestions: gatewayConnectivity,
515
+ AddIDP: true,
453
516
  FinalizeGatewayInstall: completeInstall,
454
517
  ConfigFiles: [],
455
518
  AgentNameMap: {
@@ -466,4 +529,12 @@ const testables = exports.testables = {
466
529
  AWSAuthType,
467
530
  SaasPrompts,
468
531
  ConfigFiles
532
+ };
533
+ // These are useful because there are multiple resources created in a specific order and in case of failure, this goes through
534
+ // everything that was created and deletes it one by one. It deletes the resources in opposite order because resources added
535
+ // at the beginning might be referred by resources added afterwards
536
+ const cleanResources = async cleanupFuncs => {
537
+ for (let i = cleanupFuncs.length - 1; i >= 0; i--) {
538
+ await cleanupFuncs[i]();
539
+ }
469
540
  };
@@ -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;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@axway/axway-central-cli",
3
- "version": "3.10.0",
3
+ "version": "3.11.0-rc.0",
4
4
  "description": "Manage APIs, services and publish to the Amplify Marketplace",
5
5
  "homepage": "https://platform.axway.com",
6
6
  "author": {