@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.
Files changed (89) hide show
  1. package/README.md +0 -1
  2. package/frigg-cli/README.md +31 -123
  3. package/frigg-cli/__tests__/unit/commands/build.test.js +0 -3
  4. package/frigg-cli/__tests__/unit/commands/deploy.test.js +24 -33
  5. package/frigg-cli/__tests__/unit/commands/doctor.test.js +6 -10
  6. package/frigg-cli/__tests__/unit/commands/generate-iam.test.js +0 -18
  7. package/frigg-cli/__tests__/unit/commands/install.test.js +341 -601
  8. package/frigg-cli/__tests__/unit/commands/ui.test.js +30 -31
  9. package/frigg-cli/__tests__/unit/dependencies.test.js +2 -6
  10. package/frigg-cli/build-command/index.js +0 -6
  11. package/frigg-cli/deploy-command/index.js +0 -6
  12. package/frigg-cli/generate-command/index.js +0 -1
  13. package/frigg-cli/generate-iam-command.js +0 -1
  14. package/frigg-cli/index.js +5 -28
  15. package/frigg-cli/index.test.js +158 -0
  16. package/frigg-cli/init-command/backend-first-handler.js +551 -395
  17. package/frigg-cli/init-command/index.js +35 -82
  18. package/frigg-cli/install-command/commit-changes.js +8 -40
  19. package/frigg-cli/install-command/environment-variables.js +0 -15
  20. package/frigg-cli/install-command/index.js +21 -96
  21. package/frigg-cli/install-command/install-package.js +4 -77
  22. package/frigg-cli/install-command/integration-file.js +11 -20
  23. package/frigg-cli/install-command/template.js +75 -102
  24. package/frigg-cli/install-command/validate-package.js +4 -36
  25. package/frigg-cli/package.json +1 -1
  26. package/frigg-cli/start-command/index.js +0 -4
  27. package/frigg-cli/start-command/start-command.test.js +0 -3
  28. package/frigg-cli/test/init-command.test.js +2 -9
  29. package/infrastructure/__tests__/postgres-config.test.js +835 -241
  30. package/infrastructure/__tests__/template-generation.test.js +8 -36
  31. package/infrastructure/create-frigg-infrastructure.js +1 -4
  32. package/infrastructure/docs/POSTGRES-CONFIGURATION.md +98 -80
  33. package/infrastructure/domains/admin-scripts/admin-script-builder.js +2 -6
  34. package/infrastructure/domains/admin-scripts/admin-script-builder.test.js +0 -30
  35. package/infrastructure/domains/database/aurora-builder.js +2 -13
  36. package/infrastructure/domains/database/aurora-builder.test.js +0 -22
  37. package/infrastructure/domains/health/application/use-cases/__tests__/mismatch-analyzer-method-name.test.js +8 -12
  38. package/infrastructure/domains/health/application/use-cases/__tests__/repair-via-import-use-case.test.js +7 -19
  39. package/infrastructure/domains/health/application/use-cases/run-health-check-use-case.test.js +8 -12
  40. package/infrastructure/domains/health/domain/services/__tests__/import-progress-monitor.test.js +18 -17
  41. package/infrastructure/domains/health/domain/services/__tests__/update-progress-monitor.test.js +2 -12
  42. package/infrastructure/domains/health/infrastructure/adapters/__tests__/orphan-detection-relationship-analysis.test.js +1 -8
  43. package/infrastructure/domains/health/infrastructure/adapters/aws-property-reconciler.test.js +2 -4
  44. package/infrastructure/domains/health/infrastructure/adapters/aws-resource-detector.test.js +0 -10
  45. package/infrastructure/domains/networking/vpc-builder.js +8 -18
  46. package/infrastructure/domains/networking/vpc-builder.test.js +12 -26
  47. package/infrastructure/domains/security/iam-generator.js +5 -112
  48. package/infrastructure/domains/security/iam-generator.test.js +0 -94
  49. package/infrastructure/domains/shared/cloudformation-discovery.test.js +6 -36
  50. package/infrastructure/domains/shared/utilities/base-definition-factory.js +2 -26
  51. package/infrastructure/domains/shared/utilities/base-definition-factory.test.js +1 -34
  52. package/infrastructure/infrastructure-composer.test.js +794 -268
  53. package/infrastructure/integration.test.js +381 -0
  54. package/infrastructure/scripts/build-prisma-layer.test.js +7 -28
  55. package/infrastructure/scripts/build-time-discovery.test.js +3 -18
  56. package/package.json +8 -10
  57. package/frigg-cli/__tests__/unit/commands/init.test.js +0 -688
  58. package/frigg-cli/__tests__/unit/commands/validate-wiring.test.js +0 -92
  59. package/frigg-cli/init-command/deployment-modes.js +0 -7
  60. package/frigg-cli/init-command/safe-path.js +0 -58
  61. package/frigg-cli/init-command/scaffold-dependencies.js +0 -202
  62. package/frigg-cli/install-command/app-definition.js +0 -174
  63. package/frigg-cli/install-command/resolve-module.js +0 -69
  64. package/frigg-cli/templates/backend/README.md +0 -267
  65. package/frigg-cli/templates/backend/env.example +0 -20
  66. package/frigg-cli/templates/backend/gitignore +0 -10
  67. package/frigg-cli/templates/backend/index.js +0 -114
  68. package/frigg-cli/templates/backend/infrastructure.js +0 -20
  69. package/frigg-cli/validate-command/__tests__/init-validation.test.js +0 -63
  70. package/frigg-cli/validate-command/__tests__/integrations-checks.test.js +0 -133
  71. package/frigg-cli/validate-command/__tests__/validate-app-definition.test.js +0 -443
  72. package/frigg-cli/validate-command/__tests__/validate-command.test.js +0 -262
  73. package/frigg-cli/validate-command/__tests__/validate-module-command.test.js +0 -119
  74. package/frigg-cli/validate-command/checks/config.js +0 -504
  75. package/frigg-cli/validate-command/checks/integrations.js +0 -274
  76. package/frigg-cli/validate-command/fixtures/bad-module/index.js +0 -18
  77. package/frigg-cli/validate-command/fixtures/fathom-module/definition.js +0 -76
  78. package/frigg-cli/validate-command/fixtures/fathom-module/index.js +0 -6
  79. package/frigg-cli/validate-command/format-report.js +0 -60
  80. package/frigg-cli/validate-command/index.js +0 -151
  81. package/frigg-cli/validate-command/load-app-definition.js +0 -105
  82. package/frigg-cli/validate-command/load-module-definition.js +0 -64
  83. package/frigg-cli/validate-command/schema-issues.js +0 -154
  84. package/frigg-cli/validate-command/validate-app-definition.js +0 -60
  85. package/frigg-cli/validate-command/validate-module-definition.js +0 -46
  86. package/infrastructure/__tests__/management-api-gateway-routes.test.js +0 -281
  87. package/infrastructure/__tests__/scaffold-default-infrastructure.test.js +0 -148
  88. package/infrastructure/app-definition-schema-contract.test.js +0 -629
  89. package/infrastructure/create-frigg-infrastructure.test.js +0 -51
