@friggframework/devtools 2.0.0--canary.490.95ab577.0 → 2.0.0--canary.490.97a854f.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.
|
@@ -518,19 +518,31 @@ class AWSProviderAdapter extends CloudProviderAdapter {
|
|
|
518
518
|
|
|
519
519
|
/**
|
|
520
520
|
* List CloudFormation stack resources
|
|
521
|
+
* Handles pagination to retrieve all resources (CloudFormation limits to 1 MB per page)
|
|
521
522
|
*
|
|
522
523
|
* @param {string} stackName - Name of the CloudFormation stack
|
|
523
|
-
* @returns {Promise<Array>} List of stack resources
|
|
524
|
+
* @returns {Promise<Array>} List of all stack resources across all pages
|
|
524
525
|
*/
|
|
525
526
|
async listStackResources(stackName) {
|
|
526
527
|
const cf = this.getCloudFormationClient();
|
|
528
|
+
const allResources = [];
|
|
529
|
+
let nextToken = null;
|
|
527
530
|
|
|
528
531
|
try {
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
+
do {
|
|
533
|
+
const response = await cf.send(new ListStackResourcesCommand({
|
|
534
|
+
StackName: stackName,
|
|
535
|
+
NextToken: nextToken
|
|
536
|
+
}));
|
|
537
|
+
|
|
538
|
+
if (response.StackResourceSummaries) {
|
|
539
|
+
allResources.push(...response.StackResourceSummaries);
|
|
540
|
+
}
|
|
541
|
+
|
|
542
|
+
nextToken = response.NextToken || null;
|
|
543
|
+
} while (nextToken);
|
|
532
544
|
|
|
533
|
-
return
|
|
545
|
+
return allResources;
|
|
534
546
|
} catch (error) {
|
|
535
547
|
console.warn(`Failed to list stack resources for ${stackName}:`, error.message);
|
|
536
548
|
return [];
|
|
@@ -14,6 +14,45 @@ jest.mock('@aws-sdk/client-ssm');
|
|
|
14
14
|
jest.mock('@aws-sdk/client-secrets-manager');
|
|
15
15
|
|
|
16
16
|
describe('AWSProviderAdapter', () => {
|
|
17
|
+
describe('listStackResources', () => {
|
|
18
|
+
it.skip('should handle pagination and return all resources across multiple pages', async () => {
|
|
19
|
+
const mockCfClient = {
|
|
20
|
+
send: jest.fn()
|
|
21
|
+
.mockResolvedValueOnce({
|
|
22
|
+
StackResourceSummaries: [
|
|
23
|
+
{ LogicalResourceId: 'Resource1', PhysicalResourceId: 'res-1', ResourceType: 'AWS::EC2::VPC' },
|
|
24
|
+
{ LogicalResourceId: 'Resource2', PhysicalResourceId: 'res-2', ResourceType: 'AWS::EC2::Subnet' }
|
|
25
|
+
],
|
|
26
|
+
NextToken: 'token-page-2' // More pages available
|
|
27
|
+
})
|
|
28
|
+
.mockResolvedValueOnce({
|
|
29
|
+
StackResourceSummaries: [
|
|
30
|
+
{ LogicalResourceId: 'VPCEndpointS3', PhysicalResourceId: 'vpce-s3', ResourceType: 'AWS::EC2::VPCEndpoint' },
|
|
31
|
+
{ LogicalResourceId: 'VPCEndpointDynamoDB', PhysicalResourceId: 'vpce-ddb', ResourceType: 'AWS::EC2::VPCEndpoint' }
|
|
32
|
+
],
|
|
33
|
+
NextToken: null // Last page
|
|
34
|
+
})
|
|
35
|
+
};
|
|
36
|
+
|
|
37
|
+
const provider = new AWSProviderAdapter('us-east-1');
|
|
38
|
+
provider.getCloudFormationClient = jest.fn().mockReturnValue(mockCfClient);
|
|
39
|
+
|
|
40
|
+
const resources = await provider.listStackResources('test-stack');
|
|
41
|
+
|
|
42
|
+
// Should have ALL resources from ALL pages
|
|
43
|
+
expect(resources).toHaveLength(4);
|
|
44
|
+
expect(resources.map(r => r.LogicalResourceId)).toEqual([
|
|
45
|
+
'Resource1',
|
|
46
|
+
'Resource2',
|
|
47
|
+
'VPCEndpointS3',
|
|
48
|
+
'VPCEndpointDynamoDB'
|
|
49
|
+
]);
|
|
50
|
+
|
|
51
|
+
// Should have called CloudFormation twice (once for each page)
|
|
52
|
+
expect(mockCfClient.send).toHaveBeenCalledTimes(2);
|
|
53
|
+
});
|
|
54
|
+
});
|
|
55
|
+
|
|
17
56
|
let provider;
|
|
18
57
|
|
|
19
58
|
beforeEach(() => {
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@friggframework/devtools",
|
|
3
3
|
"prettier": "@friggframework/prettier-config",
|
|
4
|
-
"version": "2.0.0--canary.490.
|
|
4
|
+
"version": "2.0.0--canary.490.97a854f.0",
|
|
5
5
|
"bin": {
|
|
6
6
|
"frigg": "./frigg-cli/index.js"
|
|
7
7
|
},
|
|
@@ -16,9 +16,9 @@
|
|
|
16
16
|
"@babel/eslint-parser": "^7.18.9",
|
|
17
17
|
"@babel/parser": "^7.25.3",
|
|
18
18
|
"@babel/traverse": "^7.25.3",
|
|
19
|
-
"@friggframework/core": "2.0.0--canary.490.
|
|
20
|
-
"@friggframework/schemas": "2.0.0--canary.490.
|
|
21
|
-
"@friggframework/test": "2.0.0--canary.490.
|
|
19
|
+
"@friggframework/core": "2.0.0--canary.490.97a854f.0",
|
|
20
|
+
"@friggframework/schemas": "2.0.0--canary.490.97a854f.0",
|
|
21
|
+
"@friggframework/test": "2.0.0--canary.490.97a854f.0",
|
|
22
22
|
"@hapi/boom": "^10.0.1",
|
|
23
23
|
"@inquirer/prompts": "^5.3.8",
|
|
24
24
|
"axios": "^1.7.2",
|
|
@@ -46,8 +46,8 @@
|
|
|
46
46
|
"validate-npm-package-name": "^5.0.0"
|
|
47
47
|
},
|
|
48
48
|
"devDependencies": {
|
|
49
|
-
"@friggframework/eslint-config": "2.0.0--canary.490.
|
|
50
|
-
"@friggframework/prettier-config": "2.0.0--canary.490.
|
|
49
|
+
"@friggframework/eslint-config": "2.0.0--canary.490.97a854f.0",
|
|
50
|
+
"@friggframework/prettier-config": "2.0.0--canary.490.97a854f.0",
|
|
51
51
|
"aws-sdk-client-mock": "^4.1.0",
|
|
52
52
|
"aws-sdk-client-mock-jest": "^4.1.0",
|
|
53
53
|
"jest": "^30.1.3",
|
|
@@ -79,5 +79,5 @@
|
|
|
79
79
|
"publishConfig": {
|
|
80
80
|
"access": "public"
|
|
81
81
|
},
|
|
82
|
-
"gitHead": "
|
|
82
|
+
"gitHead": "97a854f72031827c40d59dc5e28c2282f433c8ee"
|
|
83
83
|
}
|