@friggframework/devtools 2.0.0--canary.474.97bfcf0.0 → 2.0.0--canary.474.da7b114.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.
@@ -0,0 +1,1136 @@
1
+ # Frigg CLI - Complete Documentation
2
+
3
+ ## Overview
4
+
5
+ The Frigg CLI provides tools for building, deploying, and managing serverless integrations on cloud platforms. Built with Domain-Driven Design and Hexagonal Architecture for multi-cloud extensibility.
6
+
7
+ ---
8
+
9
+ ## Command Reference
10
+
11
+ ### Core Commands
12
+
13
+ #### `frigg install <module-name>`
14
+
15
+ Install and configure an API integration module from the Frigg module library.
16
+
17
+ **Usage:**
18
+ ```bash
19
+ frigg install hubspot
20
+ frigg install salesforce
21
+ frigg install stripe
22
+ ```
23
+
24
+ **What it does:**
25
+ - Searches the api-module-library for the specified integration
26
+ - Installs the npm package (@friggframework/api-module-{name})
27
+ - Adds integration to your app definition
28
+ - Configures OAuth flows and webhooks if applicable
29
+ - Creates integration-specific environment variable placeholders
30
+
31
+ **Options:**
32
+ - None currently (could add `--version`, `--registry` in future)
33
+
34
+ **Example Output:**
35
+ ```
36
+ 🔍 Finding integration module: hubspot
37
+ ✓ Found @friggframework/api-module-hubspot@2.0.5
38
+ 📦 Installing package...
39
+ ✓ Package installed successfully
40
+ 🔧 Configuring integration in app definition...
41
+ ✓ Integration configured
42
+ ⚙️ Next steps:
43
+ 1. Set HUBSPOT_CLIENT_ID in your environment
44
+ 2. Set HUBSPOT_CLIENT_SECRET in your environment
45
+ 3. Run 'frigg start' to test locally
46
+ ```
47
+
48
+ ---
49
+
50
+ #### `frigg search <term>`
51
+
52
+ Search for available API integration modules.
53
+
54
+ **Usage:**
55
+ ```bash
56
+ frigg search crm
57
+ frigg search payment
58
+ frigg search
59
+ ```
60
+
61
+ **What it does:**
62
+ - Queries the api-module-library directory
63
+ - Filters modules by name, description, or category
64
+ - Returns list of matching integrations with metadata
65
+
66
+ **Options:**
67
+ - None (searches all if no term provided)
68
+
69
+ **Example Output:**
70
+ ```
71
+ 📚 Available API Modules:
72
+
73
+ CRM Systems:
74
+ • hubspot - HubSpot CRM & Marketing automation
75
+ • salesforce - Salesforce CRM & Sales Cloud
76
+ • pipedrive - Pipedrive sales CRM
77
+
78
+ Payment Processing:
79
+ • stripe - Stripe payment processing
80
+ • square - Square payments & POS
81
+
82
+ Found 5 modules matching "crm"
83
+ ```
84
+
85
+ ---
86
+
87
+ #### `frigg start [options]`
88
+
89
+ Start local development server with hot reload.
90
+
91
+ **Usage:**
92
+ ```bash
93
+ frigg start
94
+ frigg start --stage dev
95
+ frigg start --verbose
96
+ frigg start --frontend
97
+ ```
98
+
99
+ **What it does:**
100
+ 1. Validates DATABASE_URL environment variable
101
+ 2. Detects database type (MongoDB or PostgreSQL)
102
+ 3. Checks Prisma client generation status
103
+ 4. Tests database connection
104
+ 5. Starts serverless-offline for backend
105
+ 6. Optionally starts frontend dev server
106
+
107
+ **Options:**
108
+ - `--stage <stage>` - Deployment stage (default: 'dev')
109
+ - `--verbose` - Enable verbose logging
110
+ - `--frontend` - Also start frontend dev server
111
+ - `--port <port>` - Backend port (default: 3000)
112
+ - `--frontend-port <port>` - Frontend port (default: 3001)
113
+
114
+ **Example Output:**
115
+ ```
116
+ 🚀 Starting Frigg application...
117
+ ✓ DATABASE_URL found
118
+ ✓ Database type: mongodb
119
+ ✓ Prisma client generated
120
+ ✓ Database connection successful
121
+
122
+ Starting backend and optional frontend...
123
+ Starting backend in /Users/dev/my-app/backend...
124
+
125
+ ╔═════════════════════════════════════════════════╗
126
+ ║ ║
127
+ ║ Serverless Offline listening on port 3000 ║
128
+ ║ ║
129
+ ╚═════════════════════════════════════════════════╝
130
+
131
+ endpoints:
132
+ GET - http://localhost:3000/health
133
+ POST - http://localhost:3000/api/authorize
134
+ POST - http://localhost:3000/api/webhook
135
+ ...
136
+ ```
137
+
138
+ **Database Checks:**
139
+ - Validates DATABASE_URL exists and is accessible
140
+ - Determines database type from connection string
141
+ - Verifies Prisma client is generated for the correct database
142
+ - Tests connection with timeout
143
+ - Provides helpful error messages for connection failures
144
+
145
+ ---
146
+
147
+ #### `frigg deploy [options]`
148
+
149
+ Deploy serverless infrastructure to cloud provider.
150
+
151
+ **Usage:**
152
+ ```bash
153
+ frigg deploy
154
+ frigg deploy --stage production
155
+ frigg deploy --region us-west-2
156
+ frigg deploy --force
157
+ frigg deploy --skip-env-validation
158
+ ```
159
+
160
+ **What it does:**
161
+ 1. Loads app definition from index.js
162
+ 2. Validates required environment variables
163
+ 3. Discovers existing cloud resources (VPC, KMS, Aurora, etc.)
164
+ 4. Makes ownership decisions (STACK vs EXTERNAL)
165
+ 5. Generates CloudFormation resources
166
+ 6. Generates serverless.yml configuration
167
+ 7. Executes `osls deploy` with filtered environment
168
+ 8. Creates/updates stack in cloud provider
169
+
170
+ **Options:**
171
+ - `--stage <stage>` - Deployment stage (default: 'dev')
172
+ - `--region <region>` - Cloud provider region (overrides app definition)
173
+ - `--force` - Force deployment even if no changes detected
174
+ - `--skip-env-validation` - Skip environment variable validation warnings
175
+ - `--verbose` - Enable verbose logging
176
+
177
+ **Example Output:**
178
+ ```
179
+ 🔧 Loading environment configuration from appDefinition...
180
+ Found 3 environment variables: DATABASE_URL, JWT_SECRET, STRIPE_API_KEY
181
+
182
+ 🔍 Discovering existing infrastructure...
183
+
184
+ [VPC Builder] Discovering VPC resources...
185
+ Found VPC: vpc-0abc123def456 (existing in AWS)
186
+ 📋 Resource Ownership Decision: external - Using existing VPC vpc-0abc123def456
187
+ [VPC Builder] ✅ VPC configuration completed
188
+
189
+ [KMS Builder] Discovering KMS keys...
190
+ Found KMS key: alias/frigg-my-app-dev
191
+ 📋 Resource Ownership Decision: stack - Will create FriggKMSKey in stack
192
+ [KMS Builder] ✅ KMS configuration completed
193
+
194
+ [Aurora Builder] Discovering Aurora clusters...
195
+ No existing Aurora cluster found
196
+ 📋 Resource Ownership Decision: stack - Will create AuroraCluster in stack
197
+ [Aurora Builder] ✅ Aurora configuration completed
198
+
199
+ 🚀 Deploying serverless application...
200
+
201
+ Deploying my-app to stage dev (us-east-1)
202
+
203
+ Creating CloudFormation stack...
204
+ ✓ Stack created: my-app-dev
205
+ ✓ VPC endpoints configured
206
+ ✓ Aurora cluster created
207
+ ✓ Lambda functions deployed (12)
208
+ ✓ API Gateway configured
209
+ ✓ CloudWatch alarms created
210
+
211
+ Stack Outputs:
212
+ ServiceEndpoint: https://abc123.execute-api.us-east-1.amazonaws.com/dev
213
+ AuroraEndpoint: my-app-dev.cluster-abc123.us-east-1.rds.amazonaws.com
214
+
215
+ Deployment completed in 3m 42s
216
+ ```
217
+
218
+ **Environment Variable Handling:**
219
+ - Passes only necessary environment variables to serverless (security)
220
+ - Includes AWS credentials (AWS_* prefix)
221
+ - Includes app-defined environment variables from definition
222
+ - Validates required variables exist
223
+ - Warns about missing optional variables
224
+
225
+ **Resource Discovery:**
226
+ - Queries CloudFormation for existing stack resources
227
+ - Queries AWS APIs for VPC, subnets, security groups, KMS keys, Aurora clusters
228
+ - Makes intelligent decisions about STACK vs EXTERNAL ownership
229
+ - Uses AUTO logic to minimize user configuration
230
+
231
+ ---
232
+
233
+ #### `frigg db:setup [options]`
234
+
235
+ Initialize database and Prisma configuration.
236
+
237
+ **Usage:**
238
+ ```bash
239
+ frigg db:setup
240
+ frigg db:setup --mongodb
241
+ frigg db:setup --postgresql
242
+ frigg db:setup --generate-only
243
+ ```
244
+
245
+ **What it does:**
246
+ 1. Detects database type from DATABASE_URL or option
247
+ 2. Validates DATABASE_URL format
248
+ 3. Generates Prisma client for the detected database type
249
+ 4. Tests database connection
250
+ 5. Pushes Prisma schema to database (creates tables/collections)
251
+ 6. Runs any pending data migrations
252
+
253
+ **Options:**
254
+ - `--mongodb` - Force MongoDB configuration
255
+ - `--postgresql` - Force PostgreSQL configuration
256
+ - `--generate-only` - Only generate Prisma client, don't push schema
257
+ - `--skip-connection-test` - Skip database connection validation
258
+
259
+ **Example Output:**
260
+ ```
261
+ 🗄️ Setting up database...
262
+ ✓ DATABASE_URL found
263
+ ✓ Database type detected: mongodb
264
+ ✓ Generating Prisma client for mongodb...
265
+ ✓ Prisma client generated successfully
266
+ ✓ Testing database connection...
267
+ ✓ Connection successful
268
+ ✓ Pushing schema to database...
269
+ ✓ Database schema synchronized
270
+
271
+ Database setup complete!
272
+ ```
273
+
274
+ **Error Handling:**
275
+ - Validates DATABASE_URL format for each database type
276
+ - Tests connection before attempting schema push
277
+ - Provides helpful error messages for:
278
+ - Connection timeout
279
+ - Invalid credentials
280
+ - Network issues
281
+ - Schema validation errors
282
+ - Suggests fixes based on error type
283
+
284
+ ---
285
+
286
+ #### `frigg generate <type> <name>`
287
+
288
+ Generate boilerplate code for integrations, handlers, or tests.
289
+
290
+ **Usage:**
291
+ ```bash
292
+ frigg generate integration shopify
293
+ frigg generate handler payment-webhook
294
+ frigg generate test integration-shopify
295
+ ```
296
+
297
+ **What it does:**
298
+ - Creates file structure from templates
299
+ - Generates TypeScript or JavaScript based on project
300
+ - Includes proper imports and exports
301
+ - Follows Frigg framework conventions
302
+ - Updates relevant configuration files
303
+
304
+ **Types:**
305
+ - `integration` - New integration module
306
+ - `handler` - API handler/route
307
+ - `test` - Test file
308
+ - `migration` - Database migration
309
+
310
+ **Options:**
311
+ - `--typescript` - Generate TypeScript files
312
+ - `--javascript` - Generate JavaScript files
313
+ - `--template <name>` - Use specific template
314
+
315
+ **Example Output:**
316
+ ```
317
+ ✨ Generating integration: shopify
318
+
319
+ Created files:
320
+ ✓ backend/integrations/shopify/index.js
321
+ ✓ backend/integrations/shopify/api.js
322
+ ✓ backend/integrations/shopify/config.js
323
+ ✓ backend/integrations/shopify/definition.js
324
+ ✓ backend/integrations/shopify/__tests__/integration.test.js
325
+
326
+ Updated files:
327
+ ✓ backend/index.js (added integration import)
328
+
329
+ Next steps:
330
+ 1. Configure OAuth settings in definition.js
331
+ 2. Implement API methods in api.js
332
+ 3. Add integration to app definition
333
+ 4. Run tests: npm test shopify
334
+ ```
335
+
336
+ ---
337
+
338
+ ### New Infrastructure Health Commands
339
+
340
+ #### `frigg doctor [options]`
341
+
342
+ **Status:** Planned (implementation in progress)
343
+
344
+ Run comprehensive health check on deployed infrastructure.
345
+
346
+ **Usage:**
347
+ ```bash
348
+ frigg doctor
349
+ frigg doctor --stack my-app-prod
350
+ frigg doctor --region us-west-2
351
+ frigg doctor --verbose
352
+ frigg doctor --format json
353
+ ```
354
+
355
+ **What it does:**
356
+ 1. Discovers resources in CloudFormation stack
357
+ 2. Discovers resources in cloud provider (AWS/GCP/Azure)
358
+ 3. Compares desired state (app definition) with actual state
359
+ 4. Detects infrastructure issues:
360
+ - **Orphaned Resources** - Resources exist in cloud but not in stack
361
+ - **Missing Resources** - Resources defined in stack but don't exist
362
+ - **Drifted Resources** - Properties differ between stack and actual
363
+ - **Property Mismatches** - Configuration drift on specific properties
364
+ 5. Calculates health score (0-100)
365
+ 6. Provides actionable remediation suggestions
366
+
367
+ **Options:**
368
+ - `--stack <name>` - CloudFormation stack name (default: from app definition)
369
+ - `--region <region>` - Cloud provider region
370
+ - `--format <format>` - Output format: `table` (default), `json`, `yaml`
371
+ - `--verbose` - Show detailed property comparisons
372
+ - `--check <domain>` - Check specific domain only: `vpc`, `kms`, `aurora`, `all`
373
+ - `--exit-code` - Exit with non-zero code if unhealthy (for CI/CD)
374
+
375
+ **Example Output:**
376
+
377
+ ```
378
+ 🩺 Running infrastructure health check...
379
+
380
+ Stack: my-app-prod (us-east-1)
381
+ Region: us-east-1
382
+ Account: 123456789012
383
+
384
+ ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
385
+ HEALTH SCORE: 65 (degraded)
386
+ ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
387
+
388
+ 📊 Resource Summary
389
+ ✓ 12 resources healthy
390
+ ⚠ 3 resources with warnings
391
+ ✗ 2 critical issues
392
+
393
+ ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
394
+
395
+ 🔴 CRITICAL ISSUES (2)
396
+
397
+ [1] Orphaned Resource
398
+ Type: AWS::RDS::DBCluster
399
+ Physical ID: my-app-prod-aurora-cluster
400
+ Status: ORPHANED
401
+ Issue: Resource exists in AWS but not managed by CloudFormation stack
402
+ Impact: Stack doesn't track this resource. Manual deletion could break app.
403
+
404
+ Resolution: Run 'frigg repair --import' to import into stack
405
+
406
+ [2] Property Mismatch (Immutable)
407
+ Resource: ProductionBucket (AWS::S3::Bucket)
408
+ Property: BucketName
409
+ Expected: my-app-prod-bucket-v2
410
+ Actual: my-app-prod-bucket-v1
411
+ Mutability: IMMUTABLE
412
+ Impact: Requires resource replacement to fix
413
+
414
+ Resolution: Run 'frigg repair --reconcile' to plan replacement
415
+
416
+ ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
417
+
418
+ ⚠️ WARNINGS (3)
419
+
420
+ [1] Property Drift (Mutable)
421
+ Resource: ProdVPC (AWS::EC2::VPC)
422
+ Property: Tags
423
+ Expected: [{"Key": "Environment", "Value": "production"}]
424
+ Actual: [{"Key": "Env", "Value": "prod"}]
425
+ Mutability: MUTABLE
426
+ Impact: Configuration drift - can be auto-fixed
427
+
428
+ Resolution: Run 'frigg repair --reconcile'
429
+
430
+ [2] Property Drift (Mutable)
431
+ Resource: FriggKMSKey (AWS::KMS::Key)
432
+ Property: EnableKeyRotation
433
+ Expected: true
434
+ Actual: false
435
+ Mutability: MUTABLE
436
+ Impact: Key rotation disabled - security risk
437
+
438
+ Resolution: Run 'frigg repair --reconcile'
439
+
440
+ [3] Missing Tag
441
+ Resource: LambdaExecutionRole (AWS::IAM::Role)
442
+ Expected Tag: CostCenter
443
+ Impact: Cost tracking incomplete
444
+
445
+ Resolution: Update app definition and redeploy
446
+
447
+ ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
448
+
449
+ 💡 RECOMMENDATIONS
450
+
451
+ High Priority:
452
+ • Import orphaned Aurora cluster to prevent data loss
453
+ • Plan S3 bucket replacement (requires downtime)
454
+
455
+ Medium Priority:
456
+ • Fix 2 mutable property drifts
457
+ • Enable KMS key rotation for security
458
+
459
+ Low Priority:
460
+ • Add missing tags for cost tracking
461
+
462
+ ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
463
+
464
+ Next steps:
465
+ 1. Review critical issues above
466
+ 2. Run 'frigg repair' to fix detected issues
467
+ 3. Re-run 'frigg doctor' to verify fixes
468
+
469
+ For detailed report: frigg doctor --format json > health-report.json
470
+ ```
471
+
472
+ **JSON Output** (with `--format json`):
473
+ ```json
474
+ {
475
+ "stack": {
476
+ "name": "my-app-prod",
477
+ "region": "us-east-1",
478
+ "accountId": "123456789012"
479
+ },
480
+ "healthScore": 65,
481
+ "assessment": "degraded",
482
+ "summary": {
483
+ "healthy": 12,
484
+ "warnings": 3,
485
+ "critical": 2,
486
+ "total": 17
487
+ },
488
+ "issues": [
489
+ {
490
+ "severity": "critical",
491
+ "type": "orphaned_resource",
492
+ "resource": {
493
+ "type": "AWS::RDS::DBCluster",
494
+ "physicalId": "my-app-prod-aurora-cluster",
495
+ "state": "ORPHANED"
496
+ },
497
+ "description": "Resource exists in AWS but not managed by stack",
498
+ "impact": "Stack doesn't track this resource",
499
+ "resolution": {
500
+ "command": "frigg repair --import",
501
+ "canAutoFix": true
502
+ }
503
+ },
504
+ {
505
+ "severity": "critical",
506
+ "type": "property_mismatch",
507
+ "resource": {
508
+ "logicalId": "ProductionBucket",
509
+ "type": "AWS::S3::Bucket",
510
+ "physicalId": "my-app-prod-bucket-v1"
511
+ },
512
+ "mismatch": {
513
+ "propertyPath": "Properties.BucketName",
514
+ "expected": "my-app-prod-bucket-v2",
515
+ "actual": "my-app-prod-bucket-v1",
516
+ "mutability": "IMMUTABLE"
517
+ },
518
+ "impact": "Requires resource replacement",
519
+ "resolution": {
520
+ "command": "frigg repair --reconcile",
521
+ "canAutoFix": false,
522
+ "requiresReplacement": true
523
+ }
524
+ }
525
+ ],
526
+ "recommendations": [
527
+ {
528
+ "priority": "high",
529
+ "action": "Import orphaned Aurora cluster",
530
+ "reason": "Prevent data loss"
531
+ },
532
+ {
533
+ "priority": "high",
534
+ "action": "Plan S3 bucket replacement",
535
+ "reason": "Requires downtime coordination"
536
+ }
537
+ ],
538
+ "timestamp": "2025-10-26T01:23:45.678Z"
539
+ }
540
+ ```
541
+
542
+ **Exit Codes** (with `--exit-code`):
543
+ - `0` - Healthy (score >= 80)
544
+ - `1` - Degraded (score 40-79)
545
+ - `2` - Unhealthy (score < 40)
546
+ - `3` - Error running health check
547
+
548
+ **Use Cases:**
549
+ - **Pre-deployment validation** - Run before deploy to catch issues
550
+ - **CI/CD health gates** - Fail pipeline if score below threshold
551
+ - **Scheduled audits** - Cron job to monitor infrastructure drift
552
+ - **Incident investigation** - Diagnose production issues
553
+ - **Compliance checks** - Verify security configurations
554
+
555
+ ---
556
+
557
+ #### `frigg repair [options]`
558
+
559
+ **Status:** Planned (implementation in progress)
560
+
561
+ Repair infrastructure issues detected by `frigg doctor`.
562
+
563
+ **Usage:**
564
+ ```bash
565
+ frigg repair # Interactive mode
566
+ frigg repair --import # Import orphaned resources
567
+ frigg repair --reconcile # Fix property mismatches
568
+ frigg repair --clean-deploy # Delete and recreate resources
569
+ frigg repair --auto # Auto-fix all fixable issues
570
+ frigg repair --dry-run # Show what would be fixed
571
+ frigg repair --issue <id> # Fix specific issue only
572
+ ```
573
+
574
+ **What it does:**
575
+
576
+ **Import Mode** (`--import`):
577
+ 1. Discovers orphaned resources (exist in cloud, not in stack)
578
+ 2. Validates resources are importable
579
+ 3. Generates CloudFormation import change set
580
+ 4. Displays resources to be imported
581
+ 5. Confirms with user (unless --auto)
582
+ 6. Executes CloudFormation import operation
583
+ 7. Updates stack to track resources
584
+
585
+ **Reconcile Mode** (`--reconcile`):
586
+ 1. Detects property mismatches (drift)
587
+ 2. Categorizes by mutability:
588
+ - **Mutable** - Can update without replacement
589
+ - **Immutable** - Requires resource replacement
590
+ - **Conditional** - Depends on other properties
591
+ 3. Auto-fixes mutable properties
592
+ 4. Plans replacement for immutable properties
593
+ 5. Prompts for confirmation on destructive changes
594
+ 6. Executes updates via CloudFormation
595
+
596
+ **Clean Deploy Mode** (`--clean-deploy`):
597
+ 1. Identifies resources that can't be imported/reconciled
598
+ 2. Plans deletion of problematic resources
599
+ 3. Generates new resource definitions
600
+ 4. Confirms destructive operation
601
+ 5. Deletes old resources
602
+ 6. Creates new resources via CloudFormation
603
+ 7. Updates application references
604
+
605
+ **Options:**
606
+ - `--import` - Import orphaned resources into stack
607
+ - `--reconcile` - Fix property mismatches
608
+ - `--clean-deploy` - Delete and recreate resources
609
+ - `--auto` - Auto-fix without prompts (for CI/CD)
610
+ - `--dry-run` - Show planned changes without executing
611
+ - `--issue <id>` - Fix only specific issue from doctor report
612
+ - `--force` - Skip safety checks (dangerous!)
613
+ - `--backup` - Create backup before destructive operations
614
+
615
+ **Example Output:**
616
+
617
+ **Interactive Mode:**
618
+ ```
619
+ 🔧 Frigg Repair - Infrastructure Remediation
620
+
621
+ 🩺 Running health check first...
622
+ Found 5 issues to repair:
623
+ • 2 orphaned resources
624
+ • 2 property mismatches (mutable)
625
+ • 1 property mismatch (immutable)
626
+
627
+ ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
628
+
629
+ What would you like to do?
630
+
631
+ [1] Import orphaned resources (2)
632
+ ├─ AWS::RDS::DBCluster - my-app-prod-aurora-cluster
633
+ └─ AWS::EC2::VPC - vpc-0abc123
634
+
635
+ [2] Fix mutable property drift (2) ⚡ Auto-fixable
636
+ ├─ ProdVPC: Tags property mismatch
637
+ └─ FriggKMSKey: EnableKeyRotation mismatch
638
+
639
+ [3] Plan immutable property replacement (1) ⚠️ Requires downtime
640
+ └─ ProductionBucket: BucketName mismatch
641
+
642
+ [4] Fix all auto-fixable issues
643
+ [5] Show detailed repair plan
644
+ [Q] Quit
645
+
646
+ Select option [1-5, Q]:
647
+ ```
648
+
649
+ **After selecting option 1 (Import):**
650
+ ```
651
+ 🔍 Analyzing resources for import...
652
+
653
+ Resources to import:
654
+ ┌──────────────────────────────────────────────────────────────┐
655
+ │ Resource 1: Aurora Database Cluster │
656
+ ├──────────────────────────────────────────────────────────────┤
657
+ │ Type: AWS::RDS::DBCluster │
658
+ │ Physical ID: my-app-prod-aurora-cluster │
659
+ │ Logical ID: AuroraCluster (will be assigned) │
660
+ │ Status: Ready for import │
661
+ │ Properties: Will be matched from existing resource │
662
+ └──────────────────────────────────────────────────────────────┘
663
+
664
+ ┌──────────────────────────────────────────────────────────────┐
665
+ │ Resource 2: VPC │
666
+ ├──────────────────────────────────────────────────────────────┤
667
+ │ Type: AWS::EC2::VPC │
668
+ │ Physical ID: vpc-0abc123 │
669
+ │ Logical ID: ProdVPC (will be assigned) │
670
+ │ Status: Ready for import │
671
+ │ Properties: Will be matched from existing resource │
672
+ └──────────────────────────────────────────────────────────────┘
673
+
674
+ ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
675
+
676
+ ⚠️ IMPORTANT: CloudFormation Import Requirements
677
+
678
+ ✓ Resources must be in a stable state
679
+ ✓ Resources must be importable resource types
680
+ ✓ Stack must be in UPDATE_COMPLETE or CREATE_COMPLETE state
681
+ ✓ Import operation cannot be rolled back
682
+
683
+ ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
684
+
685
+ Proceed with import? [y/N]: y
686
+
687
+ Creating CloudFormation change set for import...
688
+ ✓ Change set created: import-2025-10-26-01-23-45
689
+
690
+ Reviewing change set...
691
+ ✓ Validation passed
692
+
693
+ Executing import operation...
694
+ [████████████████████████████████] 100% - Importing resources
695
+
696
+ ✓ AuroraCluster imported successfully
697
+ ✓ ProdVPC imported successfully
698
+
699
+ Import completed! Resources are now managed by CloudFormation.
700
+
701
+ Next steps:
702
+ • Run 'frigg doctor' to verify health improved
703
+ • Future deploys will manage these resources
704
+ ```
705
+
706
+ **After selecting option 2 (Fix Mutable Drift):**
707
+ ```
708
+ 🔄 Reconciling property mismatches...
709
+
710
+ Planned Updates:
711
+ ┌──────────────────────────────────────────────────────────────┐
712
+ │ Update 1: ProdVPC (AWS::EC2::VPC) │
713
+ ├──────────────────────────────────────────────────────────────┤
714
+ │ Property: Tags │
715
+ │ Current: [{"Key": "Env", "Value": "prod"}] │
716
+ │ Desired: [{"Key": "Environment", "Value": "production"}] │
717
+ │ Impact: No interruption │
718
+ │ Auto-fix: ✓ Yes │
719
+ └──────────────────────────────────────────────────────────────┘
720
+
721
+ ┌──────────────────────────────────────────────────────────────┐
722
+ │ Update 2: FriggKMSKey (AWS::KMS::Key) │
723
+ ├──────────────────────────────────────────────────────────────┤
724
+ │ Property: EnableKeyRotation │
725
+ │ Current: false │
726
+ │ Desired: true │
727
+ │ Impact: No interruption │
728
+ │ Auto-fix: ✓ Yes │
729
+ └──────────────────────────────────────────────────────────────┘
730
+
731
+ ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
732
+
733
+ These changes are safe (no resource replacement required).
734
+
735
+ Proceed with updates? [y/N]: y
736
+
737
+ Applying updates via CloudFormation...
738
+ [████████████████████████████████] 100% - Updating stack
739
+
740
+ ✓ ProdVPC tags updated
741
+ ✓ FriggKMSKey rotation enabled
742
+
743
+ Property drift fixed! Stack now matches desired configuration.
744
+ ```
745
+
746
+ **Dry Run Mode** (`--dry-run`):
747
+ ```
748
+ 🔬 Repair Dry Run - No changes will be made
749
+
750
+ Detected Issues:
751
+ ✓ 2 orphaned resources → Would import via CloudFormation
752
+ ✓ 2 mutable property drifts → Would update properties
753
+ ✗ 1 immutable property drift → Requires manual intervention
754
+
755
+ Planned Actions:
756
+
757
+ [1] Import Resources
758
+ Command: aws cloudformation create-change-set \
759
+ --stack-name my-app-prod \
760
+ --change-set-type IMPORT \
761
+ --resources-to-import file://resources.json
762
+
763
+ [2] Update Properties
764
+ Update: ProdVPC.Tags
765
+ From: [{"Key": "Env", "Value": "prod"}]
766
+ To: [{"Key": "Environment", "Value": "production"}]
767
+
768
+ Update: FriggKMSKey.EnableKeyRotation
769
+ From: false
770
+ To: true
771
+
772
+ [3] Manual Action Required
773
+ Resource: ProductionBucket
774
+ Issue: BucketName is immutable
775
+ Current: my-app-prod-bucket-v1
776
+ Desired: my-app-prod-bucket-v2
777
+
778
+ Resolution steps:
779
+ 1. Create new bucket: my-app-prod-bucket-v2
780
+ 2. Copy data from old bucket to new bucket
781
+ 3. Update application configuration
782
+ 4. Delete old bucket: my-app-prod-bucket-v1
783
+ 5. Update CloudFormation stack
784
+
785
+ ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
786
+
787
+ To execute repairs, run: frigg repair --auto
788
+ To execute specific issue: frigg repair --issue <id>
789
+ ```
790
+
791
+ **Exit Codes:**
792
+ - `0` - Repairs completed successfully
793
+ - `1` - Some repairs failed
794
+ - `2` - Repairs require manual intervention
795
+ - `3` - Error during repair operation
796
+
797
+ **Safety Features:**
798
+ - **Confirmation prompts** for destructive operations
799
+ - **Dry-run mode** to preview changes
800
+ - **Backup creation** before deletions
801
+ - **Rollback support** via CloudFormation
802
+ - **Validation** before import/update
803
+ - **Issue-specific** repair to limit blast radius
804
+
805
+ **Use Cases:**
806
+ - **Import unmanaged resources** - Bring existing infrastructure under CloudFormation management
807
+ - **Fix configuration drift** - Align actual state with desired state
808
+ - **Clean up orphaned resources** - Remove resources outside stack control
809
+ - **Remediate security issues** - Fix misconfigurations automatically
810
+ - **CI/CD integration** - Auto-repair in deployment pipelines
811
+
812
+ ---
813
+
814
+ ## Multi-Cloud Provider Support
815
+
816
+ ### Current Status
817
+ - **AWS**: Fully supported
818
+ - **GCP**: Planned
819
+ - **Azure**: Planned
820
+ - **Cloudflare**: Planned
821
+
822
+ ### Architecture for Multi-Cloud
823
+
824
+ The CLI uses Hexagonal Architecture (Ports & Adapters) to support multiple cloud providers:
825
+
826
+ **Domain Layer** (Provider-Agnostic):
827
+ ```
828
+ packages/devtools/infrastructure/domains/health/
829
+ domain/ # Pure domain logic (no provider specifics)
830
+ entities/ # Resource, Issue, StackHealthReport
831
+ value-objects/ # HealthScore, ResourceState, PropertyMutability
832
+ services/ # HealthScoreCalculator, DriftDetector
833
+
834
+ application/ # Use cases (orchestration)
835
+ use-cases/ # RunHealthCheck, RepairStack, ImportResource
836
+ ports/ # Interfaces for adapters
837
+ StackRepository.js # Port interface
838
+ ResourceDetector.js # Port interface
839
+ DriftDetector.js # Port interface
840
+ ```
841
+
842
+ **Infrastructure Layer** (Provider-Specific Adapters):
843
+ ```
844
+ packages/devtools/infrastructure/domains/health/
845
+ infrastructure/
846
+ adapters/
847
+ aws/ # AWS-specific implementations
848
+ AWSStackRepository.js # CloudFormation
849
+ AWSResourceDetector.js # AWS APIs (EC2, RDS, etc.)
850
+ AWSCloudFormationImporter.js # Import operations
851
+
852
+ gcp/ # GCP-specific implementations (future)
853
+ GCPStackRepository.js # Deployment Manager
854
+ GCPResourceDetector.js # GCP APIs
855
+ GCPDeploymentImporter.js
856
+
857
+ azure/ # Azure-specific implementations (future)
858
+ AzureStackRepository.js # ARM Templates
859
+ AzureResourceDetector.js # Azure APIs
860
+ AzureResourceImporter.js
861
+ ```
862
+
863
+ **Provider Selection**:
864
+ ```javascript
865
+ // App definition specifies provider
866
+ {
867
+ provider: 'aws', // or 'gcp', 'azure', 'cloudflare'
868
+ region: 'us-east-1',
869
+ // ... rest of definition
870
+ }
871
+
872
+ // CLI auto-selects correct adapter
873
+ const adapters = getAdaptersForProvider(appDefinition.provider);
874
+ const useCase = new RunHealthCheckUseCase({
875
+ stackRepository: adapters.stackRepository, // AWS/GCP/Azure
876
+ resourceDetector: adapters.resourceDetector, // Provider-specific
877
+ driftDetector: adapters.driftDetector, // Provider-specific
878
+ });
879
+ ```
880
+
881
+ **Provider-Specific Domains**:
882
+
883
+ Some infrastructure domains are inherently provider-specific:
884
+
885
+ ```
886
+ domains/
887
+ networking/
888
+ vpc-builder.js # AWS VPC
889
+ vnet-builder.js # Azure VNet (future)
890
+ network-builder.js # GCP Network (future)
891
+
892
+ database/
893
+ aurora-builder.js # AWS Aurora
894
+ cloud-sql-builder.js # GCP Cloud SQL (future)
895
+ cosmos-db-builder.js # Azure Cosmos DB (future)
896
+ ```
897
+
898
+ Builder orchestrator selects appropriate builders based on provider:
899
+ ```javascript
900
+ const orchestrator = new BuilderOrchestrator(
901
+ getBuilders(appDefinition.provider) // Returns AWS/GCP/Azure builders
902
+ );
903
+ ```
904
+
905
+ ---
906
+
907
+ ## Environment Variables
908
+
909
+ ### Required (varies by features used)
910
+
911
+ **Database:**
912
+ - `DATABASE_URL` - Connection string for MongoDB or PostgreSQL
913
+
914
+ **AWS Deployment:**
915
+ - `AWS_ACCESS_KEY_ID` - AWS access key
916
+ - `AWS_SECRET_ACCESS_KEY` - AWS secret key
917
+ - `AWS_REGION` - AWS region (or use --region flag)
918
+
919
+ **Encryption:**
920
+ - `KMS_KEY_ARN` - AWS KMS key ARN (or auto-discovered)
921
+ - `AES_KEY_ID` - AES key ID (if using AES encryption)
922
+ - `AES_KEY` - AES encryption key (32 characters)
923
+
924
+ **Optional:**
925
+ - `STAGE` - Deployment stage (default: 'dev')
926
+ - `FRIGG_SKIP_AWS_DISCOVERY` - Skip AWS resource discovery (speeds up local dev)
927
+ - `NODE_ENV` - Node environment (development, production, test)
928
+
929
+ ### App-Defined Variables
930
+
931
+ Additional environment variables can be defined in your app definition:
932
+
933
+ ```javascript
934
+ {
935
+ environment: {
936
+ JWT_SECRET: true, // Mark as required
937
+ STRIPE_API_KEY: true,
938
+ SENDGRID_API_KEY: true,
939
+ FEATURE_FLAG_X: true,
940
+ }
941
+ }
942
+ ```
943
+
944
+ These are validated during deploy and passed to Lambda functions.
945
+
946
+ ---
947
+
948
+ ## Configuration Files
949
+
950
+ ### `index.js` (App Definition)
951
+
952
+ Entry point for your Frigg application:
953
+
954
+ ```javascript
955
+ const { ModuleManager, IntegrationManager } = require('@friggframework/core');
956
+ const HubSpotIntegration = require('@friggframework/api-module-hubspot');
957
+
958
+ const Definition = {
959
+ name: 'my-integration-app',
960
+ version: '1.0.0',
961
+
962
+ provider: 'aws',
963
+ region: 'us-east-1',
964
+
965
+ integrations: [
966
+ {
967
+ Definition: HubSpotIntegration.Definition,
968
+ ownership: {
969
+ queue: 'STACK', // Create queue in CloudFormation
970
+ },
971
+ },
972
+ ],
973
+
974
+ database: {
975
+ type: 'mongodb',
976
+ ownership: 'STACK', // Create Aurora in CloudFormation
977
+ },
978
+
979
+ vpc: {
980
+ ownership: 'EXTERNAL',
981
+ vpcId: 'vpc-0abc123', // Use existing VPC
982
+ },
983
+
984
+ kms: {
985
+ ownership: 'STACK', // Create KMS key in CloudFormation
986
+ },
987
+
988
+ encryption: {
989
+ useDefaultKMSForFieldLevelEncryption: true,
990
+ },
991
+
992
+ environment: {
993
+ DATABASE_URL: true,
994
+ JWT_SECRET: true,
995
+ },
996
+ };
997
+
998
+ module.exports = { Definition };
999
+ ```
1000
+
1001
+ ### `infrastructure.js` (Generated)
1002
+
1003
+ This file is **generated** by the Frigg infrastructure composer and should not be edited manually. It's referenced by `osls deploy` command.
1004
+
1005
+ ---
1006
+
1007
+ ## Architecture Overview
1008
+
1009
+ ```
1010
+ ┌─────────────────────────────────────────────────────────┐
1011
+ │ Frigg CLI Commands │
1012
+ │ • frigg install • frigg deploy • frigg doctor │
1013
+ │ • frigg search • frigg start • frigg repair │
1014
+ │ • frigg generate • frigg db:setup │
1015
+ └───────────────┬─────────────────────────────────────────┘
1016
+
1017
+ ┌───────────────▼─────────────────────────────────────────┐
1018
+ │ Infrastructure Composer │
1019
+ │ packages/devtools/infrastructure/ │
1020
+ │ │
1021
+ │ • Loads app definition (index.js) │
1022
+ │ • Orchestrates domain builders │
1023
+ │ • Generates serverless configuration │
1024
+ └───────────────┬─────────────────────────────────────────┘
1025
+
1026
+ ┌───────────────▼─────────────────────────────────────────┐
1027
+ │ Domain Builders (Hexagonal Architecture) │
1028
+ │ │
1029
+ │ Discovery → Resolution → Building │
1030
+ │ │
1031
+ │ • VpcBuilder (networking) │
1032
+ │ • KmsBuilder (security) │
1033
+ │ • AuroraBuilder (database) │
1034
+ │ • MigrationBuilder (database) │
1035
+ │ • IntegrationBuilder (integration) │
1036
+ │ • SsmBuilder (parameters) │
1037
+ │ • WebsocketBuilder (integration) │
1038
+ └───────────────┬─────────────────────────────────────────┘
1039
+
1040
+ ┌───────────────▼─────────────────────────────────────────┐
1041
+ │ OSS-Serverless (Deployment) │
1042
+ │ • Packages Lambda functions │
1043
+ │ • Generates CloudFormation templates │
1044
+ │ • Deploys to AWS │
1045
+ └─────────────────────────────────────────────────────────┘
1046
+ ```
1047
+
1048
+ ---
1049
+
1050
+ ## Common Workflows
1051
+
1052
+ ### Initial Project Setup
1053
+
1054
+ ```bash
1055
+ # 1. Install integrations
1056
+ frigg install hubspot
1057
+ frigg install stripe
1058
+
1059
+ # 2. Set up database
1060
+ export DATABASE_URL="mongodb://localhost:27017/myapp"
1061
+ frigg db:setup
1062
+
1063
+ # 3. Start local development
1064
+ frigg start --frontend
1065
+
1066
+ # 4. Test integration flows locally
1067
+ # Visit http://localhost:3000
1068
+
1069
+ # 5. Deploy to dev
1070
+ frigg deploy --stage dev
1071
+
1072
+ # 6. Deploy to production
1073
+ frigg deploy --stage production
1074
+ ```
1075
+
1076
+ ### Infrastructure Health Workflow
1077
+
1078
+ ```bash
1079
+ # 1. Check infrastructure health
1080
+ frigg doctor --stage production
1081
+
1082
+ # 2. Review issues (health score, orphaned resources, drift)
1083
+
1084
+ # 3. Fix auto-fixable issues
1085
+ frigg repair --auto
1086
+
1087
+ # 4. Manually fix complex issues
1088
+ frigg repair --issue 3
1089
+
1090
+ # 5. Verify health improved
1091
+ frigg doctor --stage production
1092
+ ```
1093
+
1094
+ ### Troubleshooting Deployment Issues
1095
+
1096
+ ```bash
1097
+ # 1. Enable verbose logging
1098
+ frigg deploy --stage dev --verbose
1099
+
1100
+ # 2. Check for orphaned resources
1101
+ frigg doctor --verbose
1102
+
1103
+ # 3. Import orphaned resources
1104
+ frigg repair --import
1105
+
1106
+ # 4. Retry deployment
1107
+ frigg deploy --stage dev --force
1108
+ ```
1109
+
1110
+ ---
1111
+
1112
+ ## Exit Codes
1113
+
1114
+ All commands follow consistent exit code conventions:
1115
+
1116
+ - `0` - Success
1117
+ - `1` - General error
1118
+ - `2` - Configuration error
1119
+ - `3` - Network/API error
1120
+ - `4` - Validation error
1121
+ - `5` - User cancelled operation
1122
+
1123
+ ---
1124
+
1125
+ ## Getting Help
1126
+
1127
+ ```bash
1128
+ frigg --help # General help
1129
+ frigg <command> --help # Command-specific help
1130
+ frigg --version # Show version
1131
+ ```
1132
+
1133
+ **Community Support:**
1134
+ - GitHub Issues: https://github.com/friggframework/frigg/issues
1135
+ - Documentation: https://docs.friggframework.org
1136
+ - Slack: Join via https://friggframework.org/#contact