aws-architect 6.7.133 → 6.7.136

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.
@@ -13,6 +13,17 @@ function tryParseJson(stringContent) {
13
13
  }
14
14
  }
15
15
 
16
+ function getChangeSetName(changeSetName) {
17
+ let newChangeSetName = '';
18
+ if (!changeSetName[0].match(/[a-z]/ig)) {
19
+ newChangeSetName = 'v';
20
+ }
21
+
22
+ newChangeSetName += changeSetName.replace(/[^a-z0-9-]/gi, '-');
23
+
24
+ return newChangeSetName;
25
+ }
26
+
16
27
  class CloudFormationDeployer {
17
28
  constructor(region, bucketManager, deploymentBucket) {
18
29
  this.cloudFormationClient = new CloudFormation({ region });
@@ -159,7 +170,9 @@ class CloudFormationDeployer {
159
170
  await iteratePromise();
160
171
  }
161
172
 
162
- async waitForChangeSetCreation(stackName, changeSetName) {
173
+ async waitForChangeSetCreation(stackName, rawChangeSetName) {
174
+ const changeSetName = getChangeSetName(rawChangeSetName);
175
+
163
176
  let timeout = new Date();
164
177
  let timeoutLength = 60 * 1000;
165
178
  timeout.setTime(timeout.getTime() + timeoutLength);
@@ -213,9 +226,11 @@ class CloudFormationDeployer {
213
226
  let region = this.cloudFormationClient.config.region;
214
227
  console.log(`Starting Configuration of Stack: ${options.stackName} in ${region}`);
215
228
 
229
+ const changeSetName = getChangeSetName(options.changeSetName);
230
+
216
231
  let stackExists = await this.stackExists(options.stackName);
217
232
  let stackParameters = {
218
- ChangeSetName: options.changeSetName,
233
+ ChangeSetName: changeSetName,
219
234
  StackName: options.stackName,
220
235
  Capabilities: ['CAPABILITY_IAM', 'CAPABILITY_NAMED_IAM'],
221
236
  ChangeSetType: stackExists ? 'UPDATE' : 'CREATE',
@@ -258,14 +273,14 @@ class CloudFormationDeployer {
258
273
  }
259
274
 
260
275
  let executeParameters = {
261
- ChangeSetName: options.changeSetName,
276
+ ChangeSetName: getChangeSetName(stackParameters.ChangeSetName),
262
277
  StackName: options.stackName
263
278
  };
264
279
 
265
280
  console.log(`Deploying Stack: ${options.stackName} in ${region}`);
266
281
  try {
267
282
  await this.cloudFormationClient.createChangeSet(stackParameters).promise();
268
- await this.waitForChangeSetCreation(options.stackName, options.changeSetName);
283
+ await this.waitForChangeSetCreation(options.stackName, executeParameters.ChangeSetName);
269
284
  await this.cloudFormationClient.executeChangeSet(executeParameters).promise();
270
285
  } catch (error) {
271
286
  if (error.code === 'ValidationError' || error.code === 'MultipleValidationErrors' || error.code === 'InvalidParameterType') {
@@ -393,9 +408,10 @@ class CloudFormationDeployer {
393
408
  }
394
409
  }
395
410
 
411
+ const changeSetName = getChangeSetName(options.changeSetName);
396
412
  if (stackExists) {
397
413
  console.log('Updating stack set...');
398
- stackParameters.OperationId = `${options.changeSetName}-update`;
414
+ stackParameters.OperationId = `${changeSetName}-update`;
399
415
  stackParameters.OperationPreferences = {
400
416
  FailureToleranceCount: 20,
401
417
  MaxConcurrentCount: 20,
@@ -429,7 +445,7 @@ class CloudFormationDeployer {
429
445
  StackSetName: options.stackSetName,
430
446
  Accounts: [accountId],
431
447
  Regions: newRegions,
432
- OperationId: options.changeSetName,
448
+ OperationId: changeSetName,
433
449
  OperationPreferences: {
434
450
  FailureToleranceCount: 20,
435
451
  MaxConcurrentCount: 20,
@@ -505,9 +521,10 @@ class CloudFormationDeployer {
505
521
  }
506
522
  }
507
523
 
524
+ const changeSetName = getChangeSetName(options.changeSetName);
508
525
  if (stackExists) {
509
526
  console.log('Updating organizational stack set, stack will be updated asynchronously');
510
- stackParameters.OperationId = `${options.changeSetName}-update`;
527
+ stackParameters.OperationId = `${changeSetName}-update`;
511
528
  stackParameters.OperationPreferences = {
512
529
  FailureToleranceCount: 20,
513
530
  MaxConcurrentCount: 20,
@@ -529,7 +546,7 @@ class CloudFormationDeployer {
529
546
  OrganizationalUnitIds: rootOrgsInfo.Roots.map(org => org.Id)
530
547
  },
531
548
  Regions: newRegions,
532
- OperationId: options.changeSetName,
549
+ OperationId: changeSetName,
533
550
  OperationPreferences: {
534
551
  FailureToleranceCount: 20,
535
552
  MaxConcurrentCount: 20,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "aws-architect",
3
- "version": "6.7.133",
3
+ "version": "6.7.136",
4
4
  "description": "AWS Architect is a node based tool to configure and deploy AWS-based microservices.",
5
5
  "main": "index.js",
6
6
  "types": "index.d.ts",