aws-architect 6.7.144 → 6.7.146
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.
|
@@ -517,6 +517,47 @@ class CloudFormationDeployer {
|
|
|
517
517
|
await this.cloudFormationClient.createStackSet(stackParameters).promise();
|
|
518
518
|
}
|
|
519
519
|
|
|
520
|
+
const org = new Organizations({ region: 'us-east-1' });
|
|
521
|
+
const rootOrgsInfo = await org.listRoots({}).promise();
|
|
522
|
+
const rootOuIds = options.orgIds || rootOrgsInfo.Roots.map(root => root.Id);
|
|
523
|
+
|
|
524
|
+
try {
|
|
525
|
+
let allAccounts = [];
|
|
526
|
+
let nextToken;
|
|
527
|
+
do {
|
|
528
|
+
const response = await org.listAccounts({ NextToken: nextToken }).promise();
|
|
529
|
+
allAccounts.push(...response.Accounts);
|
|
530
|
+
nextToken = response.NextToken;
|
|
531
|
+
} while (nextToken);
|
|
532
|
+
|
|
533
|
+
const suspendedAccountIds = new Set(allAccounts.filter(a => a.Status === 'SUSPENDED' || a.Status === 'PENDING_CLOSURE').map(a => a.Id));
|
|
534
|
+
const existingInstances = await this.cloudFormationClient.listStackInstances({ StackSetName: options.stackSetName }).promise().then(d => d.Summaries);
|
|
535
|
+
const suspendedInstances = existingInstances.filter(s => suspendedAccountIds.has(s.Account));
|
|
536
|
+
const uniqueSuspendedAccounts = [...new Set(suspendedInstances.map(s => s.Account))];
|
|
537
|
+
|
|
538
|
+
if (uniqueSuspendedAccounts.length) {
|
|
539
|
+
const suspendedRegions = [...new Set(suspendedInstances.map(s => s.Region))];
|
|
540
|
+
console.log(`Removing stack instances from ${uniqueSuspendedAccounts.length} suspended accounts: ${uniqueSuspendedAccounts.join(', ')}`);
|
|
541
|
+
await this.cloudFormationClient.deleteStackInstances({
|
|
542
|
+
StackSetName: options.stackSetName,
|
|
543
|
+
DeploymentTargets: {
|
|
544
|
+
OrganizationalUnitIds: rootOuIds,
|
|
545
|
+
Accounts: uniqueSuspendedAccounts,
|
|
546
|
+
AccountFilterType: 'INTERSECTION'
|
|
547
|
+
},
|
|
548
|
+
Regions: suspendedRegions,
|
|
549
|
+
RetainStacks: true,
|
|
550
|
+
OperationPreferences: {
|
|
551
|
+
FailureToleranceCount: uniqueSuspendedAccounts.length,
|
|
552
|
+
MaxConcurrentCount: 20,
|
|
553
|
+
RegionConcurrencyType: 'PARALLEL'
|
|
554
|
+
}
|
|
555
|
+
}).promise();
|
|
556
|
+
}
|
|
557
|
+
} catch (error) {
|
|
558
|
+
console.log('Skipping removal of suspected account stackset, due to error:', error);
|
|
559
|
+
}
|
|
560
|
+
|
|
520
561
|
const currentStackData = await this.cloudFormationClient.describeStackSet({ StackSetName: options.stackSetName }).promise().then(data => data.StackSet);
|
|
521
562
|
const rawRegions = await new EC2().describeRegions().promise().then(data => data.Regions.map(r => r.RegionName));
|
|
522
563
|
const newRegions = rawRegions.filter(r => !currentStackData.Regions || !currentStackData.Regions.some(e => e === r))
|
|
@@ -548,12 +589,10 @@ class CloudFormationDeployer {
|
|
|
548
589
|
return { title: 'Success' };
|
|
549
590
|
}
|
|
550
591
|
|
|
551
|
-
const rootOrgsInfo = await new Organizations({ region: 'us-east-1' }).listRoots({}).promise();
|
|
552
|
-
|
|
553
592
|
const deployToAdditionalRegionsParams = {
|
|
554
593
|
StackSetName: options.stackSetName,
|
|
555
594
|
DeploymentTargets: {
|
|
556
|
-
OrganizationalUnitIds:
|
|
595
|
+
OrganizationalUnitIds: rootOuIds
|
|
557
596
|
},
|
|
558
597
|
Regions: newRegions,
|
|
559
598
|
OperationId: changeSetName,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "aws-architect",
|
|
3
|
-
"version": "6.7.
|
|
3
|
+
"version": "6.7.146",
|
|
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",
|
|
@@ -12,7 +12,7 @@
|
|
|
12
12
|
],
|
|
13
13
|
"scripts": {
|
|
14
14
|
"lint": "eslint --ext .js tests lib index.js",
|
|
15
|
-
"test": "
|
|
15
|
+
"test": "vitest run"
|
|
16
16
|
},
|
|
17
17
|
"bin": {
|
|
18
18
|
"aws-architect": "./bin/aws-architect.js"
|
|
@@ -42,17 +42,15 @@
|
|
|
42
42
|
"devDependencies": {
|
|
43
43
|
"@authress/eslint-config": "^1.0.2",
|
|
44
44
|
"aws-sdk": "*",
|
|
45
|
-
"chai": "^3.5.0",
|
|
46
45
|
"error-object-polyfill": "^1.1.14",
|
|
47
46
|
"eslint": "~8.35.0",
|
|
48
47
|
"eslint-config-cimpress-atsquad": "^1.0.67",
|
|
49
48
|
"eslint-plugin-import": "^2.22.1",
|
|
50
|
-
"eslint-plugin-mocha": "^10.0.5",
|
|
51
49
|
"eslint-plugin-node": "^11.1.0",
|
|
52
50
|
"eslint-plugin-promise": "^6.1.1",
|
|
53
51
|
"glob": "^5.0.15",
|
|
54
|
-
"
|
|
55
|
-
"
|
|
52
|
+
"sinon": "^1.17.3",
|
|
53
|
+
"vitest": "^3.0.0"
|
|
56
54
|
},
|
|
57
55
|
"repository": {
|
|
58
56
|
"type": "git",
|
|
@@ -1,74 +0,0 @@
|
|
|
1
|
-
let { describe, it } = require('mocha');
|
|
2
|
-
let assert = require('chai').assert;
|
|
3
|
-
|
|
4
|
-
describe('src/index.js', function() {
|
|
5
|
-
describe('Test Handler', function () {
|
|
6
|
-
it('GET livecheck', function() {
|
|
7
|
-
try {
|
|
8
|
-
let api = require('../src/index');
|
|
9
|
-
|
|
10
|
-
let result = api.Routes['GET']['/livecheck'].Handler();
|
|
11
|
-
let expectedResult = {
|
|
12
|
-
statusCode: 200,
|
|
13
|
-
body: JSON.stringify({
|
|
14
|
-
'field': 'hello world'
|
|
15
|
-
}),
|
|
16
|
-
headers: {
|
|
17
|
-
'Content-Type': 'application/json'
|
|
18
|
-
}
|
|
19
|
-
}
|
|
20
|
-
assert.equal(result.statusCode, expectedResult.statusCode, 'Expected ANY /proxy status code to have matching value.')
|
|
21
|
-
assert.deepEqual(result.headers, expectedResult.headers, 'Expected ANY /proxy headers to have matching value.')
|
|
22
|
-
assert.equal(result.body, expectedResult.body, 'Expected ANY /proxy body to have matching value.')
|
|
23
|
-
}
|
|
24
|
-
catch(e) {
|
|
25
|
-
console.error(e.stack);
|
|
26
|
-
assert(false, e.toString());
|
|
27
|
-
}
|
|
28
|
-
});
|
|
29
|
-
it('ANY', function() {
|
|
30
|
-
try {
|
|
31
|
-
let api = require('../src/index');
|
|
32
|
-
|
|
33
|
-
let result = api.Routes['ANY']['/{proxy+}'].Handler();
|
|
34
|
-
let expectedResult = {
|
|
35
|
-
statusCode: 404,
|
|
36
|
-
body: JSON.stringify({}),
|
|
37
|
-
headers: {
|
|
38
|
-
'Content-Type': 'application/json'
|
|
39
|
-
}
|
|
40
|
-
}
|
|
41
|
-
assert.equal(result.statusCode, expectedResult.statusCode, 'Expected ANY /proxy status code to have matching value.')
|
|
42
|
-
assert.deepEqual(result.headers, expectedResult.headers, 'Expected ANY /proxy headers to have matching value.')
|
|
43
|
-
assert.equal(result.body, expectedResult.body, 'Expected ANY /proxy body to have matching value.')
|
|
44
|
-
}
|
|
45
|
-
catch(e) {
|
|
46
|
-
console.error(e.stack);
|
|
47
|
-
assert(false, e.toString());
|
|
48
|
-
}
|
|
49
|
-
});
|
|
50
|
-
});
|
|
51
|
-
describe('Non-RESTful Test', function () {
|
|
52
|
-
/*
|
|
53
|
-
it('GET', function(done) {
|
|
54
|
-
try {
|
|
55
|
-
let lambda = require('../src/index');
|
|
56
|
-
new Promise((s, f) => {
|
|
57
|
-
lambda({}, {}, (failure, success) => {
|
|
58
|
-
if(success && !failure) { return s(success); }
|
|
59
|
-
else { f(failure); }
|
|
60
|
-
});
|
|
61
|
-
})
|
|
62
|
-
.then(output => {
|
|
63
|
-
done();
|
|
64
|
-
})
|
|
65
|
-
.catch(failure => done(failure));
|
|
66
|
-
}
|
|
67
|
-
catch(e) {
|
|
68
|
-
console.error(e.stack);
|
|
69
|
-
assert(false, e.toString());
|
|
70
|
-
}
|
|
71
|
-
});
|
|
72
|
-
*/
|
|
73
|
-
});
|
|
74
|
-
});
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
let { describe, it } = require('mocha');
|
|
2
|
-
let assert = require('chai').assert;
|
|
3
|
-
let fs = require('fs');
|
|
4
|
-
let path = require('path');
|
|
5
|
-
|
|
6
|
-
describe('make.js', function() {
|
|
7
|
-
describe('Syntax', function () {
|
|
8
|
-
it('Should be valid node', function(){
|
|
9
|
-
try {
|
|
10
|
-
let app = require('../make');
|
|
11
|
-
assert(true);
|
|
12
|
-
}
|
|
13
|
-
catch(e) {
|
|
14
|
-
console.log(e.stack);
|
|
15
|
-
assert(false, e.toString());
|
|
16
|
-
}
|
|
17
|
-
});
|
|
18
|
-
});
|
|
19
|
-
});
|