@friggframework/devtools 2.0.0--canary.490.b58dfbe.0 → 2.0.0--canary.490.1c28319.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.
|
@@ -159,6 +159,9 @@ class VpcBuilder extends InfrastructureBuilder {
|
|
|
159
159
|
} else if (logicalId === 'FriggNATGateway') {
|
|
160
160
|
resourceType = 'AWS::EC2::NatGateway';
|
|
161
161
|
physicalId = flatDiscovery.existingNatGatewayId;
|
|
162
|
+
} else if (logicalId === 'FriggLambdaRouteTable') {
|
|
163
|
+
resourceType = 'AWS::EC2::RouteTable';
|
|
164
|
+
physicalId = flatDiscovery.routeTableId;
|
|
162
165
|
} else if (logicalId === 'FriggS3VPCEndpoint') {
|
|
163
166
|
resourceType = 'AWS::EC2::VPCEndpoint';
|
|
164
167
|
physicalId = flatDiscovery.s3VpcEndpointId;
|
|
@@ -1258,5 +1258,145 @@ describe('VpcBuilder', () => {
|
|
|
1258
1258
|
expect(result.outputs.PrivateSubnet2Id).toBeDefined();
|
|
1259
1259
|
});
|
|
1260
1260
|
});
|
|
1261
|
+
|
|
1262
|
+
describe('convertFlatDiscoveryToStructured - CloudFormation query results', () => {
|
|
1263
|
+
it('should add VPC from CloudFormation query to external array', () => {
|
|
1264
|
+
const flatDiscovery = {
|
|
1265
|
+
fromCloudFormationStack: true,
|
|
1266
|
+
stackName: 'test-stack',
|
|
1267
|
+
existingLogicalIds: ['FriggLambdaRouteTable', 'FriggLambdaSecurityGroup'],
|
|
1268
|
+
// VPC ID was extracted from security group query (NOT a stack resource)
|
|
1269
|
+
defaultVpcId: 'vpc-extracted-from-sg',
|
|
1270
|
+
lambdaSecurityGroupId: 'sg-123',
|
|
1271
|
+
routeTableId: 'rtb-123'
|
|
1272
|
+
};
|
|
1273
|
+
|
|
1274
|
+
const result = vpcBuilder.convertFlatDiscoveryToStructured(flatDiscovery);
|
|
1275
|
+
|
|
1276
|
+
// VPC should be in external array (discovered via query, not in stack)
|
|
1277
|
+
const vpcExternal = result.external.find(r => r.resourceType === 'AWS::EC2::VPC');
|
|
1278
|
+
expect(vpcExternal).toBeDefined();
|
|
1279
|
+
expect(vpcExternal.physicalId).toBe('vpc-extracted-from-sg');
|
|
1280
|
+
expect(vpcExternal.source).toBe('cloudformation-query');
|
|
1281
|
+
|
|
1282
|
+
// Security group SHOULD be in stackManaged (is in stack)
|
|
1283
|
+
const sgStack = result.stackManaged.find(r => r.logicalId === 'FriggLambdaSecurityGroup');
|
|
1284
|
+
expect(sgStack).toBeDefined();
|
|
1285
|
+
expect(sgStack.physicalId).toBe('sg-123');
|
|
1286
|
+
});
|
|
1287
|
+
|
|
1288
|
+
it('should add subnets from route table associations to external array', () => {
|
|
1289
|
+
const flatDiscovery = {
|
|
1290
|
+
fromCloudFormationStack: true,
|
|
1291
|
+
stackName: 'test-stack',
|
|
1292
|
+
existingLogicalIds: ['FriggLambdaRouteTable'],
|
|
1293
|
+
routeTableId: 'rtb-123',
|
|
1294
|
+
// Subnets extracted from route table associations (NOT stack resources)
|
|
1295
|
+
privateSubnetId1: 'subnet-1',
|
|
1296
|
+
privateSubnetId2: 'subnet-2'
|
|
1297
|
+
};
|
|
1298
|
+
|
|
1299
|
+
const result = vpcBuilder.convertFlatDiscoveryToStructured(flatDiscovery);
|
|
1300
|
+
|
|
1301
|
+
// Subnets should be in external array
|
|
1302
|
+
const subnet1 = result.external.find(r => r.physicalId === 'subnet-1');
|
|
1303
|
+
const subnet2 = result.external.find(r => r.physicalId === 'subnet-2');
|
|
1304
|
+
|
|
1305
|
+
expect(subnet1).toBeDefined();
|
|
1306
|
+
expect(subnet1.resourceType).toBe('AWS::EC2::Subnet');
|
|
1307
|
+
expect(subnet1.source).toBe('cloudformation-query');
|
|
1308
|
+
|
|
1309
|
+
expect(subnet2).toBeDefined();
|
|
1310
|
+
expect(subnet2.resourceType).toBe('AWS::EC2::Subnet');
|
|
1311
|
+
expect(subnet2.source).toBe('cloudformation-query');
|
|
1312
|
+
});
|
|
1313
|
+
|
|
1314
|
+
it('should add NAT Gateway from route table queries to external array', () => {
|
|
1315
|
+
const flatDiscovery = {
|
|
1316
|
+
fromCloudFormationStack: true,
|
|
1317
|
+
stackName: 'test-stack',
|
|
1318
|
+
existingLogicalIds: ['FriggLambdaRouteTable', 'FriggPrivateRoute'],
|
|
1319
|
+
routeTableId: 'rtb-123',
|
|
1320
|
+
// NAT Gateway extracted from route table routes (NOT a stack resource)
|
|
1321
|
+
existingNatGatewayId: 'nat-extracted'
|
|
1322
|
+
};
|
|
1323
|
+
|
|
1324
|
+
const result = vpcBuilder.convertFlatDiscoveryToStructured(flatDiscovery);
|
|
1325
|
+
|
|
1326
|
+
// NAT should be in external array
|
|
1327
|
+
const natExternal = result.external.find(r => r.resourceType === 'AWS::EC2::NatGateway');
|
|
1328
|
+
expect(natExternal).toBeDefined();
|
|
1329
|
+
expect(natExternal.physicalId).toBe('nat-extracted');
|
|
1330
|
+
expect(natExternal.source).toBe('cloudformation-query');
|
|
1331
|
+
});
|
|
1332
|
+
|
|
1333
|
+
it('should NOT add resources to external if they are in stack', () => {
|
|
1334
|
+
const flatDiscovery = {
|
|
1335
|
+
fromCloudFormationStack: true,
|
|
1336
|
+
stackName: 'test-stack',
|
|
1337
|
+
existingLogicalIds: ['FriggVPC', 'FriggPrivateSubnet1'],
|
|
1338
|
+
// These ARE in the stack
|
|
1339
|
+
defaultVpcId: 'vpc-in-stack',
|
|
1340
|
+
privateSubnetId1: 'subnet-in-stack'
|
|
1341
|
+
};
|
|
1342
|
+
|
|
1343
|
+
const result = vpcBuilder.convertFlatDiscoveryToStructured(flatDiscovery);
|
|
1344
|
+
|
|
1345
|
+
// Should be in stackManaged, NOT external
|
|
1346
|
+
expect(result.stackManaged.some(r => r.logicalId === 'FriggVPC')).toBe(true);
|
|
1347
|
+
expect(result.stackManaged.some(r => r.logicalId === 'FriggPrivateSubnet1')).toBe(true);
|
|
1348
|
+
|
|
1349
|
+
// Should NOT be in external
|
|
1350
|
+
expect(result.external.some(r => r.physicalId === 'vpc-in-stack')).toBe(false);
|
|
1351
|
+
expect(result.external.some(r => r.physicalId === 'subnet-in-stack')).toBe(false);
|
|
1352
|
+
});
|
|
1353
|
+
|
|
1354
|
+
it('should handle Frontify pattern: stack resources + queried external references', () => {
|
|
1355
|
+
const flatDiscovery = {
|
|
1356
|
+
fromCloudFormationStack: true,
|
|
1357
|
+
stackName: 'create-frigg-app-production',
|
|
1358
|
+
existingLogicalIds: [
|
|
1359
|
+
'FriggLambdaSecurityGroup',
|
|
1360
|
+
'FriggLambdaRouteTable',
|
|
1361
|
+
'FriggPrivateRoute',
|
|
1362
|
+
'FriggPrivateSubnet1RouteTableAssociation',
|
|
1363
|
+
'FriggPrivateSubnet2RouteTableAssociation',
|
|
1364
|
+
'FriggS3VPCEndpoint',
|
|
1365
|
+
'FriggDynamoDBVPCEndpoint',
|
|
1366
|
+
'FriggKMSVPCEndpoint'
|
|
1367
|
+
],
|
|
1368
|
+
// Stack resources
|
|
1369
|
+
lambdaSecurityGroupId: 'sg-01002240c6a446202',
|
|
1370
|
+
routeTableId: 'rtb-08af43bbf0775602d',
|
|
1371
|
+
s3VpcEndpointId: 'vpce-s3',
|
|
1372
|
+
// External resources (discovered via queries)
|
|
1373
|
+
defaultVpcId: 'vpc-0cd17c0e06cb28b28',
|
|
1374
|
+
privateSubnetId1: 'subnet-034f6562dbbc16348',
|
|
1375
|
+
privateSubnetId2: 'subnet-0b8be2b82aeb5cdec',
|
|
1376
|
+
existingNatGatewayId: 'nat-022660c36a47e2d79'
|
|
1377
|
+
};
|
|
1378
|
+
|
|
1379
|
+
const result = vpcBuilder.convertFlatDiscoveryToStructured(flatDiscovery);
|
|
1380
|
+
|
|
1381
|
+
// Stack resources should be in stackManaged
|
|
1382
|
+
expect(result.stackManaged).toEqual(
|
|
1383
|
+
expect.arrayContaining([
|
|
1384
|
+
expect.objectContaining({ logicalId: 'FriggLambdaSecurityGroup', physicalId: 'sg-01002240c6a446202' }),
|
|
1385
|
+
expect.objectContaining({ logicalId: 'FriggLambdaRouteTable', physicalId: 'rtb-08af43bbf0775602d' }),
|
|
1386
|
+
expect.objectContaining({ logicalId: 'FriggS3VPCEndpoint' })
|
|
1387
|
+
])
|
|
1388
|
+
);
|
|
1389
|
+
|
|
1390
|
+
// External resources should be in external array
|
|
1391
|
+
expect(result.external).toEqual(
|
|
1392
|
+
expect.arrayContaining([
|
|
1393
|
+
expect.objectContaining({ physicalId: 'vpc-0cd17c0e06cb28b28', resourceType: 'AWS::EC2::VPC', source: 'cloudformation-query' }),
|
|
1394
|
+
expect.objectContaining({ physicalId: 'subnet-034f6562dbbc16348', resourceType: 'AWS::EC2::Subnet', source: 'cloudformation-query' }),
|
|
1395
|
+
expect.objectContaining({ physicalId: 'subnet-0b8be2b82aeb5cdec', resourceType: 'AWS::EC2::Subnet', source: 'cloudformation-query' }),
|
|
1396
|
+
expect.objectContaining({ physicalId: 'nat-022660c36a47e2d79', resourceType: 'AWS::EC2::NatGateway', source: 'cloudformation-query' })
|
|
1397
|
+
])
|
|
1398
|
+
);
|
|
1399
|
+
});
|
|
1400
|
+
});
|
|
1261
1401
|
});
|
|
1262
1402
|
|
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.1c28319.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.1c28319.0",
|
|
20
|
+
"@friggframework/schemas": "2.0.0--canary.490.1c28319.0",
|
|
21
|
+
"@friggframework/test": "2.0.0--canary.490.1c28319.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.1c28319.0",
|
|
50
|
+
"@friggframework/prettier-config": "2.0.0--canary.490.1c28319.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": "1c28319a3d8c7c5df38b05d62d637b2579fa573f"
|
|
83
83
|
}
|