@@ -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, functions or framework resources
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([...allIds, ...functionResources]).toContain(ref);
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
- // Discovery is stubbed to an empty account, so the VPC must be
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
- // Discovery is stubbed to an empty account, so the VPC must be
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
- // Discovery is stubbed to an empty account, so the VPC must be
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
- // Discovery is stubbed to an empty account, so the VPC must be
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
- // Discovery is stubbed to an empty account, so the VPC must be
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
- // Discovery is stubbed to an empty account, so the VPC must be
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',
@@ -3,7 +3,6 @@ const fs = require('fs-extra');
3
3
  const crypto = require('crypto');
4
4
  const { composeServerlessDefinition } = require('./infrastructure-composer');
5
5
  const { findNearestBackendPackageJson } = require('@friggframework/core');
6
- const { applyAppDefinitionDefaults } = require('@friggframework/schemas');
7
6
 
8
7
  // Filesystem-based cache to persist across osls require cache clears
9
8
  const getCachePath = (backendDir) => {
@@ -103,9 +102,7 @@ async function createFriggInfrastructure() {
103
102
 
104
103
  try {
105
104
  const backend = require(backendFilePath);
106
- // Same defaults step as core's loadAppDefinition (ADR-051), so the
107
- // builders and the runtime see the same definition.
108
- const appDefinition = applyAppDefinitionDefaults(backend.Definition);
105
+ const appDefinition = backend.Definition;
109
106
 
110
107
  const definition = await composeServerlessDefinition(
111
108
  appDefinition,
@@ -8,49 +8,25 @@ 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-4 ACU default)
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, managed, use-existing, external (bring your own `DATABASE_URL`)
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
41
21
 
42
22
  ### App Definition Structure
43
23
 
44
- These are the keys the Aurora builder reads (see `database.postgres` in
45
- `packages/schemas/schemas/app-definition.schema.json`). `frigg validate`
46
- rejects any other key under `database.postgres`.
47
-
48
24
  ```javascript
49
25
  // backend/index.js
50
26
  const appDefinition = {
51
27
  name: 'my-frigg-app',
52
28
 
53
- // VPC Configuration (required for Aurora)
29
+ // Enable VPC deployment (required for Aurora)
54
30
  vpc: {
55
31
  enable: true,
56
32
  },
@@ -60,24 +36,34 @@ const appDefinition = {
60
36
  postgres: {
61
37
  enable: true,
62
38
 
63
- // 'discover' (also when omitted) | 'managed' | 'use-existing'
64
- // Ignored when managementMode is 'managed' or 'existing'.
39
+ // Management mode: 'discover' | 'create-new' | 'use-existing'
65
40
  management: 'discover',
66
41
 
67
- database: 'frigg', // database name (default 'frigg')
68
- username: 'postgres', // master user (default 'postgres')
69
- engineVersion: '15.13', // Aurora PostgreSQL version (default '15.13')
42
+ // Basic Configuration
43
+ databaseName: 'frigg_db',
44
+ masterUsername: 'frigg_admin',
45
+
46
+ // Engine Configuration
47
+ engine: 'aurora-postgresql',
48
+ engineVersion: '15.3',
49
+
50
+ // Scaling Configuration (Aurora Serverless v2)
51
+ scaling: {
52
+ minCapacity: 0.5, // ACUs (0.5 = ~1GB RAM, ~$43/month)
53
+ maxCapacity: 1.0, // ACUs (1.0 = ~2GB RAM, ~$87/month)
54
+ },
70
55
 
71
- // Aurora Serverless v2 capacity, in ACUs (0.5-128)
72
- minCapacity: 0.5, // default 0.5
73
- maxCapacity: 4, // default 4
56
+ // Backup Configuration
57
+ backupRetentionDays: 7,
58
+ preferredBackupWindow: '03:00-04:00',
74
59
 
75
- publiclyAccessible: false, // default false (private subnets)
76
- autoCreateCredentials: false, // discover only: create a secret for a discovered cluster
60
+ // Security & Advanced
61
+ deletionProtection: true,
62
+ enablePerformanceInsights: false,
77
63
 
78
- // use-existing only
79
- // endpoint: 'mydb.cluster-abc123.us-east-1.rds.amazonaws.com',
80
- // port: 5432,
64
+ // For use-existing mode
65
+ clusterIdentifier: 'my-existing-cluster',
66
+ secretArn: 'arn:aws:secretsmanager:...',
81
67
  }
82
68
  }
83
69
  };
@@ -87,17 +73,13 @@ module.exports = {
87
73
  };
88
74
  ```
89
75
 
90
- Backup retention (7 days), the backup and maintenance windows and deletion
91
- settings are fixed by the builder and are not configurable through the app
92
- definition.
93
-
94
76
  ---
95
77
 
96
78
  ## Management Modes
97
79
 
98
80
  ### 1. Discover Mode (Default)
99
81
 
100
- Discovers an existing Aurora cluster, or creates a new one in the stack if none is found.
82
+ Automatically discovers existing Aurora clusters or creates new one if none found.
101
83
 
102
84
  ```javascript
103
85
  database: {
@@ -118,56 +100,63 @@ database: {
118
100
 
119
101
  ---
120
102
 
121
- ### 2. Managed Mode
103
+ ### 2. Create-New Mode
122
104
 
123
- Creates the cluster, instance, subnet group and secret in the stack.
105
+ Always creates a new Aurora cluster, even if existing clusters are found.
124
106
 
125
107
  ```javascript
126
108
  database: {
127
109
  postgres: {
128
110
  enable: true,
129
- management: 'managed',
130
- minCapacity: 1,
131
- maxCapacity: 2,
111
+ management: 'create-new',
112
+
113
+ // Customization options
114
+ databaseName: 'my_app_db',
115
+ masterUsername: 'admin',
116
+ engineVersion: '15.3',
117
+ scaling: {
118
+ minCapacity: 1.0,
119
+ maxCapacity: 2.0,
120
+ },
121
+ backupRetentionDays: 14,
122
+ deletionProtection: true,
132
123
  }
133
124
  }
134
125
  ```
135
126
 
136
- With the top-level `managementMode: 'managed'` (and `vpcIsolation: 'isolated'`),
137
- Frigg manages the database per stage and `database.postgres.management` is ignored.
138
-
139
127
  **Best For**: Production environments where you want dedicated database resources.
140
128
 
141
129
  ---
142
130
 
143
131
  ### 3. Use-Existing Mode
144
132
 
145
- Connects to an existing PostgreSQL endpoint without creating database resources.
133
+ Uses a specific existing Aurora cluster by identifier.
146
134
 
147
135
  ```javascript
148
136
  database: {
149
137
  postgres: {
150
138
  enable: true,
151
139
  management: 'use-existing',
152
- endpoint: 'my-cluster.cluster-abc123.us-east-1.rds.amazonaws.com', // required
153
- port: 5432,
154
- database: 'frigg_db',
155
- username: 'frigg_admin',
140
+
141
+ // Required: existing cluster identifier
142
+ clusterIdentifier: 'my-existing-aurora-cluster',
143
+
144
+ // Optional: secret ARN (discovered if not provided)
145
+ secretArn: 'arn:aws:secretsmanager:us-east-1:123456789012:secret:my-db-secret',
146
+
147
+ // Database name to connect to
148
+ databaseName: 'frigg_db',
156
149
  }
157
150
  }
158
151
  ```
159
152
 
160
- To use an existing cluster by identifier instead, use the ownership form:
161
- `ownership: { cluster: 'external', instance: 'external' }` with
162
- `external: { clusterIdentifier, instanceIdentifier, secretArn }`.
163
-
164
153
  **Best For**: Shared database scenarios or when you manage Aurora outside of Frigg.
165
154
 
166
155
  ---
167
156
 
168
157
  ## Created AWS Resources
169
158
 
170
- When provisioning Aurora (`managed`, or `discover` mode without an existing cluster), Frigg creates:
159
+ When provisioning Aurora (`create-new` or `discover` mode without existing cluster), Frigg creates:
171
160
 
172
161
  ### 1. RDS DB Subnet Group
173
162
  - **Name**: `{service}-{stage}-db-subnet-group`
@@ -232,15 +221,17 @@ database: {
232
221
  database: {
233
222
  postgres: {
234
223
  enable: true,
235
- minCapacity: 1, // Higher baseline for production
236
- maxCapacity: 4, // Handle traffic spikes
224
+ scaling: {
225
+ minCapacity: 1.0, // Higher baseline for production
226
+ maxCapacity: 4.0, // Handle traffic spikes
227
+ },
228
+ backupRetentionDays: 30, // Longer retention
229
+ enablePerformanceInsights: true, // Monitoring
230
+ deletionProtection: true, // Prevent accidental deletion
237
231
  }
238
232
  }
239
233
  ```
240
234
 
241
- Backup retention, Performance Insights and deletion protection are not
242
- configurable through the app definition; change them on the cluster.
243
-
244
235
  **Estimated Monthly Costs**:
245
236
  - **Baseline**: $87/month (1.0 ACU minimum)
246
237
  - **Peak Traffic**: $348/month (4.0 ACU maximum)
@@ -285,9 +276,15 @@ const users = await prismaClient.user.findMany();
285
276
 
286
277
  ### 4. Deletion Protection
287
278
 
288
- Deletion protection is not configurable through the app definition. Enable it
289
- on the cluster in the AWS console (or with the AWS CLI); you must then disable
290
- it before deleting the stack.
279
+ ```javascript
280
+ database: {
281
+ postgres: {
282
+ deletionProtection: true, // Prevents accidental deletion
283
+ }
284
+ }
285
+ ```
286
+
287
+ **Important**: When enabled, you must manually disable deletion protection in AWS console before stack deletion.
291
288
 
292
289
  ---
293
290
 
@@ -387,7 +384,7 @@ DB_TYPE=postgresql
387
384
  database: {
388
385
  postgres: {
389
386
  enable: true,
390
- management: 'managed',
387
+ management: 'create-new',
391
388
  }
392
389
  }
393
390
  ```
@@ -414,7 +411,7 @@ DB_TYPE=postgresql
414
411
  database: {
415
412
  postgres: {
416
413
  enable: true,
417
- management: 'managed',
414
+ management: 'create-new',
418
415
  }
419
416
  }
420
417
  ```
@@ -459,13 +456,13 @@ DB_TYPE=postgresql
459
456
 
460
457
  **Error**:
461
458
  ```
462
- No Aurora cluster found in discovery mode. Set management to "managed" or provide endpoint with "use-existing".
459
+ No Aurora cluster found in discovery mode. Set management to "create-new"...
463
460
  ```
464
461
 
465
462
  **Solution**:
466
463
  1. Check VPC is enabled: `vpc.enable: true`
467
- 2. Set management mode: `management: 'managed'`
468
- 3. Or connect to a known endpoint: `management: 'use-existing'`, `endpoint: '...'`
464
+ 2. Set management mode: `management: 'create-new'`
465
+ 3. Or provide cluster identifier: `clusterIdentifier: 'my-cluster'`
469
466
 
470
467
  ---
471
468
 
@@ -547,19 +544,40 @@ Cannot create Aurora cluster: InsufficientDBInstanceCapacity
547
544
 
548
545
  ## Advanced Configuration
549
546
 
550
- ### Custom Engine Version
547
+ ### Custom Backup Window
548
+
549
+ ```javascript
550
+ database: {
551
+ postgres: {
552
+ enable: true,
553
+ backupRetentionDays: 30,
554
+ preferredBackupWindow: '02:00-03:00', // UTC
555
+ }
556
+ }
557
+ ```
558
+
559
+ ### Enhanced Monitoring
551
560
 
552
561
  ```javascript
553
562
  database: {
554
563
  postgres: {
555
564
  enable: true,
556
- engineVersion: '16.4', // Default: 15.13
565
+ enablePerformanceInsights: true,
566
+ // Performance Insights retention: 7 days (default) or 731 days
557
567
  }
558
568
  }
559
569
  ```
560
570
 
561
- The backup window, backup retention and Performance Insights are set by the
562
- builder and are not configurable through the app definition.
571
+ ### Custom Engine Version
572
+
573
+ ```javascript
574
+ database: {
575
+ postgres: {
576
+ enable: true,
577
+ engineVersion: '14.6', // Default: 15.3
578
+ }
579
+ }
580
+ ```
563
581
 
564
582
  ### Read Replicas (Not Supported Yet)
565
583
 
@@ -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:custom.AdminScriptQueue}',
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:custom.ReportQueue}',
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
- const postgres = appDefinition.database?.postgres;
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', 'external'];
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
- // Raw CloudFormation PropertyDifference shape, as passed through by
88
- // AWSStackRepository.getResourceDrift() (PascalCase, slash-separated path).
89
- PropertyPath: '/BucketEncryption/ServerSideEncryptionConfiguration/0/BucketKeyEnabled',
90
- ExpectedValue: 'true',
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
- // Raw CloudFormation PropertyDifference shape, as passed through by
150
- // AWSStackRepository.getResourceDrift() (PascalCase, slash-separated path).
151
- PropertyPath: '/BucketEncryption/enabled',
152
- ExpectedValue: 'true',
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
  });