@friggframework/devtools 2.0.0--canary.710.91495fa.0 → 2.0.0--canary.702.ef0dc8c.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 +1 -0
- package/frigg-cli/README.md +76 -78
- package/frigg-cli/__tests__/unit/commands/build.test.js +3 -0
- package/frigg-cli/__tests__/unit/commands/deploy.test.js +27 -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/commands/validate-wiring.test.js +92 -0
- package/frigg-cli/__tests__/unit/dependencies.test.js +2 -6
- package/frigg-cli/build-command/index.js +6 -0
- package/frigg-cli/deploy-command/index.js +6 -0
- package/frigg-cli/generate-command/index.js +0 -1
- package/frigg-cli/generate-iam-command.js +0 -1
- package/frigg-cli/index.js +23 -10
- package/frigg-cli/index.test.js +158 -0
- package/frigg-cli/init-command/backend-first-handler.js +531 -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 +4 -0
- package/frigg-cli/start-command/start-command.test.js +3 -0
- package/frigg-cli/test/init-command.test.js +2 -9
- package/frigg-cli/validate-command/__tests__/init-validation.test.js +63 -0
- package/frigg-cli/validate-command/__tests__/integrations-checks.test.js +133 -0
- package/frigg-cli/validate-command/__tests__/validate-app-definition.test.js +326 -0
- package/frigg-cli/validate-command/__tests__/validate-command.test.js +241 -0
- package/frigg-cli/validate-command/__tests__/validate-module-command.test.js +119 -0
- package/frigg-cli/validate-command/checks/config.js +468 -0
- package/frigg-cli/validate-command/checks/integrations.js +274 -0
- package/frigg-cli/validate-command/fixtures/bad-module/index.js +18 -0
- package/frigg-cli/validate-command/fixtures/fathom-module/definition.js +76 -0
- package/frigg-cli/validate-command/fixtures/fathom-module/index.js +6 -0
- package/frigg-cli/validate-command/format-report.js +60 -0
- package/frigg-cli/validate-command/index.js +151 -0
- package/frigg-cli/validate-command/load-app-definition.js +93 -0
- package/frigg-cli/validate-command/load-module-definition.js +64 -0
- package/frigg-cli/validate-command/schema-issues.js +154 -0
- package/frigg-cli/validate-command/validate-app-definition.js +60 -0
- package/frigg-cli/validate-command/validate-module-definition.js +46 -0
- package/infrastructure/__tests__/postgres-config.test.js +835 -241
- package/infrastructure/__tests__/template-generation.test.js +8 -36
- package/infrastructure/app-definition-schema-contract.test.js +607 -0
- package/infrastructure/create-frigg-infrastructure.js +4 -1
- package/infrastructure/create-frigg-infrastructure.test.js +51 -0
- package/infrastructure/docs/POSTGRES-CONFIGURATION.md +60 -118
- 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 +13 -32
- 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 -7
- package/infrastructure/domains/shared/utilities/base-definition-factory.test.js +0 -21
- 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
|
@@ -8,45 +8,29 @@ Frigg Framework supports automatic provisioning of Amazon Aurora Serverless v2 P
|
|
|
8
8
|
|
|
9
9
|
### Key Features
|
|
10
10
|
|
|
11
|
-
- **Aurora Serverless v2**: Cost-efficient auto-scaling database (0.5-
|
|
11
|
+
- **Aurora Serverless v2**: Cost-efficient auto-scaling database (0.5-4 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,
|
|
14
|
+
- **Three Management Modes**: discover, managed, 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
|
|
41
21
|
|
|
42
22
|
### App Definition Structure
|
|
43
23
|
|
|
24
|
+
These are the keys the Aurora builder reads (see `database.postgres` in
|
|
25
|
+
`packages/schemas/schemas/app-definition.schema.json`). `frigg validate`
|
|
26
|
+
rejects any other key under `database.postgres`.
|
|
27
|
+
|
|
44
28
|
```javascript
|
|
45
29
|
// backend/index.js
|
|
46
30
|
const appDefinition = {
|
|
47
31
|
name: 'my-frigg-app',
|
|
48
32
|
|
|
49
|
-
//
|
|
33
|
+
// VPC Configuration (required for Aurora)
|
|
50
34
|
vpc: {
|
|
51
35
|
enable: true,
|
|
52
36
|
},
|
|
@@ -56,34 +40,24 @@ const appDefinition = {
|
|
|
56
40
|
postgres: {
|
|
57
41
|
enable: true,
|
|
58
42
|
|
|
59
|
-
//
|
|
43
|
+
// 'discover' (also when omitted) | 'managed' | 'use-existing'
|
|
44
|
+
// Ignored when managementMode is 'managed' or 'existing'.
|
|
60
45
|
management: 'discover',
|
|
61
46
|
|
|
62
|
-
//
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
// Engine Configuration
|
|
67
|
-
engine: 'aurora-postgresql',
|
|
68
|
-
engineVersion: '15.3',
|
|
69
|
-
|
|
70
|
-
// Scaling Configuration (Aurora Serverless v2)
|
|
71
|
-
scaling: {
|
|
72
|
-
minCapacity: 0.5, // ACUs (0.5 = ~1GB RAM, ~$43/month)
|
|
73
|
-
maxCapacity: 1.0, // ACUs (1.0 = ~2GB RAM, ~$87/month)
|
|
74
|
-
},
|
|
47
|
+
database: 'frigg', // database name (default 'frigg')
|
|
48
|
+
username: 'postgres', // master user (default 'postgres')
|
|
49
|
+
engineVersion: '15.13', // Aurora PostgreSQL version (default '15.13')
|
|
75
50
|
|
|
76
|
-
//
|
|
77
|
-
|
|
78
|
-
|
|
51
|
+
// Aurora Serverless v2 capacity, in ACUs (0.5-128)
|
|
52
|
+
minCapacity: 0.5, // default 0.5
|
|
53
|
+
maxCapacity: 4, // default 4
|
|
79
54
|
|
|
80
|
-
//
|
|
81
|
-
|
|
82
|
-
enablePerformanceInsights: false,
|
|
55
|
+
publiclyAccessible: false, // default false (private subnets)
|
|
56
|
+
autoCreateCredentials: false, // discover only: create a secret for a discovered cluster
|
|
83
57
|
|
|
84
|
-
//
|
|
85
|
-
|
|
86
|
-
|
|
58
|
+
// use-existing only
|
|
59
|
+
// endpoint: 'mydb.cluster-abc123.us-east-1.rds.amazonaws.com',
|
|
60
|
+
// port: 5432,
|
|
87
61
|
}
|
|
88
62
|
}
|
|
89
63
|
};
|
|
@@ -93,13 +67,17 @@ module.exports = {
|
|
|
93
67
|
};
|
|
94
68
|
```
|
|
95
69
|
|
|
70
|
+
Backup retention (7 days), the backup and maintenance windows and deletion
|
|
71
|
+
settings are fixed by the builder and are not configurable through the app
|
|
72
|
+
definition.
|
|
73
|
+
|
|
96
74
|
---
|
|
97
75
|
|
|
98
76
|
## Management Modes
|
|
99
77
|
|
|
100
78
|
### 1. Discover Mode (Default)
|
|
101
79
|
|
|
102
|
-
|
|
80
|
+
Discovers an existing Aurora cluster, or creates a new one in the stack if none is found.
|
|
103
81
|
|
|
104
82
|
```javascript
|
|
105
83
|
database: {
|
|
@@ -120,63 +98,56 @@ database: {
|
|
|
120
98
|
|
|
121
99
|
---
|
|
122
100
|
|
|
123
|
-
### 2.
|
|
101
|
+
### 2. Managed Mode
|
|
124
102
|
|
|
125
|
-
|
|
103
|
+
Creates the cluster, instance, subnet group and secret in the stack.
|
|
126
104
|
|
|
127
105
|
```javascript
|
|
128
106
|
database: {
|
|
129
107
|
postgres: {
|
|
130
108
|
enable: true,
|
|
131
|
-
management: '
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
databaseName: 'my_app_db',
|
|
135
|
-
masterUsername: 'admin',
|
|
136
|
-
engineVersion: '15.3',
|
|
137
|
-
scaling: {
|
|
138
|
-
minCapacity: 1.0,
|
|
139
|
-
maxCapacity: 2.0,
|
|
140
|
-
},
|
|
141
|
-
backupRetentionDays: 14,
|
|
142
|
-
deletionProtection: true,
|
|
109
|
+
management: 'managed',
|
|
110
|
+
minCapacity: 1,
|
|
111
|
+
maxCapacity: 2,
|
|
143
112
|
}
|
|
144
113
|
}
|
|
145
114
|
```
|
|
146
115
|
|
|
116
|
+
With the top-level `managementMode: 'managed'` (and `vpcIsolation: 'isolated'`),
|
|
117
|
+
Frigg manages the database per stage and `database.postgres.management` is ignored.
|
|
118
|
+
|
|
147
119
|
**Best For**: Production environments where you want dedicated database resources.
|
|
148
120
|
|
|
149
121
|
---
|
|
150
122
|
|
|
151
123
|
### 3. Use-Existing Mode
|
|
152
124
|
|
|
153
|
-
|
|
125
|
+
Connects to an existing PostgreSQL endpoint without creating database resources.
|
|
154
126
|
|
|
155
127
|
```javascript
|
|
156
128
|
database: {
|
|
157
129
|
postgres: {
|
|
158
130
|
enable: true,
|
|
159
131
|
management: 'use-existing',
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
// Optional: secret ARN (discovered if not provided)
|
|
165
|
-
secretArn: 'arn:aws:secretsmanager:us-east-1:123456789012:secret:my-db-secret',
|
|
166
|
-
|
|
167
|
-
// Database name to connect to
|
|
168
|
-
databaseName: 'frigg_db',
|
|
132
|
+
endpoint: 'my-cluster.cluster-abc123.us-east-1.rds.amazonaws.com', // required
|
|
133
|
+
port: 5432,
|
|
134
|
+
database: 'frigg_db',
|
|
135
|
+
username: 'frigg_admin',
|
|
169
136
|
}
|
|
170
137
|
}
|
|
171
138
|
```
|
|
172
139
|
|
|
140
|
+
To use an existing cluster by identifier instead, use the ownership form:
|
|
141
|
+
`ownership: { cluster: 'external', instance: 'external' }` with
|
|
142
|
+
`external: { clusterIdentifier, instanceIdentifier, secretArn }`.
|
|
143
|
+
|
|
173
144
|
**Best For**: Shared database scenarios or when you manage Aurora outside of Frigg.
|
|
174
145
|
|
|
175
146
|
---
|
|
176
147
|
|
|
177
148
|
## Created AWS Resources
|
|
178
149
|
|
|
179
|
-
When provisioning Aurora (`
|
|
150
|
+
When provisioning Aurora (`managed`, or `discover` mode without an existing cluster), Frigg creates:
|
|
180
151
|
|
|
181
152
|
### 1. RDS DB Subnet Group
|
|
182
153
|
- **Name**: `{service}-{stage}-db-subnet-group`
|
|
@@ -241,17 +212,15 @@ database: {
|
|
|
241
212
|
database: {
|
|
242
213
|
postgres: {
|
|
243
214
|
enable: true,
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
maxCapacity: 4.0, // Handle traffic spikes
|
|
247
|
-
},
|
|
248
|
-
backupRetentionDays: 30, // Longer retention
|
|
249
|
-
enablePerformanceInsights: true, // Monitoring
|
|
250
|
-
deletionProtection: true, // Prevent accidental deletion
|
|
215
|
+
minCapacity: 1, // Higher baseline for production
|
|
216
|
+
maxCapacity: 4, // Handle traffic spikes
|
|
251
217
|
}
|
|
252
218
|
}
|
|
253
219
|
```
|
|
254
220
|
|
|
221
|
+
Backup retention, Performance Insights and deletion protection are not
|
|
222
|
+
configurable through the app definition; change them on the cluster.
|
|
223
|
+
|
|
255
224
|
**Estimated Monthly Costs**:
|
|
256
225
|
- **Baseline**: $87/month (1.0 ACU minimum)
|
|
257
226
|
- **Peak Traffic**: $348/month (4.0 ACU maximum)
|
|
@@ -296,15 +265,9 @@ const users = await prismaClient.user.findMany();
|
|
|
296
265
|
|
|
297
266
|
### 4. Deletion Protection
|
|
298
267
|
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
deletionProtection: true, // Prevents accidental deletion
|
|
303
|
-
}
|
|
304
|
-
}
|
|
305
|
-
```
|
|
306
|
-
|
|
307
|
-
**Important**: When enabled, you must manually disable deletion protection in AWS console before stack deletion.
|
|
268
|
+
Deletion protection is not configurable through the app definition. Enable it
|
|
269
|
+
on the cluster in the AWS console (or with the AWS CLI); you must then disable
|
|
270
|
+
it before deleting the stack.
|
|
308
271
|
|
|
309
272
|
---
|
|
310
273
|
|
|
@@ -404,7 +367,7 @@ DB_TYPE=postgresql
|
|
|
404
367
|
database: {
|
|
405
368
|
postgres: {
|
|
406
369
|
enable: true,
|
|
407
|
-
management: '
|
|
370
|
+
management: 'managed',
|
|
408
371
|
}
|
|
409
372
|
}
|
|
410
373
|
```
|
|
@@ -431,7 +394,7 @@ DB_TYPE=postgresql
|
|
|
431
394
|
database: {
|
|
432
395
|
postgres: {
|
|
433
396
|
enable: true,
|
|
434
|
-
management: '
|
|
397
|
+
management: 'managed',
|
|
435
398
|
}
|
|
436
399
|
}
|
|
437
400
|
```
|
|
@@ -476,13 +439,13 @@ DB_TYPE=postgresql
|
|
|
476
439
|
|
|
477
440
|
**Error**:
|
|
478
441
|
```
|
|
479
|
-
No Aurora cluster found in discovery mode. Set management to "
|
|
442
|
+
No Aurora cluster found in discovery mode. Set management to "managed" or provide endpoint with "use-existing".
|
|
480
443
|
```
|
|
481
444
|
|
|
482
445
|
**Solution**:
|
|
483
446
|
1. Check VPC is enabled: `vpc.enable: true`
|
|
484
|
-
2. Set management mode: `management: '
|
|
485
|
-
3. Or
|
|
447
|
+
2. Set management mode: `management: 'managed'`
|
|
448
|
+
3. Or connect to a known endpoint: `management: 'use-existing'`, `endpoint: '...'`
|
|
486
449
|
|
|
487
450
|
---
|
|
488
451
|
|
|
@@ -564,41 +527,20 @@ Cannot create Aurora cluster: InsufficientDBInstanceCapacity
|
|
|
564
527
|
|
|
565
528
|
## Advanced Configuration
|
|
566
529
|
|
|
567
|
-
### Custom Backup Window
|
|
568
|
-
|
|
569
|
-
```javascript
|
|
570
|
-
database: {
|
|
571
|
-
postgres: {
|
|
572
|
-
enable: true,
|
|
573
|
-
backupRetentionDays: 30,
|
|
574
|
-
preferredBackupWindow: '02:00-03:00', // UTC
|
|
575
|
-
}
|
|
576
|
-
}
|
|
577
|
-
```
|
|
578
|
-
|
|
579
|
-
### Enhanced Monitoring
|
|
580
|
-
|
|
581
|
-
```javascript
|
|
582
|
-
database: {
|
|
583
|
-
postgres: {
|
|
584
|
-
enable: true,
|
|
585
|
-
enablePerformanceInsights: true,
|
|
586
|
-
// Performance Insights retention: 7 days (default) or 731 days
|
|
587
|
-
}
|
|
588
|
-
}
|
|
589
|
-
```
|
|
590
|
-
|
|
591
530
|
### Custom Engine Version
|
|
592
531
|
|
|
593
532
|
```javascript
|
|
594
533
|
database: {
|
|
595
534
|
postgres: {
|
|
596
535
|
enable: true,
|
|
597
|
-
engineVersion: '
|
|
536
|
+
engineVersion: '16.4', // Default: 15.13
|
|
598
537
|
}
|
|
599
538
|
}
|
|
600
539
|
```
|
|
601
540
|
|
|
541
|
+
The backup window, backup retention and Performance Insights are set by the
|
|
542
|
+
builder and are not configurable through the app definition.
|
|
543
|
+
|
|
602
544
|
### Read Replicas (Not Supported Yet)
|
|
603
545
|
|
|
604
546
|
Frigg currently provisions a single Aurora instance. For read replicas:
|
|
@@ -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',
|