@friggframework/devtools 2.0.0--canary.710.7cfcf12.0 → 2.0.0--canary.682.451c957.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/frigg-cli/README.md +30 -77
- package/frigg-cli/__tests__/unit/commands/deploy.test.js +24 -30
- 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/generate-command/index.js +0 -1
- package/frigg-cli/generate-iam-command.js +0 -1
- package/frigg-cli/index.js +4 -9
- package/frigg-cli/index.test.js +158 -0
- package/frigg-cli/init-command/backend-first-handler.js +554 -397
- 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/test/init-command.test.js +2 -9
- package/infrastructure/__tests__/management-api-gateway-routes.test.js +335 -0
- package/infrastructure/__tests__/postgres-config.test.js +835 -241
- package/infrastructure/__tests__/template-generation.test.js +8 -36
- package/infrastructure/docs/POSTGRES-CONFIGURATION.md +1 -21
- 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 +28 -17
- package/infrastructure/domains/shared/utilities/base-definition-factory.test.js +61 -22
- 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/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/infrastructure/__tests__/scaffold-default-infrastructure.test.js +0 -148
|
@@ -5,17 +5,6 @@
|
|
|
5
5
|
* valid, consistent CloudFormation templates.
|
|
6
6
|
*/
|
|
7
7
|
|
|
8
|
-
// Never touch AWS or the real Prisma layer from a unit test: discovery returns
|
|
9
|
-
// nothing (a fresh account), and the layer build (npm install into
|
|
10
|
-
// layers/prisma) is stubbed out.
|
|
11
|
-
jest.mock('../domains/shared/resource-discovery', () => ({
|
|
12
|
-
...jest.requireActual('../domains/shared/resource-discovery'),
|
|
13
|
-
gatherDiscoveredResources: jest.fn().mockResolvedValue({}),
|
|
14
|
-
}));
|
|
15
|
-
jest.mock('../domains/shared/utilities/prisma-layer-manager', () => ({
|
|
16
|
-
ensurePrismaLayerExists: jest.fn().mockResolvedValue(undefined),
|
|
17
|
-
}));
|
|
18
|
-
|
|
19
8
|
const { composeServerlessDefinition } = require('../infrastructure-composer');
|
|
20
9
|
|
|
21
10
|
describe('CloudFormation Template Generation', () => {
|
|
@@ -97,16 +86,11 @@ describe('CloudFormation Template Generation', () => {
|
|
|
97
86
|
|
|
98
87
|
// Framework-generated resources (created by Serverless Framework, not our builders)
|
|
99
88
|
const frameworkResources = ['HttpApi', 'HttpApiLogGroup'];
|
|
100
|
-
// Serverless names each function's resource `<Name>LambdaFunction`
|
|
101
|
-
// (e.g. dbMigrationWorker -> DbMigrationWorkerLambdaFunction).
|
|
102
|
-
const functionResources = Object.keys(result.functions || {}).map(
|
|
103
|
-
(name) => `${name.charAt(0).toUpperCase()}${name.slice(1)}LambdaFunction`
|
|
104
|
-
);
|
|
105
89
|
|
|
106
|
-
// Verify all Refs point to existing resources, layers,
|
|
90
|
+
// Verify all Refs point to existing resources, layers, or framework resources
|
|
107
91
|
refs.forEach(ref => {
|
|
108
92
|
if (!frameworkResources.includes(ref)) {
|
|
109
|
-
expect(
|
|
93
|
+
expect(allIds).toContain(ref);
|
|
110
94
|
}
|
|
111
95
|
});
|
|
112
96
|
});
|
|
@@ -139,9 +123,7 @@ describe('CloudFormation Template Generation', () => {
|
|
|
139
123
|
integrations: [
|
|
140
124
|
{ Definition: { name: 'slack' } }
|
|
141
125
|
],
|
|
142
|
-
|
|
143
|
-
// created explicitly; `auto` with no VPC found is a hard error.
|
|
144
|
-
vpc: { enable: true, management: 'create-new' },
|
|
126
|
+
vpc: { enable: true },
|
|
145
127
|
encryption: { fieldLevelEncryptionMethod: 'kms' }
|
|
146
128
|
};
|
|
147
129
|
|
|
@@ -269,9 +251,7 @@ describe('CloudFormation Template Generation', () => {
|
|
|
269
251
|
it('should create VPC resources when enabled', async () => {
|
|
270
252
|
const appDefinition = {
|
|
271
253
|
name: 'test-app',
|
|
272
|
-
|
|
273
|
-
// created explicitly; `auto` with no VPC found is a hard error.
|
|
274
|
-
vpc: { enable: true, management: 'create-new' },
|
|
254
|
+
vpc: { enable: true },
|
|
275
255
|
integrations: []
|
|
276
256
|
};
|
|
277
257
|
|
|
@@ -284,9 +264,7 @@ describe('CloudFormation Template Generation', () => {
|
|
|
284
264
|
it('should create subnets in VPC', async () => {
|
|
285
265
|
const appDefinition = {
|
|
286
266
|
name: 'test-app',
|
|
287
|
-
|
|
288
|
-
// created explicitly; `auto` with no VPC found is a hard error.
|
|
289
|
-
vpc: { enable: true, management: 'create-new' },
|
|
267
|
+
vpc: { enable: true },
|
|
290
268
|
integrations: []
|
|
291
269
|
};
|
|
292
270
|
|
|
@@ -299,9 +277,7 @@ describe('CloudFormation Template Generation', () => {
|
|
|
299
277
|
it('should create security group in VPC', async () => {
|
|
300
278
|
const appDefinition = {
|
|
301
279
|
name: 'test-app',
|
|
302
|
-
|
|
303
|
-
// created explicitly; `auto` with no VPC found is a hard error.
|
|
304
|
-
vpc: { enable: true, management: 'create-new' },
|
|
280
|
+
vpc: { enable: true },
|
|
305
281
|
integrations: []
|
|
306
282
|
};
|
|
307
283
|
|
|
@@ -314,9 +290,7 @@ describe('CloudFormation Template Generation', () => {
|
|
|
314
290
|
it('should configure Lambda functions with VPC', async () => {
|
|
315
291
|
const appDefinition = {
|
|
316
292
|
name: 'test-app',
|
|
317
|
-
|
|
318
|
-
// created explicitly; `auto` with no VPC found is a hard error.
|
|
319
|
-
vpc: { enable: true, management: 'create-new' },
|
|
293
|
+
vpc: { enable: true },
|
|
320
294
|
integrations: [
|
|
321
295
|
{ Definition: { name: 'slack' } }
|
|
322
296
|
]
|
|
@@ -453,9 +427,7 @@ describe('CloudFormation Template Generation', () => {
|
|
|
453
427
|
{ Definition: { name: 'slack' } },
|
|
454
428
|
{ Definition: { name: 'hubspot' } }
|
|
455
429
|
],
|
|
456
|
-
|
|
457
|
-
// created explicitly; `auto` with no VPC found is a hard error.
|
|
458
|
-
vpc: { enable: true, management: 'create-new' },
|
|
430
|
+
vpc: { enable: true },
|
|
459
431
|
encryption: { useDefaultKMSForFieldLevelEncryption: true },
|
|
460
432
|
database: {
|
|
461
433
|
type: 'postgresql',
|
|
@@ -11,30 +11,10 @@ Frigg Framework supports automatic provisioning of Amazon Aurora Serverless v2 P
|
|
|
11
11
|
- **Aurora Serverless v2**: Cost-efficient auto-scaling database (0.5-1.0 ACU default)
|
|
12
12
|
- **VPC Integration**: Deployed in same private subnets as Lambda functions
|
|
13
13
|
- **Secrets Manager**: Automatic credential management and rotation
|
|
14
|
-
- **Management Modes**: discover, create-new, use-existing
|
|
14
|
+
- **Three Management Modes**: discover, create-new, use-existing
|
|
15
15
|
- **Security**: Private subnet deployment with security group isolation
|
|
16
16
|
- **High Availability**: Multi-AZ deployment with automatic failover
|
|
17
17
|
|
|
18
|
-
### Bring your own PostgreSQL (`management: 'external'`)
|
|
19
|
-
|
|
20
|
-
To connect to a PostgreSQL that Frigg does not manage (any hosted provider, or
|
|
21
|
-
a database you run yourself), set `management: 'external'`. Frigg then creates
|
|
22
|
-
and discovers no database resources (no RDS/Aurora, no Secrets Manager secret)
|
|
23
|
-
and needs no VPC for the database; the app connects through `DATABASE_URL`.
|
|
24
|
-
This check takes precedence over a top-level `managementMode`. The migration
|
|
25
|
-
infrastructure is still composed, so migrations run against `DATABASE_URL`.
|
|
26
|
-
|
|
27
|
-
```javascript
|
|
28
|
-
const appDefinition = {
|
|
29
|
-
vpc: { enable: false },
|
|
30
|
-
database: { postgres: { enable: true, management: 'external' } },
|
|
31
|
-
environment: { DATABASE_URL: true }, // read from the shell that runs `frigg deploy` (not .env)
|
|
32
|
-
};
|
|
33
|
-
```
|
|
34
|
-
|
|
35
|
-
Use `sslmode=require` in the URL. This is the default for apps scaffolded by
|
|
36
|
-
`frigg init`.
|
|
37
|
-
|
|
38
18
|
---
|
|
39
19
|
|
|
40
20
|
## Configuration Schema
|
|
@@ -141,12 +141,10 @@ class AdminScriptBuilder extends InfrastructureBuilder {
|
|
|
141
141
|
}
|
|
142
142
|
|
|
143
143
|
createAdminScriptQueue(result, appDefinition) {
|
|
144
|
-
// Registered under custom so the serverless plugin creates it in LocalStack offline
|
|
145
|
-
result.custom.AdminScriptQueue = '${self:service}-${self:provider.stage}-AdminScriptQueue';
|
|
146
144
|
result.resources.AdminScriptQueue = {
|
|
147
145
|
Type: 'AWS::SQS::Queue',
|
|
148
146
|
Properties: {
|
|
149
|
-
QueueName: '${self:
|
|
147
|
+
QueueName: '${self:service}-${self:provider.stage}-AdminScriptQueue',
|
|
150
148
|
MessageRetentionPeriod: 86400, // 1 day
|
|
151
149
|
VisibilityTimeout: 900, // 15 minutes (Lambda max)
|
|
152
150
|
RedrivePolicy: {
|
|
@@ -266,12 +264,10 @@ class AdminScriptBuilder extends InfrastructureBuilder {
|
|
|
266
264
|
}
|
|
267
265
|
|
|
268
266
|
createReportQueue(result, appDefinition) {
|
|
269
|
-
// Registered under custom so the serverless plugin creates it in LocalStack offline
|
|
270
|
-
result.custom.ReportQueue = '${self:service}-${self:provider.stage}-ReportQueue';
|
|
271
267
|
result.resources.ReportQueue = {
|
|
272
268
|
Type: 'AWS::SQS::Queue',
|
|
273
269
|
Properties: {
|
|
274
|
-
QueueName: '${self:
|
|
270
|
+
QueueName: '${self:service}-${self:provider.stage}-ReportQueue',
|
|
275
271
|
MessageRetentionPeriod: 86400, // 1 day
|
|
276
272
|
VisibilityTimeout: 900, // 15 minutes (Lambda max)
|
|
277
273
|
RedrivePolicy: {
|
|
@@ -168,21 +168,6 @@ describe('AdminScriptBuilder', () => {
|
|
|
168
168
|
expect(result.resources.AdminScriptQueue.Properties.VisibilityTimeout).toBe(900); // 15 minutes
|
|
169
169
|
});
|
|
170
170
|
|
|
171
|
-
it('registers AdminScriptQueue under custom so frigg start creates it locally', async () => {
|
|
172
|
-
const appDefinition = {
|
|
173
|
-
adminScripts: [{ Definition: { name: 'test-script' } }],
|
|
174
|
-
};
|
|
175
|
-
|
|
176
|
-
const result = await adminScriptBuilder.build(appDefinition, {});
|
|
177
|
-
|
|
178
|
-
expect(result.custom.AdminScriptQueue).toBe(
|
|
179
|
-
'${self:service}-${self:provider.stage}-AdminScriptQueue'
|
|
180
|
-
);
|
|
181
|
-
expect(result.resources.AdminScriptQueue.Properties.QueueName).toBe(
|
|
182
|
-
'${self:custom.AdminScriptQueue}'
|
|
183
|
-
);
|
|
184
|
-
});
|
|
185
|
-
|
|
186
171
|
it('should configure AdminScriptQueue redrive policy to InternalErrorQueue', async () => {
|
|
187
172
|
const appDefinition = {
|
|
188
173
|
adminScripts: [
|
|
@@ -636,21 +621,6 @@ describe('AdminScriptBuilder', () => {
|
|
|
636
621
|
});
|
|
637
622
|
|
|
638
623
|
describe('reports (ReportQueue + reportExecutor)', () => {
|
|
639
|
-
it('registers ReportQueue under custom so frigg start creates it locally', async () => {
|
|
640
|
-
const appDefinition = {
|
|
641
|
-
reports: [{ Definition: { name: 'my-report', version: '1.0.0' } }],
|
|
642
|
-
};
|
|
643
|
-
|
|
644
|
-
const result = await adminScriptBuilder.build(appDefinition, {});
|
|
645
|
-
|
|
646
|
-
expect(result.custom.ReportQueue).toBe(
|
|
647
|
-
'${self:service}-${self:provider.stage}-ReportQueue'
|
|
648
|
-
);
|
|
649
|
-
expect(result.resources.ReportQueue.Properties.QueueName).toBe(
|
|
650
|
-
'${self:custom.ReportQueue}'
|
|
651
|
-
);
|
|
652
|
-
});
|
|
653
|
-
|
|
654
624
|
it('creates ReportQueue + reportExecutor and wires REPORT_QUEUE_URL when reports are present', async () => {
|
|
655
625
|
const appDefinition = {
|
|
656
626
|
reports: [{ Definition: { name: 'my-report', version: '1.0.0' } }],
|
|
@@ -64,18 +64,7 @@ class AuroraBuilder extends InfrastructureBuilder {
|
|
|
64
64
|
return false;
|
|
65
65
|
}
|
|
66
66
|
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
// management='external': the app brings its own PostgreSQL (any
|
|
70
|
-
// provider) and connects through DATABASE_URL. Frigg creates and
|
|
71
|
-
// discovers no database resources and needs no VPC for it. This
|
|
72
|
-
// check precedes managementMode, which otherwise always manages
|
|
73
|
-
// Aurora. Migrations still run (MigrationBuilder) against DATABASE_URL.
|
|
74
|
-
if (postgres?.management === 'external') {
|
|
75
|
-
return false;
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
return postgres?.enable === true;
|
|
67
|
+
return appDefinition.database?.postgres?.enable === true;
|
|
79
68
|
}
|
|
80
69
|
|
|
81
70
|
getDependencies() {
|
|
@@ -93,7 +82,7 @@ class AuroraBuilder extends InfrastructureBuilder {
|
|
|
93
82
|
const dbConfig = appDefinition.database.postgres;
|
|
94
83
|
|
|
95
84
|
// Validate management mode
|
|
96
|
-
const validModes = ['discover', 'managed', 'use-existing'
|
|
85
|
+
const validModes = ['discover', 'managed', 'use-existing'];
|
|
97
86
|
const management = dbConfig.management || 'discover';
|
|
98
87
|
if (!validModes.includes(management)) {
|
|
99
88
|
result.addError(`Invalid database.postgres.management: "${management}"`);
|
|
@@ -42,28 +42,6 @@ describe('AuroraBuilder', () => {
|
|
|
42
42
|
expect(auroraBuilder.shouldExecute(appDefinition)).toBe(false);
|
|
43
43
|
});
|
|
44
44
|
|
|
45
|
-
it('should return false when Postgres is external (bring your own DATABASE_URL)', () => {
|
|
46
|
-
const appDefinition = {
|
|
47
|
-
database: {
|
|
48
|
-
postgres: { enable: true, management: 'external' },
|
|
49
|
-
},
|
|
50
|
-
};
|
|
51
|
-
|
|
52
|
-
expect(auroraBuilder.shouldExecute(appDefinition)).toBe(false);
|
|
53
|
-
});
|
|
54
|
-
|
|
55
|
-
it('should return false for external Postgres even with managementMode=managed', () => {
|
|
56
|
-
const appDefinition = {
|
|
57
|
-
managementMode: 'managed',
|
|
58
|
-
vpcIsolation: 'isolated',
|
|
59
|
-
database: {
|
|
60
|
-
postgres: { enable: true, management: 'external' },
|
|
61
|
-
},
|
|
62
|
-
};
|
|
63
|
-
|
|
64
|
-
expect(auroraBuilder.shouldExecute(appDefinition)).toBe(false);
|
|
65
|
-
});
|
|
66
|
-
|
|
67
45
|
it('should return false when database is not defined', () => {
|
|
68
46
|
const appDefinition = {};
|
|
69
47
|
|
|
@@ -84,12 +84,10 @@ describe('MismatchAnalyzer Method Name Bug Fix', () => {
|
|
|
84
84
|
driftStatus: 'MODIFIED',
|
|
85
85
|
propertyDifferences: [
|
|
86
86
|
{
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
ActualValue: 'false',
|
|
92
|
-
DifferenceType: 'NOT_EQUAL',
|
|
87
|
+
propertyPath: 'BucketEncryption.Rules[0].BucketKeyEnabled',
|
|
88
|
+
expectedValue: true,
|
|
89
|
+
actualValue: false,
|
|
90
|
+
differenceType: 'NOT_EQUAL',
|
|
93
91
|
},
|
|
94
92
|
],
|
|
95
93
|
});
|
|
@@ -146,12 +144,10 @@ describe('MismatchAnalyzer Method Name Bug Fix', () => {
|
|
|
146
144
|
actualProperties: { BucketEncryption: { enabled: false } },
|
|
147
145
|
propertyDifferences: [
|
|
148
146
|
{
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
ActualValue: 'false',
|
|
154
|
-
DifferenceType: 'NOT_EQUAL',
|
|
147
|
+
propertyPath: 'BucketEncryption.enabled',
|
|
148
|
+
expectedValue: true,
|
|
149
|
+
actualValue: false,
|
|
150
|
+
differenceType: 'NOT_EQUAL',
|
|
155
151
|
},
|
|
156
152
|
],
|
|
157
153
|
});
|
|
@@ -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
|
|