@friggframework/devtools 2.0.0--canary.701.32f702a.0 → 2.0.0--canary.662.6d3931c.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.
- package/README.md +0 -1
- package/frigg-cli/README.md +31 -123
- package/frigg-cli/__tests__/unit/commands/build.test.js +0 -3
- package/frigg-cli/__tests__/unit/commands/deploy.test.js +24 -33
- package/frigg-cli/__tests__/unit/commands/doctor.test.js +6 -10
- package/frigg-cli/__tests__/unit/commands/generate-iam.test.js +0 -18
- package/frigg-cli/__tests__/unit/commands/install.test.js +341 -601
- package/frigg-cli/__tests__/unit/commands/ui.test.js +30 -31
- package/frigg-cli/__tests__/unit/dependencies.test.js +2 -6
- package/frigg-cli/build-command/index.js +0 -6
- package/frigg-cli/deploy-command/index.js +0 -6
- package/frigg-cli/generate-command/index.js +0 -1
- package/frigg-cli/generate-iam-command.js +0 -1
- package/frigg-cli/index.js +5 -28
- package/frigg-cli/index.test.js +158 -0
- package/frigg-cli/init-command/backend-first-handler.js +551 -395
- package/frigg-cli/init-command/index.js +35 -82
- package/frigg-cli/install-command/commit-changes.js +8 -40
- package/frigg-cli/install-command/environment-variables.js +0 -15
- package/frigg-cli/install-command/index.js +21 -96
- package/frigg-cli/install-command/install-package.js +4 -77
- package/frigg-cli/install-command/integration-file.js +11 -20
- package/frigg-cli/install-command/template.js +75 -102
- package/frigg-cli/install-command/validate-package.js +4 -36
- package/frigg-cli/package.json +1 -1
- package/frigg-cli/start-command/index.js +0 -4
- package/frigg-cli/start-command/start-command.test.js +0 -3
- package/frigg-cli/test/init-command.test.js +2 -9
- package/infrastructure/__tests__/postgres-config.test.js +835 -241
- package/infrastructure/__tests__/template-generation.test.js +8 -36
- package/infrastructure/create-frigg-infrastructure.js +1 -4
- package/infrastructure/docs/POSTGRES-CONFIGURATION.md +98 -80
- package/infrastructure/domains/admin-scripts/admin-script-builder.js +2 -6
- package/infrastructure/domains/admin-scripts/admin-script-builder.test.js +0 -30
- package/infrastructure/domains/database/aurora-builder.js +2 -13
- package/infrastructure/domains/database/aurora-builder.test.js +0 -22
- package/infrastructure/domains/health/application/use-cases/__tests__/mismatch-analyzer-method-name.test.js +8 -12
- package/infrastructure/domains/health/application/use-cases/__tests__/repair-via-import-use-case.test.js +7 -19
- package/infrastructure/domains/health/application/use-cases/run-health-check-use-case.test.js +8 -12
- package/infrastructure/domains/health/domain/services/__tests__/import-progress-monitor.test.js +18 -17
- package/infrastructure/domains/health/domain/services/__tests__/update-progress-monitor.test.js +2 -12
- package/infrastructure/domains/health/infrastructure/adapters/__tests__/orphan-detection-relationship-analysis.test.js +1 -8
- package/infrastructure/domains/health/infrastructure/adapters/aws-property-reconciler.test.js +2 -4
- package/infrastructure/domains/health/infrastructure/adapters/aws-resource-detector.test.js +0 -10
- package/infrastructure/domains/networking/vpc-builder.js +8 -18
- package/infrastructure/domains/networking/vpc-builder.test.js +12 -26
- package/infrastructure/domains/security/iam-generator.js +5 -112
- package/infrastructure/domains/security/iam-generator.test.js +0 -94
- package/infrastructure/domains/shared/cloudformation-discovery.test.js +6 -36
- package/infrastructure/domains/shared/utilities/base-definition-factory.js +2 -26
- package/infrastructure/domains/shared/utilities/base-definition-factory.test.js +1 -34
- package/infrastructure/infrastructure-composer.test.js +794 -268
- package/infrastructure/integration.test.js +381 -0
- package/infrastructure/scripts/build-prisma-layer.test.js +7 -28
- package/infrastructure/scripts/build-time-discovery.test.js +3 -18
- package/package.json +8 -10
- package/frigg-cli/__tests__/unit/commands/init.test.js +0 -688
- package/frigg-cli/__tests__/unit/commands/validate-wiring.test.js +0 -92
- package/frigg-cli/init-command/deployment-modes.js +0 -7
- package/frigg-cli/init-command/safe-path.js +0 -58
- package/frigg-cli/init-command/scaffold-dependencies.js +0 -202
- package/frigg-cli/install-command/app-definition.js +0 -174
- package/frigg-cli/install-command/resolve-module.js +0 -69
- package/frigg-cli/templates/backend/README.md +0 -267
- package/frigg-cli/templates/backend/env.example +0 -20
- package/frigg-cli/templates/backend/gitignore +0 -10
- package/frigg-cli/templates/backend/index.js +0 -114
- package/frigg-cli/templates/backend/infrastructure.js +0 -20
- package/frigg-cli/validate-command/__tests__/init-validation.test.js +0 -63
- package/frigg-cli/validate-command/__tests__/integrations-checks.test.js +0 -133
- package/frigg-cli/validate-command/__tests__/validate-app-definition.test.js +0 -443
- package/frigg-cli/validate-command/__tests__/validate-command.test.js +0 -262
- package/frigg-cli/validate-command/__tests__/validate-module-command.test.js +0 -119
- package/frigg-cli/validate-command/checks/config.js +0 -504
- package/frigg-cli/validate-command/checks/integrations.js +0 -274
- package/frigg-cli/validate-command/fixtures/bad-module/index.js +0 -18
- package/frigg-cli/validate-command/fixtures/fathom-module/definition.js +0 -76
- package/frigg-cli/validate-command/fixtures/fathom-module/index.js +0 -6
- package/frigg-cli/validate-command/format-report.js +0 -60
- package/frigg-cli/validate-command/index.js +0 -151
- package/frigg-cli/validate-command/load-app-definition.js +0 -105
- package/frigg-cli/validate-command/load-module-definition.js +0 -64
- package/frigg-cli/validate-command/schema-issues.js +0 -154
- package/frigg-cli/validate-command/validate-app-definition.js +0 -60
- package/frigg-cli/validate-command/validate-module-definition.js +0 -46
- package/infrastructure/__tests__/management-api-gateway-routes.test.js +0 -281
- package/infrastructure/__tests__/scaffold-default-infrastructure.test.js +0 -148
- package/infrastructure/app-definition-schema-contract.test.js +0 -629
- package/infrastructure/create-frigg-infrastructure.test.js +0 -51
|
@@ -548,11 +548,7 @@ describe('RepairViaImportUseCase - importWithLogicalIdMapping', () => {
|
|
|
548
548
|
expect(result.unmappedCount).toBe(2);
|
|
549
549
|
});
|
|
550
550
|
|
|
551
|
-
it('should
|
|
552
|
-
// Since 6a0bba7b, importWithLogicalIdMapping() de-duplicates candidates
|
|
553
|
-
// per logical ID and only warns about the candidates it dropped
|
|
554
|
-
// (_checkForMultipleResources(duplicates)). Distinct logical IDs are not
|
|
555
|
-
// duplicates and produce no warning.
|
|
551
|
+
it('should generate warnings for multiple resources of same type', async () => {
|
|
556
552
|
// Arrange
|
|
557
553
|
const stackIdentifier = {
|
|
558
554
|
stackName: 'acme-integrations-dev',
|
|
@@ -592,7 +588,7 @@ describe('RepairViaImportUseCase - importWithLogicalIdMapping', () => {
|
|
|
592
588
|
const buildTemplate = { resources: {} };
|
|
593
589
|
const deployedTemplate = { resources: {} };
|
|
594
590
|
|
|
595
|
-
// Three VPCs
|
|
591
|
+
// Three VPCs mapped
|
|
596
592
|
const mappings = [
|
|
597
593
|
{
|
|
598
594
|
logicalId: 'FriggVPC',
|
|
@@ -602,14 +598,14 @@ describe('RepairViaImportUseCase - importWithLogicalIdMapping', () => {
|
|
|
602
598
|
confidence: 'high',
|
|
603
599
|
},
|
|
604
600
|
{
|
|
605
|
-
logicalId: '
|
|
601
|
+
logicalId: 'FriggVPC2',
|
|
606
602
|
physicalId: 'vpc-456',
|
|
607
603
|
resourceType: 'AWS::EC2::VPC',
|
|
608
604
|
matchMethod: 'contained-resources',
|
|
609
605
|
confidence: 'high',
|
|
610
606
|
},
|
|
611
607
|
{
|
|
612
|
-
logicalId: '
|
|
608
|
+
logicalId: 'FriggVPC3',
|
|
613
609
|
physicalId: 'vpc-789',
|
|
614
610
|
resourceType: 'AWS::EC2::VPC',
|
|
615
611
|
matchMethod: 'tag',
|
|
@@ -632,21 +628,13 @@ describe('RepairViaImportUseCase - importWithLogicalIdMapping', () => {
|
|
|
632
628
|
});
|
|
633
629
|
|
|
634
630
|
// Assert
|
|
635
|
-
// Nothing is referenced by the deployed template, so the first candidate
|
|
636
|
-
// is kept and the other two are reported as duplicates.
|
|
637
631
|
expect(result.success).toBe(true);
|
|
638
|
-
expect(result.mappedCount).toBe(1);
|
|
639
|
-
expect(result.mappings[0].physicalId).toBe('vpc-123');
|
|
640
|
-
expect(result.duplicatesRemoved).toBe(2);
|
|
641
632
|
expect(result.warnings).toHaveLength(1);
|
|
642
633
|
expect(result.warnings[0].type).toBe('MULTIPLE_RESOURCES');
|
|
643
634
|
expect(result.warnings[0].resourceType).toBe('AWS::EC2::VPC');
|
|
644
|
-
expect(result.warnings[0].count).toBe(
|
|
645
|
-
expect(result.warnings[0].message).toContain('Multiple VPCs detected (
|
|
646
|
-
expect(result.warnings[0].resources.
|
|
647
|
-
'vpc-456',
|
|
648
|
-
'vpc-789',
|
|
649
|
-
]);
|
|
635
|
+
expect(result.warnings[0].count).toBe(3);
|
|
636
|
+
expect(result.warnings[0].message).toContain('Multiple VPCs detected (3)');
|
|
637
|
+
expect(result.warnings[0].resources).toHaveLength(3);
|
|
650
638
|
});
|
|
651
639
|
|
|
652
640
|
it('should include build and deployed template paths in result', async () => {
|
package/infrastructure/domains/health/application/use-cases/run-health-check-use-case.test.js
CHANGED
|
@@ -133,12 +133,10 @@ describe('RunHealthCheckUseCase', () => {
|
|
|
133
133
|
driftStatus: 'MODIFIED',
|
|
134
134
|
propertyDifferences: [
|
|
135
135
|
{
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
ActualValue: 'false',
|
|
141
|
-
DifferenceType: 'NOT_EQUAL',
|
|
136
|
+
propertyPath: 'Properties.EnableDnsSupport',
|
|
137
|
+
expectedValue: true,
|
|
138
|
+
actualValue: false,
|
|
139
|
+
differenceType: 'NOT_EQUAL',
|
|
142
140
|
},
|
|
143
141
|
],
|
|
144
142
|
});
|
|
@@ -310,12 +308,10 @@ describe('RunHealthCheckUseCase', () => {
|
|
|
310
308
|
driftStatus: 'MODIFIED',
|
|
311
309
|
propertyDifferences: [
|
|
312
310
|
{
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
ActualValue: 'false',
|
|
318
|
-
DifferenceType: 'NOT_EQUAL',
|
|
311
|
+
propertyPath: 'Properties.EnableDnsSupport',
|
|
312
|
+
expectedValue: true,
|
|
313
|
+
actualValue: false,
|
|
314
|
+
differenceType: 'NOT_EQUAL',
|
|
319
315
|
},
|
|
320
316
|
],
|
|
321
317
|
});
|
package/infrastructure/domains/health/domain/services/__tests__/import-progress-monitor.test.js
CHANGED
|
@@ -412,23 +412,24 @@ describe('ImportProgressMonitor', () => {
|
|
|
412
412
|
|
|
413
413
|
mockCloudFormationRepository.getStackStatus.mockResolvedValue('IMPORT_IN_PROGRESS');
|
|
414
414
|
|
|
415
|
-
// Act & Assert -
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
415
|
+
// Act & Assert - wrap in expect().rejects to properly handle async rejection
|
|
416
|
+
await expect(
|
|
417
|
+
(async () => {
|
|
418
|
+
const resultPromise = monitor.monitorImport({
|
|
419
|
+
stackIdentifier,
|
|
420
|
+
resourceLogicalIds,
|
|
421
|
+
onProgress,
|
|
422
|
+
});
|
|
423
|
+
|
|
424
|
+
// Advance timers beyond 5 minutes (300,000ms) in chunks
|
|
425
|
+
// Simulate 151 polls (302 seconds = 302,000ms) to exceed timeout
|
|
426
|
+
for (let i = 0; i < 151; i++) {
|
|
427
|
+
await jest.advanceTimersByTimeAsync(2000);
|
|
428
|
+
}
|
|
429
|
+
|
|
430
|
+
return await resultPromise;
|
|
431
|
+
})()
|
|
432
|
+
).rejects.toThrow('Import operation timed out');
|
|
432
433
|
});
|
|
433
434
|
|
|
434
435
|
it('should filter events by resourceLogicalIds', async () => {
|
package/infrastructure/domains/health/domain/services/__tests__/update-progress-monitor.test.js
CHANGED
|
@@ -302,14 +302,9 @@ describe('UpdateProgressMonitor', () => {
|
|
|
302
302
|
onProgress: onProgressCallback,
|
|
303
303
|
});
|
|
304
304
|
|
|
305
|
-
// Attach the rejection handler before advancing the fake clock: the
|
|
306
|
-
// monitor rejects while the timers run, and an unobserved rejection
|
|
307
|
-
// fails the test under Jest 30.
|
|
308
|
-
const assertion = expect(monitorPromise).rejects.toThrow('Update operation failed and rolled back');
|
|
309
|
-
|
|
310
305
|
await jest.advanceTimersByTimeAsync(2000);
|
|
311
306
|
|
|
312
|
-
await
|
|
307
|
+
await expect(monitorPromise).rejects.toThrow('Update operation failed and rolled back');
|
|
313
308
|
});
|
|
314
309
|
});
|
|
315
310
|
|
|
@@ -339,15 +334,10 @@ describe('UpdateProgressMonitor', () => {
|
|
|
339
334
|
onProgress: onProgressCallback,
|
|
340
335
|
});
|
|
341
336
|
|
|
342
|
-
// Attach the rejection handler before advancing the fake clock: the
|
|
343
|
-
// monitor rejects while the timers run, and an unobserved rejection
|
|
344
|
-
// fails the test under Jest 30.
|
|
345
|
-
const assertion = expect(monitorPromise).rejects.toThrow('Update operation timed out');
|
|
346
|
-
|
|
347
337
|
// Advance past 5 minute timeout (300000ms)
|
|
348
338
|
await jest.advanceTimersByTimeAsync(300000 + 2000);
|
|
349
339
|
|
|
350
|
-
await
|
|
340
|
+
await expect(monitorPromise).rejects.toThrow('Update operation timed out');
|
|
351
341
|
});
|
|
352
342
|
});
|
|
353
343
|
|
|
@@ -82,14 +82,7 @@ jest.mock('@aws-sdk/client-kms', () => ({
|
|
|
82
82
|
ListAliasesCommand: jest.fn(),
|
|
83
83
|
}));
|
|
84
84
|
|
|
85
|
-
|
|
86
|
-
// AWSResourceDetector has no findOrphanedResourcesWithRelationships() or
|
|
87
|
-
// _extractReferencedResourceIds(); the design is in
|
|
88
|
-
// domains/health/docs/ORPHAN-DETECTION-ANALYSIS.md. (A template-based variant of
|
|
89
|
-
// the reference analysis lives in RepairViaImportUseCase._extractReferencedIdsFromTemplate.)
|
|
90
|
-
// Un-skip when the relationship analysis is implemented.
|
|
91
|
-
// Tracked in https://github.com/friggframework/frigg/issues/709
|
|
92
|
-
describe.skip('Orphan Detection with Relationship Analysis (TDD)', () => {
|
|
85
|
+
describe('Orphan Detection with Relationship Analysis (TDD)', () => {
|
|
93
86
|
let detector;
|
|
94
87
|
let mockEC2Send;
|
|
95
88
|
let mockRDSSend;
|
package/infrastructure/domains/health/infrastructure/adapters/aws-property-reconciler.test.js
CHANGED
|
@@ -447,9 +447,7 @@ describe('AWSPropertyReconciler', () => {
|
|
|
447
447
|
);
|
|
448
448
|
|
|
449
449
|
expect(strategy.supportsTemplateUpdate).toBe(true);
|
|
450
|
-
|
|
451
|
-
// (UpdateFunctionConfiguration) since 6a0bba7b; template is still preferred.
|
|
452
|
-
expect(strategy.supportsResourceUpdate).toBe(true);
|
|
450
|
+
expect(strategy.supportsResourceUpdate).toBe(false);
|
|
453
451
|
expect(strategy.recommendedMode).toBe('template');
|
|
454
452
|
expect(strategy.limitations).toContain(
|
|
455
453
|
'VpcConfig changes may take several minutes to propagate'
|
|
@@ -661,7 +659,7 @@ describe('AWSPropertyReconciler', () => {
|
|
|
661
659
|
|
|
662
660
|
expect(strategy).toEqual({
|
|
663
661
|
supportsTemplateUpdate: true,
|
|
664
|
-
supportsResourceUpdate:
|
|
662
|
+
supportsResourceUpdate: false,
|
|
665
663
|
recommendedMode: 'template',
|
|
666
664
|
limitations: expect.arrayContaining([
|
|
667
665
|
'VpcConfig changes may take several minutes to propagate',
|
|
@@ -441,16 +441,6 @@ describe('AWSResourceDetector', () => {
|
|
|
441
441
|
describe('findOrphanedResources', () => {
|
|
442
442
|
const StackIdentifier = require('../../domain/value-objects/stack-identifier');
|
|
443
443
|
|
|
444
|
-
beforeEach(() => {
|
|
445
|
-
// findOrphanedResources() scans every supported resource type
|
|
446
|
-
// (EC2, RDS and KMS), not just the types in the stack, so every
|
|
447
|
-
// client needs an (empty) response; each test overrides the one
|
|
448
|
-
// service it is about.
|
|
449
|
-
mockEC2Send.mockResolvedValue({});
|
|
450
|
-
mockRDSSend.mockResolvedValue({});
|
|
451
|
-
mockKMSSend.mockResolvedValue({});
|
|
452
|
-
});
|
|
453
|
-
|
|
454
444
|
it('should find orphaned RDS DBCluster with frigg:stack tag', async () => {
|
|
455
445
|
const stackIdentifier = new StackIdentifier({
|
|
456
446
|
stackName: 'my-app-prod',
|
|
@@ -439,14 +439,8 @@ class VpcBuilder extends InfrastructureBuilder {
|
|
|
439
439
|
translated.vpc.ownership.subnets = 'external';
|
|
440
440
|
}
|
|
441
441
|
|
|
442
|
-
// Legacy options that warnIgnoredOptions() reports as ignored under
|
|
443
|
-
// managementMode='managed' must really be ignored: applying them would
|
|
444
|
-
// undo the ownership chosen above (e.g. vpc.management='discover' turning
|
|
445
|
-
// managed+isolated's ownership.vpc='stack' back into 'auto').
|
|
446
|
-
const honorLegacyModes = globalMode !== 'managed';
|
|
447
|
-
|
|
448
442
|
// Handle legacy vpc.management modes
|
|
449
|
-
const vpcManagement =
|
|
443
|
+
const vpcManagement = appDefinition.vpc?.management;
|
|
450
444
|
if (vpcManagement === 'create-new') {
|
|
451
445
|
translated.vpc.ownership.vpc = 'stack';
|
|
452
446
|
translated.vpc.ownership.securityGroup = 'stack';
|
|
@@ -472,7 +466,7 @@ class VpcBuilder extends InfrastructureBuilder {
|
|
|
472
466
|
}
|
|
473
467
|
|
|
474
468
|
// Handle legacy shareAcrossStages
|
|
475
|
-
if (
|
|
469
|
+
if (appDefinition.vpc?.shareAcrossStages !== undefined) {
|
|
476
470
|
if (appDefinition.vpc.shareAcrossStages) {
|
|
477
471
|
// Shared VPC - discover and reuse
|
|
478
472
|
translated.vpc.ownership.vpc = 'auto';
|
|
@@ -487,7 +481,7 @@ class VpcBuilder extends InfrastructureBuilder {
|
|
|
487
481
|
}
|
|
488
482
|
|
|
489
483
|
// Handle legacy NAT Gateway management
|
|
490
|
-
if (
|
|
484
|
+
if (appDefinition.vpc?.natGateway?.management === 'createAndManage') {
|
|
491
485
|
// Use 'auto' to allow discovering and reusing properly placed external NAT Gateways
|
|
492
486
|
// The resolver will check if there's a good external NAT Gateway and reuse it,
|
|
493
487
|
// or create a new one if needed (or if the existing one is misplaced)
|
|
@@ -499,10 +493,9 @@ class VpcBuilder extends InfrastructureBuilder {
|
|
|
499
493
|
}
|
|
500
494
|
|
|
501
495
|
// Handle legacy subnet management
|
|
502
|
-
|
|
503
|
-
if (subnetManagement === 'create') {
|
|
496
|
+
if (appDefinition.vpc?.subnets?.management === 'create') {
|
|
504
497
|
translated.vpc.ownership.subnets = 'stack';
|
|
505
|
-
} else if (
|
|
498
|
+
} else if (appDefinition.vpc?.subnets?.management === 'use-existing' && appDefinition.vpc.subnets.ids) {
|
|
506
499
|
translated.vpc.ownership.subnets = 'external';
|
|
507
500
|
translated.vpc.external.subnetIds = appDefinition.vpc.subnets.ids;
|
|
508
501
|
}
|
|
@@ -698,11 +691,8 @@ class VpcBuilder extends InfrastructureBuilder {
|
|
|
698
691
|
result.vpcConfig.securityGroupIds = [{ Ref: 'FriggLambdaSecurityGroup' }];
|
|
699
692
|
console.log(' ✅ Security Group added to template');
|
|
700
693
|
} else if (decision.ownership === ResourceOwnership.EXTERNAL) {
|
|
701
|
-
// Use external security group IDs
|
|
702
|
-
|
|
703
|
-
const sgIds = decision.physicalIds?.length
|
|
704
|
-
? decision.physicalIds
|
|
705
|
-
: Array.isArray(decision.physicalId) ? decision.physicalId : [decision.physicalId];
|
|
694
|
+
// Use external security group IDs
|
|
695
|
+
const sgIds = Array.isArray(decision.physicalId) ? decision.physicalId : [decision.physicalId];
|
|
706
696
|
result.vpcConfig.securityGroupIds = sgIds;
|
|
707
697
|
console.log(` ✓ Using external security group(s): ${sgIds.join(', ')}`);
|
|
708
698
|
}
|
|
@@ -1185,7 +1175,7 @@ class VpcBuilder extends InfrastructureBuilder {
|
|
|
1185
1175
|
const vpcId = result.vpcId;
|
|
1186
1176
|
|
|
1187
1177
|
// Determine logical IDs based on what exists in stack for backwards compatibility
|
|
1188
|
-
// CRITICAL:
|
|
1178
|
+
// CRITICAL: Frontify production uses OLD naming (VPCEndpointS3, not FriggS3VPCEndpoint)
|
|
1189
1179
|
const existingLogicalIds = discoveredResources?.existingLogicalIds || [];
|
|
1190
1180
|
|
|
1191
1181
|
|
|
@@ -293,10 +293,10 @@ describe('VpcBuilder', () => {
|
|
|
293
293
|
]);
|
|
294
294
|
expect(result.resources.FriggPrivateSubnet1).toBeDefined();
|
|
295
295
|
expect(result.resources.FriggPrivateSubnet2).toBeDefined();
|
|
296
|
-
// In discover mode
|
|
297
|
-
|
|
298
|
-
expect(result.
|
|
299
|
-
expect(result.resources.FriggLambdaSecurityGroup).
|
|
296
|
+
// In discover mode, we create FriggLambdaSecurityGroup in the discovered VPC
|
|
297
|
+
expect(result.vpcConfig.securityGroupIds).toEqual([{ Ref: 'FriggLambdaSecurityGroup' }]);
|
|
298
|
+
expect(result.resources.FriggLambdaSecurityGroup).toBeDefined();
|
|
299
|
+
expect(result.resources.FriggLambdaSecurityGroup.Properties.VpcId).toBe('vpc-discovered');
|
|
300
300
|
});
|
|
301
301
|
|
|
302
302
|
it('should allow sharing discovered subnets when explicitly configured', async () => {
|
|
@@ -330,8 +330,6 @@ describe('VpcBuilder', () => {
|
|
|
330
330
|
management: 'discover',
|
|
331
331
|
selfHeal: true,
|
|
332
332
|
},
|
|
333
|
-
// The DynamoDB gateway endpoint is opt-in since 37a354e8
|
|
334
|
-
database: { dynamodb: { enable: true } },
|
|
335
333
|
};
|
|
336
334
|
|
|
337
335
|
const discoveredResources = {
|
|
@@ -464,8 +462,6 @@ describe('VpcBuilder', () => {
|
|
|
464
462
|
const appDefinition = {
|
|
465
463
|
vpc: { enable: true },
|
|
466
464
|
encryption: { fieldLevelEncryptionMethod: 'kms' },
|
|
467
|
-
// The DynamoDB gateway endpoint is opt-in since 37a354e8
|
|
468
|
-
database: { dynamodb: { enable: true } },
|
|
469
465
|
};
|
|
470
466
|
|
|
471
467
|
// Structured discovery from CloudFormation
|
|
@@ -526,8 +522,6 @@ describe('VpcBuilder', () => {
|
|
|
526
522
|
const appDefinition = {
|
|
527
523
|
vpc: { enable: true, enableVPCEndpoints: true, selfHeal: true },
|
|
528
524
|
encryption: { fieldLevelEncryptionMethod: 'kms' },
|
|
529
|
-
// The DynamoDB gateway endpoint is opt-in since 37a354e8
|
|
530
|
-
database: { dynamodb: { enable: true } },
|
|
531
525
|
};
|
|
532
526
|
const discoveredResources = {
|
|
533
527
|
defaultVpcId: 'vpc-123',
|
|
@@ -810,12 +804,7 @@ describe('VpcBuilder', () => {
|
|
|
810
804
|
expect(result.resources.FriggPrivateSubnet2RouteTableAssociation.Properties.RouteTableId).toEqual({ Ref: 'FriggLambdaRouteTable' });
|
|
811
805
|
});
|
|
812
806
|
|
|
813
|
-
|
|
814
|
-
// to FriggPrivateSubnetNRouteTableAssociation is unresolved. Since 37a354e8
|
|
815
|
-
// the source always uses the new IDs; this test (same commit) expects the old
|
|
816
|
-
// ones. Moving could hit Resource.AlreadyAssociated on upgrade.
|
|
817
|
-
// Tracked in https://github.com/friggframework/frigg/issues/714
|
|
818
|
-
it.skip('should add UpdateReplacePolicy to force association recreation on updates', async () => {
|
|
807
|
+
it('should add UpdateReplacePolicy to force association recreation on updates', async () => {
|
|
819
808
|
const appDefinition = {
|
|
820
809
|
vpc: {
|
|
821
810
|
enable: true,
|
|
@@ -826,9 +815,7 @@ describe('VpcBuilder', () => {
|
|
|
826
815
|
};
|
|
827
816
|
|
|
828
817
|
const discoveredResources = {
|
|
829
|
-
|
|
830
|
-
// the resolver refuses to create one implicitly (37a354e8).
|
|
831
|
-
defaultVpcId: 'vpc-123',
|
|
818
|
+
vpcId: 'vpc-123',
|
|
832
819
|
privateSubnetId1: 'subnet-existing-1',
|
|
833
820
|
privateSubnetId2: 'subnet-existing-2',
|
|
834
821
|
natGatewayId: 'nat-existing',
|
|
@@ -1535,7 +1522,7 @@ describe('VpcBuilder', () => {
|
|
|
1535
1522
|
});
|
|
1536
1523
|
|
|
1537
1524
|
it('should use OLD logical IDs for backwards compatibility (FriggNATRoute, VPCEndpointS3 pattern)', async () => {
|
|
1538
|
-
// CRITICAL TEST:
|
|
1525
|
+
// CRITICAL TEST: Real Frontify production stack uses OLD naming convention
|
|
1539
1526
|
// Stack currently has: FriggNATRoute, VPCEndpointS3, VPCEndpointDynamoDB
|
|
1540
1527
|
// We MUST use these same logical IDs to avoid AlreadyExists errors
|
|
1541
1528
|
const appDefinition = {
|
|
@@ -1554,7 +1541,7 @@ describe('VpcBuilder', () => {
|
|
|
1554
1541
|
}
|
|
1555
1542
|
};
|
|
1556
1543
|
|
|
1557
|
-
// Discovery results matching
|
|
1544
|
+
// Discovery results matching ACTUAL Frontify production stack
|
|
1558
1545
|
const discoveredResources = {
|
|
1559
1546
|
fromCloudFormationStack: true,
|
|
1560
1547
|
stackName: 'create-frigg-app-production',
|
|
@@ -1602,9 +1589,10 @@ describe('VpcBuilder', () => {
|
|
|
1602
1589
|
expect(result.resources.FriggNATRoute.Type).toBe('AWS::EC2::Route');
|
|
1603
1590
|
expect(result.resources.FriggPrivateRoute).toBeUndefined(); // Should NOT create new ID
|
|
1604
1591
|
|
|
1605
|
-
|
|
1606
|
-
|
|
1607
|
-
|
|
1592
|
+
expect(result.resources.FriggSubnet1RouteAssociation).toBeDefined();
|
|
1593
|
+
expect(result.resources.FriggSubnet2RouteAssociation).toBeDefined();
|
|
1594
|
+
expect(result.resources.FriggPrivateSubnet1RouteTableAssociation).toBeUndefined();
|
|
1595
|
+
expect(result.resources.FriggPrivateSubnet2RouteTableAssociation).toBeUndefined();
|
|
1608
1596
|
|
|
1609
1597
|
expect(result.resources.VPCEndpointS3).toBeDefined();
|
|
1610
1598
|
expect(result.resources.VPCEndpointS3.Type).toBe('AWS::EC2::VPCEndpoint');
|
|
@@ -1826,8 +1814,6 @@ describe('VpcBuilder', () => {
|
|
|
1826
1814
|
const appDefinition = {
|
|
1827
1815
|
vpc: { enable: true },
|
|
1828
1816
|
encryption: { fieldLevelEncryptionMethod: 'kms' },
|
|
1829
|
-
// The DynamoDB gateway endpoint is opt-in since 37a354e8
|
|
1830
|
-
database: { dynamodb: { enable: true } },
|
|
1831
1817
|
};
|
|
1832
1818
|
|
|
1833
1819
|
const discoveredResources = {
|
|
@@ -4,11 +4,6 @@ const path = require('path');
|
|
|
4
4
|
* Generate IAM CloudFormation template
|
|
5
5
|
* @param {Object} options - Generation options
|
|
6
6
|
* @param {string} [options.appName='Frigg'] - Application name
|
|
7
|
-
* @param {string} [options.serviceName] - The osls service name the app deploys
|
|
8
|
-
* under (Definition.name). Resource grants that match `*frigg*` are also
|
|
9
|
-
* granted for `*<serviceName>*`, because `frigg deploy` names the stack,
|
|
10
|
-
* functions, role, queues, topics, alarms, log groups, layer and buckets
|
|
11
|
-
* after the service, not after "frigg".
|
|
12
7
|
* @param {Object} [options.features={}] - Enabled features { vpc, kms, ssm, websockets }
|
|
13
8
|
* @param {string} [options.userPrefix='frigg-deployment-user'] - IAM user name prefix
|
|
14
9
|
* @param {string} [options.stackName='frigg-deployment-iam'] - CloudFormation stack name
|
|
@@ -21,8 +16,7 @@ function generateIAMCloudFormation(options = {}) {
|
|
|
21
16
|
features = {},
|
|
22
17
|
userPrefix = 'frigg-deployment-user',
|
|
23
18
|
stackName = 'frigg-deployment-iam',
|
|
24
|
-
ssmKmsKeyArn
|
|
25
|
-
serviceName,
|
|
19
|
+
ssmKmsKeyArn
|
|
26
20
|
} = options;
|
|
27
21
|
|
|
28
22
|
const deploymentUserName = userPrefix;
|
|
@@ -531,51 +525,6 @@ function generateIAMCloudFormation(options = {}) {
|
|
|
531
525
|
},
|
|
532
526
|
];
|
|
533
527
|
|
|
534
|
-
coreStatements.push(
|
|
535
|
-
{
|
|
536
|
-
Sid: 'FriggLambdaLayers',
|
|
537
|
-
Effect: 'Allow',
|
|
538
|
-
Action: [
|
|
539
|
-
'lambda:PublishLayerVersion',
|
|
540
|
-
'lambda:DeleteLayerVersion',
|
|
541
|
-
'lambda:GetLayerVersion',
|
|
542
|
-
],
|
|
543
|
-
Resource: [
|
|
544
|
-
{
|
|
545
|
-
'Fn::Sub':
|
|
546
|
-
'arn:aws:lambda:*:${AWS::AccountId}:layer:*frigg*',
|
|
547
|
-
},
|
|
548
|
-
{
|
|
549
|
-
'Fn::Sub':
|
|
550
|
-
'arn:aws:lambda:*:${AWS::AccountId}:layer:*frigg*:*',
|
|
551
|
-
},
|
|
552
|
-
],
|
|
553
|
-
},
|
|
554
|
-
{
|
|
555
|
-
// Buckets the app's stack creates (e.g. the migration-status
|
|
556
|
-
// bucket); CloudFormation names them after the stack, in lower case.
|
|
557
|
-
Sid: 'FriggAppBuckets',
|
|
558
|
-
Effect: 'Allow',
|
|
559
|
-
Action: [
|
|
560
|
-
's3:CreateBucket',
|
|
561
|
-
's3:DeleteBucket',
|
|
562
|
-
's3:PutBucketPolicy',
|
|
563
|
-
's3:DeleteBucketPolicy',
|
|
564
|
-
's3:PutBucketVersioning',
|
|
565
|
-
's3:PutBucketPublicAccessBlock',
|
|
566
|
-
's3:PutEncryptionConfiguration',
|
|
567
|
-
's3:PutLifecycleConfiguration',
|
|
568
|
-
's3:PutBucketTagging',
|
|
569
|
-
's3:GetBucketLocation',
|
|
570
|
-
's3:ListBucket',
|
|
571
|
-
's3:GetObject',
|
|
572
|
-
's3:PutObject',
|
|
573
|
-
's3:DeleteObject',
|
|
574
|
-
],
|
|
575
|
-
Resource: ['arn:aws:s3:::*frigg*', 'arn:aws:s3:::*frigg*/*'],
|
|
576
|
-
}
|
|
577
|
-
);
|
|
578
|
-
|
|
579
528
|
template.Resources.FriggCoreDeploymentPolicy = {
|
|
580
529
|
Type: 'AWS::IAM::ManagedPolicy',
|
|
581
530
|
Properties: {
|
|
@@ -819,59 +768,10 @@ function generateIAMCloudFormation(options = {}) {
|
|
|
819
768
|
},
|
|
820
769
|
};
|
|
821
770
|
|
|
822
|
-
expandResourceNamePatterns(template, serviceName);
|
|
823
|
-
|
|
824
771
|
// Convert to YAML
|
|
825
772
|
return convertToYAML(template);
|
|
826
773
|
}
|
|
827
774
|
|
|
828
|
-
const FRIGG_NAME_PATTERN = '*frigg*';
|
|
829
|
-
|
|
830
|
-
/**
|
|
831
|
-
* Next to every policy resource that matches `*frigg*`, add the same
|
|
832
|
-
* resource for `*<serviceName>*` (lower case for S3 bucket ARNs), so an app
|
|
833
|
-
* that is not named "frigg" can manage its own stack resources.
|
|
834
|
-
*
|
|
835
|
-
* @param {Object} template - CloudFormation template (mutated)
|
|
836
|
-
* @param {string} [serviceName]
|
|
837
|
-
*/
|
|
838
|
-
function expandResourceNamePatterns(template, serviceName) {
|
|
839
|
-
if (!serviceName || /frigg/i.test(serviceName)) {
|
|
840
|
-
return;
|
|
841
|
-
}
|
|
842
|
-
const servicePattern = `*${serviceName}*`;
|
|
843
|
-
const expand = (resource) => {
|
|
844
|
-
const value =
|
|
845
|
-
typeof resource === 'string'
|
|
846
|
-
? resource
|
|
847
|
-
: resource && resource['Fn::Sub'];
|
|
848
|
-
if (typeof value !== 'string' || !value.includes(FRIGG_NAME_PATTERN)) {
|
|
849
|
-
return [resource];
|
|
850
|
-
}
|
|
851
|
-
const pattern = value.startsWith('arn:aws:s3:::')
|
|
852
|
-
? servicePattern.toLowerCase()
|
|
853
|
-
: servicePattern;
|
|
854
|
-
const scoped = value.split(FRIGG_NAME_PATTERN).join(pattern);
|
|
855
|
-
return [
|
|
856
|
-
resource,
|
|
857
|
-
typeof resource === 'string' ? scoped : { 'Fn::Sub': scoped },
|
|
858
|
-
];
|
|
859
|
-
};
|
|
860
|
-
|
|
861
|
-
for (const resource of Object.values(template.Resources)) {
|
|
862
|
-
const statements = resource?.Properties?.PolicyDocument?.Statement;
|
|
863
|
-
if (!Array.isArray(statements)) continue;
|
|
864
|
-
for (const statement of statements) {
|
|
865
|
-
if (statement.Resource === undefined) continue;
|
|
866
|
-
const expanded = [].concat(statement.Resource).flatMap(expand);
|
|
867
|
-
statement.Resource =
|
|
868
|
-
Array.isArray(statement.Resource) || expanded.length > 1
|
|
869
|
-
? expanded
|
|
870
|
-
: expanded[0];
|
|
871
|
-
}
|
|
872
|
-
}
|
|
873
|
-
}
|
|
874
|
-
|
|
875
775
|
/**
|
|
876
776
|
* Convert JavaScript object to CloudFormation YAML
|
|
877
777
|
* @param {Object} obj - JavaScript object
|
|
@@ -896,7 +796,8 @@ function getFeatureSummary(appDefinition) {
|
|
|
896
796
|
const features = {
|
|
897
797
|
core: true, // Always enabled
|
|
898
798
|
vpc: appDefinition.vpc?.enable === true,
|
|
899
|
-
kms:
|
|
799
|
+
kms:
|
|
800
|
+
appDefinition.encryption?.fieldLevelEncryptionMethod === 'kms',
|
|
900
801
|
ssm: appDefinition.ssm?.enable === true,
|
|
901
802
|
websockets: appDefinition.websockets?.enable === true,
|
|
902
803
|
};
|
|
@@ -907,8 +808,6 @@ function getFeatureSummary(appDefinition) {
|
|
|
907
808
|
features,
|
|
908
809
|
integrationCount,
|
|
909
810
|
appName: appDefinition.name || 'Unnamed Frigg App',
|
|
910
|
-
// What createBaseDefinition uses as the osls service name.
|
|
911
|
-
serviceName: appDefinition.name || 'create-frigg-app',
|
|
912
811
|
ssmKmsKeyArn: appDefinition.ssm?.kmsKeyArn,
|
|
913
812
|
};
|
|
914
813
|
}
|
|
@@ -918,10 +817,7 @@ function getFeatureSummary(appDefinition) {
|
|
|
918
817
|
* @returns {Object} Basic IAM policy document
|
|
919
818
|
*/
|
|
920
819
|
function generateBasicIAMPolicy() {
|
|
921
|
-
const basicPolicyPath = path.join(
|
|
922
|
-
__dirname,
|
|
923
|
-
'templates/iam-policy-basic.json'
|
|
924
|
-
);
|
|
820
|
+
const basicPolicyPath = path.join(__dirname, 'templates/iam-policy-basic.json');
|
|
925
821
|
return require(basicPolicyPath);
|
|
926
822
|
}
|
|
927
823
|
|
|
@@ -930,10 +826,7 @@ function generateBasicIAMPolicy() {
|
|
|
930
826
|
* @returns {Object} Full IAM policy document
|
|
931
827
|
*/
|
|
932
828
|
function generateFullIAMPolicy() {
|
|
933
|
-
const fullPolicyPath = path.join(
|
|
934
|
-
__dirname,
|
|
935
|
-
'templates/iam-policy-full.json'
|
|
936
|
-
);
|
|
829
|
+
const fullPolicyPath = path.join(__dirname, 'templates/iam-policy-full.json');
|
|
937
830
|
return require(fullPolicyPath);
|
|
938
831
|
}
|
|
939
832
|
|