@friggframework/devtools 2.0.0--canary.731.ffe61d3.0 → 2.0.0--canary.656.6eb85ab.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 +31 -115
- package/frigg-cli/__tests__/unit/commands/build.test.js +0 -3
- package/frigg-cli/__tests__/unit/commands/deploy.test.js +24 -33
- package/frigg-cli/__tests__/unit/commands/doctor.test.js +6 -10
- package/frigg-cli/__tests__/unit/commands/generate-iam.test.js +0 -18
- package/frigg-cli/__tests__/unit/commands/install.test.js +341 -601
- package/frigg-cli/__tests__/unit/commands/ui.test.js +30 -31
- package/frigg-cli/__tests__/unit/dependencies.test.js +2 -6
- package/frigg-cli/build-command/index.js +0 -6
- package/frigg-cli/deploy-command/index.js +0 -6
- package/frigg-cli/generate-command/index.js +0 -1
- package/frigg-cli/generate-iam-command.js +0 -1
- package/frigg-cli/index.js +5 -22
- package/frigg-cli/index.test.js +158 -0
- package/frigg-cli/init-command/backend-first-handler.js +551 -395
- package/frigg-cli/init-command/index.js +35 -82
- package/frigg-cli/install-command/commit-changes.js +8 -40
- package/frigg-cli/install-command/environment-variables.js +0 -15
- package/frigg-cli/install-command/index.js +21 -96
- package/frigg-cli/install-command/install-package.js +4 -77
- package/frigg-cli/install-command/integration-file.js +11 -20
- package/frigg-cli/install-command/template.js +75 -102
- package/frigg-cli/install-command/validate-package.js +4 -36
- package/frigg-cli/package.json +1 -1
- package/frigg-cli/start-command/index.js +0 -4
- package/frigg-cli/start-command/start-command.test.js +0 -3
- package/frigg-cli/test/init-command.test.js +2 -9
- package/infrastructure/README.md +5 -32
- package/infrastructure/__tests__/postgres-config.test.js +836 -245
- package/infrastructure/__tests__/scoped-environment.test.js +0 -3
- package/infrastructure/__tests__/ssm-preload-node-options.test.js +0 -3
- package/infrastructure/__tests__/template-generation.test.js +8 -39
- package/infrastructure/create-frigg-infrastructure.js +1 -4
- package/infrastructure/docs/POSTGRES-CONFIGURATION.md +98 -80
- package/infrastructure/domains/admin-scripts/admin-script-builder.js +2 -8
- package/infrastructure/domains/admin-scripts/admin-script-builder.test.js +6 -52
- package/infrastructure/domains/database/aurora-builder.js +2 -13
- package/infrastructure/domains/database/aurora-builder.test.js +0 -22
- package/infrastructure/domains/database/migration-builder.js +2 -21
- package/infrastructure/domains/database/migration-builder.test.js +6 -61
- 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/integration/integration-builder.js +0 -2
- package/infrastructure/domains/integration/integration-builder.test.js +6 -22
- 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/environment-builder.js +5 -31
- package/infrastructure/domains/shared/environment-builder.test.js +7 -93
- package/infrastructure/domains/shared/utilities/base-definition-factory.js +3 -39
- package/infrastructure/domains/shared/utilities/base-definition-factory.test.js +5 -85
- package/infrastructure/domains/shared/utilities/nested-node-modules.js +5 -6
- package/infrastructure/domains/shared/utilities/nested-node-modules.test.js +26 -20
- package/infrastructure/domains/shared/utilities/prisma-layer-manager.js +12 -92
- package/infrastructure/domains/shared/utilities/prisma-layer-manager.test.js +6 -158
- package/infrastructure/infrastructure-composer.js +1 -12
- package/infrastructure/infrastructure-composer.test.js +794 -339
- package/infrastructure/integration.test.js +381 -0
- package/infrastructure/scripts/build-prisma-layer.js +50 -136
- package/infrastructure/scripts/build-prisma-layer.test.js +7 -128
- package/infrastructure/scripts/build-time-discovery.test.js +3 -18
- package/package.json +10 -12
- package/frigg-cli/__tests__/unit/commands/init.test.js +0 -688
- package/frigg-cli/__tests__/unit/commands/validate-wiring.test.js +0 -92
- package/frigg-cli/init-command/deployment-modes.js +0 -7
- package/frigg-cli/init-command/safe-path.js +0 -58
- package/frigg-cli/init-command/scaffold-dependencies.js +0 -202
- package/frigg-cli/install-command/app-definition.js +0 -174
- package/frigg-cli/install-command/resolve-module.js +0 -69
- package/frigg-cli/templates/backend/README.md +0 -267
- package/frigg-cli/templates/backend/env.example +0 -20
- package/frigg-cli/templates/backend/gitignore +0 -10
- package/frigg-cli/templates/backend/index.js +0 -114
- package/frigg-cli/templates/backend/infrastructure.js +0 -20
- package/frigg-cli/validate-command/__tests__/init-validation.test.js +0 -63
- package/frigg-cli/validate-command/__tests__/integrations-checks.test.js +0 -133
- package/frigg-cli/validate-command/__tests__/validate-app-definition.test.js +0 -443
- package/frigg-cli/validate-command/__tests__/validate-command.test.js +0 -262
- package/frigg-cli/validate-command/checks/config.js +0 -504
- package/frigg-cli/validate-command/checks/integrations.js +0 -274
- package/frigg-cli/validate-command/format-report.js +0 -58
- package/frigg-cli/validate-command/index.js +0 -107
- package/frigg-cli/validate-command/load-app-definition.js +0 -105
- package/frigg-cli/validate-command/schema-issues.js +0 -154
- package/frigg-cli/validate-command/validate-app-definition.js +0 -60
- package/infrastructure/__tests__/helpers/bundled-prisma-engine-excludes.js +0 -39
- package/infrastructure/__tests__/management-api-gateway-routes.test.js +0 -284
- package/infrastructure/__tests__/scaffold-default-infrastructure.test.js +0 -151
- package/infrastructure/app-definition-schema-contract.test.js +0 -634
- package/infrastructure/create-frigg-infrastructure.test.js +0 -51
- package/infrastructure/domains/database/migration-engines.js +0 -93
- package/infrastructure/domains/database/migration-engines.test.js +0 -142
- package/infrastructure/domains/shared/lambda-architectures.js +0 -113
- package/infrastructure/domains/shared/lambda-architectures.test.js +0 -164
|
@@ -24,9 +24,6 @@ jest.mock('../domains/shared/resource-discovery', () => {
|
|
|
24
24
|
}),
|
|
25
25
|
};
|
|
26
26
|
});
|
|
27
|
-
jest.mock('../domains/database/migration-engines', () => ({
|
|
28
|
-
ensureMigrationEngines: jest.fn().mockResolvedValue(undefined),
|
|
29
|
-
}));
|
|
30
27
|
|
|
31
28
|
const buildApp = (overrides = {}) => ({
|
|
32
29
|
name: 'scoped-test-app',
|
|
@@ -23,9 +23,6 @@ jest.mock('../domains/shared/resource-discovery', () => {
|
|
|
23
23
|
}),
|
|
24
24
|
};
|
|
25
25
|
});
|
|
26
|
-
jest.mock('../domains/database/migration-engines', () => ({
|
|
27
|
-
ensureMigrationEngines: jest.fn().mockResolvedValue(undefined),
|
|
28
|
-
}));
|
|
29
26
|
|
|
30
27
|
const buildApp = (overrides = {}) => ({
|
|
31
28
|
name: 'preload-test',
|
|
@@ -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',
|
|
@@ -631,9 +603,6 @@ describe('CloudFormation Template Generation', () => {
|
|
|
631
603
|
});
|
|
632
604
|
});
|
|
633
605
|
});
|
|
634
|
-
jest.mock('../domains/database/migration-engines', () => ({
|
|
635
|
-
ensureMigrationEngines: jest.fn().mockResolvedValue(undefined),
|
|
636
|
-
}));
|
|
637
606
|
|
|
638
607
|
// Helper functions
|
|
639
608
|
function findAllRefs(obj, refs = []) {
|
|
@@ -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
|
-
|
|
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-
|
|
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,
|
|
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
|
|
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'
|
|
64
|
-
// Ignored when managementMode is 'managed' or 'existing'.
|
|
39
|
+
// Management mode: 'discover' | 'create-new' | 'use-existing'
|
|
65
40
|
management: 'discover',
|
|
66
41
|
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
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
|
-
//
|
|
72
|
-
|
|
73
|
-
|
|
56
|
+
// Backup Configuration
|
|
57
|
+
backupRetentionDays: 7,
|
|
58
|
+
preferredBackupWindow: '03:00-04:00',
|
|
74
59
|
|
|
75
|
-
|
|
76
|
-
|
|
60
|
+
// Security & Advanced
|
|
61
|
+
deletionProtection: true,
|
|
62
|
+
enablePerformanceInsights: false,
|
|
77
63
|
|
|
78
|
-
// use-existing
|
|
79
|
-
|
|
80
|
-
|
|
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
|
-
|
|
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.
|
|
103
|
+
### 2. Create-New Mode
|
|
122
104
|
|
|
123
|
-
|
|
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: '
|
|
130
|
-
|
|
131
|
-
|
|
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
|
-
|
|
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
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
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 (`
|
|
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
|
-
|
|
236
|
-
|
|
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
|
-
|
|
289
|
-
|
|
290
|
-
|
|
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: '
|
|
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: '
|
|
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 "
|
|
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: '
|
|
468
|
-
3. Or
|
|
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
|
|
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
|
-
|
|
565
|
+
enablePerformanceInsights: true,
|
|
566
|
+
// Performance Insights retention: 7 days (default) or 731 days
|
|
557
567
|
}
|
|
558
568
|
}
|
|
559
569
|
```
|
|
560
570
|
|
|
561
|
-
|
|
562
|
-
|
|
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
|
|
|
@@ -16,7 +16,6 @@
|
|
|
16
16
|
const { InfrastructureBuilder, ValidationResult } = require('../shared/base-builder');
|
|
17
17
|
const { isScopedEnvironmentActive } = require('../shared/function-environments');
|
|
18
18
|
const { nestedNodeModulesExcludes } = require('../shared/utilities/nested-node-modules');
|
|
19
|
-
const { bundledPrismaEngineExcludes } = require('../shared/lambda-architectures');
|
|
20
19
|
|
|
21
20
|
class AdminScriptBuilder extends InfrastructureBuilder {
|
|
22
21
|
constructor() {
|
|
@@ -142,12 +141,10 @@ class AdminScriptBuilder extends InfrastructureBuilder {
|
|
|
142
141
|
}
|
|
143
142
|
|
|
144
143
|
createAdminScriptQueue(result, appDefinition) {
|
|
145
|
-
// Registered under custom so the serverless plugin creates it in LocalStack offline
|
|
146
|
-
result.custom.AdminScriptQueue = '${self:service}-${self:provider.stage}-AdminScriptQueue';
|
|
147
144
|
result.resources.AdminScriptQueue = {
|
|
148
145
|
Type: 'AWS::SQS::Queue',
|
|
149
146
|
Properties: {
|
|
150
|
-
QueueName: '${self:
|
|
147
|
+
QueueName: '${self:service}-${self:provider.stage}-AdminScriptQueue',
|
|
151
148
|
MessageRetentionPeriod: 86400, // 1 day
|
|
152
149
|
VisibilityTimeout: 900, // 15 minutes (Lambda max)
|
|
153
150
|
RedrivePolicy: {
|
|
@@ -267,12 +264,10 @@ class AdminScriptBuilder extends InfrastructureBuilder {
|
|
|
267
264
|
}
|
|
268
265
|
|
|
269
266
|
createReportQueue(result, appDefinition) {
|
|
270
|
-
// Registered under custom so the serverless plugin creates it in LocalStack offline
|
|
271
|
-
result.custom.ReportQueue = '${self:service}-${self:provider.stage}-ReportQueue';
|
|
272
267
|
result.resources.ReportQueue = {
|
|
273
268
|
Type: 'AWS::SQS::Queue',
|
|
274
269
|
Properties: {
|
|
275
|
-
QueueName: '${self:
|
|
270
|
+
QueueName: '${self:service}-${self:provider.stage}-ReportQueue',
|
|
276
271
|
MessageRetentionPeriod: 86400, // 1 day
|
|
277
272
|
VisibilityTimeout: 900, // 15 minutes (Lambda max)
|
|
278
273
|
RedrivePolicy: {
|
|
@@ -413,7 +408,6 @@ class AdminScriptBuilder extends InfrastructureBuilder {
|
|
|
413
408
|
'node_modules/@friggframework/core/generated/**',
|
|
414
409
|
]
|
|
415
410
|
: []),
|
|
416
|
-
...bundledPrismaEngineExcludes(appDefinition, usePrismaLayer),
|
|
417
411
|
...nestedNodeModulesExcludes(appDefinition, usePrismaLayer),
|
|
418
412
|
'node_modules/@friggframework/test/**',
|
|
419
413
|
'node_modules/@friggframework/eslint-config/**',
|
|
@@ -10,7 +10,6 @@
|
|
|
10
10
|
|
|
11
11
|
const { AdminScriptBuilder } = require('./admin-script-builder');
|
|
12
12
|
const { ValidationResult } = require('../shared/base-builder');
|
|
13
|
-
const { itBundlesOnlyTheTargetPrismaEngine } = require('../../__tests__/helpers/bundled-prisma-engine-excludes');
|
|
14
13
|
|
|
15
14
|
describe('AdminScriptBuilder', () => {
|
|
16
15
|
let adminScriptBuilder;
|
|
@@ -169,21 +168,6 @@ describe('AdminScriptBuilder', () => {
|
|
|
169
168
|
expect(result.resources.AdminScriptQueue.Properties.VisibilityTimeout).toBe(900); // 15 minutes
|
|
170
169
|
});
|
|
171
170
|
|
|
172
|
-
it('registers AdminScriptQueue under custom so frigg start creates it locally', async () => {
|
|
173
|
-
const appDefinition = {
|
|
174
|
-
adminScripts: [{ Definition: { name: 'test-script' } }],
|
|
175
|
-
};
|
|
176
|
-
|
|
177
|
-
const result = await adminScriptBuilder.build(appDefinition, {});
|
|
178
|
-
|
|
179
|
-
expect(result.custom.AdminScriptQueue).toBe(
|
|
180
|
-
'${self:service}-${self:provider.stage}-AdminScriptQueue'
|
|
181
|
-
);
|
|
182
|
-
expect(result.resources.AdminScriptQueue.Properties.QueueName).toBe(
|
|
183
|
-
'${self:custom.AdminScriptQueue}'
|
|
184
|
-
);
|
|
185
|
-
});
|
|
186
|
-
|
|
187
171
|
it('should configure AdminScriptQueue redrive policy to InternalErrorQueue', async () => {
|
|
188
172
|
const appDefinition = {
|
|
189
173
|
adminScripts: [
|
|
@@ -637,21 +621,6 @@ describe('AdminScriptBuilder', () => {
|
|
|
637
621
|
});
|
|
638
622
|
|
|
639
623
|
describe('reports (ReportQueue + reportExecutor)', () => {
|
|
640
|
-
it('registers ReportQueue under custom so frigg start creates it locally', async () => {
|
|
641
|
-
const appDefinition = {
|
|
642
|
-
reports: [{ Definition: { name: 'my-report', version: '1.0.0' } }],
|
|
643
|
-
};
|
|
644
|
-
|
|
645
|
-
const result = await adminScriptBuilder.build(appDefinition, {});
|
|
646
|
-
|
|
647
|
-
expect(result.custom.ReportQueue).toBe(
|
|
648
|
-
'${self:service}-${self:provider.stage}-ReportQueue'
|
|
649
|
-
);
|
|
650
|
-
expect(result.resources.ReportQueue.Properties.QueueName).toBe(
|
|
651
|
-
'${self:custom.ReportQueue}'
|
|
652
|
-
);
|
|
653
|
-
});
|
|
654
|
-
|
|
655
624
|
it('creates ReportQueue + reportExecutor and wires REPORT_QUEUE_URL when reports are present', async () => {
|
|
656
625
|
const appDefinition = {
|
|
657
626
|
reports: [{ Definition: { name: 'my-report', version: '1.0.0' } }],
|
|
@@ -964,21 +933,6 @@ describe('AdminScriptBuilder', () => {
|
|
|
964
933
|
});
|
|
965
934
|
});
|
|
966
935
|
|
|
967
|
-
describe('Lambda architecture with usePrismaLambdaLayer=false', () => {
|
|
968
|
-
const functionsOf = async (usePrismaLambdaLayer, architecture) => {
|
|
969
|
-
const result = await adminScriptBuilder.build(
|
|
970
|
-
{
|
|
971
|
-
adminScripts: [{ Definition: { name: 'cleanup' } }],
|
|
972
|
-
usePrismaLambdaLayer,
|
|
973
|
-
...(architecture && { architecture }),
|
|
974
|
-
},
|
|
975
|
-
{}
|
|
976
|
-
);
|
|
977
|
-
return Object.values(result.functions);
|
|
978
|
-
};
|
|
979
|
-
itBundlesOnlyTheTargetPrismaEngine(functionsOf);
|
|
980
|
-
});
|
|
981
|
-
|
|
982
936
|
describe('getName()', () => {
|
|
983
937
|
it('should return AdminScriptBuilder', () => {
|
|
984
938
|
expect(adminScriptBuilder.getName()).toBe('AdminScriptBuilder');
|
|
@@ -1041,23 +995,23 @@ describe('AdminScriptBuilder nested node_modules (lambda.keepNestedNodeModules)'
|
|
|
1041
995
|
result.functions.adminScriptRouter,
|
|
1042
996
|
];
|
|
1043
997
|
|
|
1044
|
-
it('
|
|
998
|
+
it('excludes every nested node_modules by default', async () => {
|
|
1045
999
|
const result = await new AdminScriptBuilder().build(appDefinition(), {});
|
|
1046
1000
|
|
|
1047
1001
|
for (const fn of executorAndRouter(result)) {
|
|
1048
|
-
expect(fn.package.exclude).
|
|
1049
|
-
expect(fn.package.exclude).toContain('node_modules/**/node_modules/@friggframework/**');
|
|
1002
|
+
expect(fn.package.exclude).toContain('node_modules/**/node_modules/**');
|
|
1050
1003
|
}
|
|
1051
1004
|
});
|
|
1052
1005
|
|
|
1053
|
-
it('
|
|
1006
|
+
it('keeps nested node_modules when the app opts in, still excluding nested Frigg copies', async () => {
|
|
1054
1007
|
const result = await new AdminScriptBuilder().build(
|
|
1055
|
-
appDefinition({ keepNestedNodeModules:
|
|
1008
|
+
appDefinition({ keepNestedNodeModules: true }),
|
|
1056
1009
|
{}
|
|
1057
1010
|
);
|
|
1058
1011
|
|
|
1059
1012
|
for (const fn of executorAndRouter(result)) {
|
|
1060
|
-
expect(fn.package.exclude).toContain('node_modules/**/node_modules/**');
|
|
1013
|
+
expect(fn.package.exclude).not.toContain('node_modules/**/node_modules/**');
|
|
1014
|
+
expect(fn.package.exclude).toContain('node_modules/**/node_modules/@friggframework/**');
|
|
1061
1015
|
}
|
|
1062
1016
|
});
|
|
1063
1017
|
});
|
|
@@ -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}"`);
|