cdk-insights 0.2.0-beta.8 → 0.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -1,57 +1,25 @@
1
1
  # CDK Insights 🔍
2
2
 
3
- > **AI-Powered Analysis Tool for AWS CDK Stacks**
3
+ **AI-powered AWS CDK analysis tool** for developers and teams.
4
+ Scan your AWS CDK stacks for **security vulnerabilities, cost optimization opportunities, and best practice issues**.
5
+ Unlike tools like **cdk-nag**, CDK Insights adds **AI-powered recommendations** for smarter cloud infrastructure improvements.
4
6
 
5
- CDK Insights helps you identify security vulnerabilities, cost optimization opportunities, and best practice issues in your AWS CDK infrastructure. It combines static analysis with AI-powered recommendations to provide actionable insights for improving your cloud infrastructure.
7
+ 👉 Learn more at [cdkinsights.dev](https://cdkinsights.dev)
6
8
 
7
- > **🚧 Currently in Beta** - We're actively developing and improving CDK Insights. The current version is stable for testing and early adoption, but we recommend using it in development environments first.
8
-
9
- ## 🚀 Quick Start (30 Seconds)
10
-
11
- ### Before You Start
12
-
13
- **What You Need:**
14
-
15
- - A CDK project with at least one stack
16
- - Node.js installed
17
- - AWS CDK CLI installed (`npm install -g aws-cdk`)
18
-
19
- **Quick Check:**
20
- Make sure you're in your CDK project directory:
21
-
22
- ```bash
23
- ls -la
24
- # Should see: cdk.json, bin/, lib/ (or src/)
25
- ```
9
+ ---
26
10
 
27
- ### Option 1: Try It Immediately (No Installation)
11
+ ## 🚀 Quick Start
28
12
 
29
13
  ```bash
30
- # Run immediately without installing anything
14
+ # Try it immediately without installing
31
15
  npx cdk-insights scan
32
- ```
33
-
34
- This will:
35
-
36
- 1. Scan your CDK stacks
37
- 2. Show you issues it found
38
- 3. Provide recommendations to fix them
39
16
 
40
- ### Option 2: Install for Your Project (Recommended)
41
-
42
- ```bash
43
- # 1. Install in your project
17
+ # Or install in your project
44
18
  npm install --save-dev cdk-insights
45
-
46
- # 2. Run your first scan (use npx)
47
19
  npx cdk-insights scan
48
20
  ```
49
21
 
50
- **That's it!** CDK Insights will analyze your infrastructure and show you what needs attention.
51
-
52
- ### Adding NPM Scripts for Convenience
53
-
54
- You can add convenience scripts to your `package.json` to make commands shorter:
22
+ You can also add convenience scripts to your `package.json`:
55
23
 
56
24
  ```json
57
25
  {
@@ -61,656 +29,101 @@ You can add convenience scripts to your `package.json` to make commands shorter:
61
29
  "scan:json": "cdk-insights scan --format json",
62
30
  "scan:markdown": "cdk-insights scan --format markdown",
63
31
  "scan:summary": "cdk-insights scan --format summary",
64
- "scan:with-issues": "cdk-insights scan --withIssue"
32
+ "scan:with-issue": "cdk-insights scan --withIssue"
65
33
  }
66
34
  }
67
35
  ```
68
36
 
69
- Then you can run:
70
-
71
- ```bash
72
- npm run scan # Interactive scan
73
- npm run scan:all # Scan all stacks
74
- npm run scan:json # Scan with JSON output
75
- npm run scan:markdown # Scan with Markdown output
76
- npm run scan:summary # Scan with summary output
77
- npm run scan:with-issues # Scan and create GitHub issues
78
- ```
79
-
80
- ## ✨ What CDK Insights Does
81
-
82
- - **🔍 Static Analysis**: Automatically checks your CDK code for 20+ AWS services
83
- - **🤖 AI-Powered Insights**: Gets intelligent recommendations using AWS Bedrock (Pro subscription)
84
- - **📊 Multiple Output Formats**: View results as JSON, Markdown, Table, or Summary
85
- - **🔧 Easy to Use**: Simple CLI with interactive prompts
86
- - **⚙️ Configurable**: Save your preferences and customize what gets analyzed
87
- - **🔗 GitHub Integration**: Create issues directly from findings
88
- - **🛡️ Security Focus**: Comprehensive security checks and recommendations
89
- - **💰 Cost Optimization**: Find opportunities to reduce AWS costs
90
-
91
- ## 📖 How to Use CDK Insights
92
-
93
- ### Basic Commands
94
-
95
- ```bash
96
- # Scan a specific stack
97
- npx cdk-insights scan MyStack
98
-
99
- # Scan all stacks in your project
100
- npx cdk-insights scan --all
101
-
102
- # Interactive mode (recommended for first time)
103
- npx cdk-insights scan
104
- ```
105
-
106
- > **💡 Tip**: After installing CDK Insights, you can use `npx cdk-insights <command>` for all commands. You can also add convenience scripts to your `package.json` (see section above).
107
-
108
- ### What You'll See
109
-
110
- ```
111
- 🔍 Analyzing stack: MyStack
112
- 📊 Found 12 issues across 8 resources
113
-
114
- 🔴 CRITICAL (2)
115
- • IAM policy allows full access to all resources
116
- • S3 bucket allows public ACLs
117
-
118
- 🟡 MEDIUM (7)
119
- • Lambda function has high memory allocation
120
- • DynamoDB table has no auto-scaling enabled
121
-
122
- 🟢 LOW (3)
123
- • S3 bucket does not use Intelligent-Tiering
124
-
125
- ✅ Analysis complete.
126
- ```
127
-
128
- ## 🎯 What Happens Next?
129
-
130
- ### Understanding Your Results
131
-
132
- **Severity Levels:**
133
-
134
- - **🔴 CRITICAL**: Security vulnerabilities or major issues that need immediate attention
135
- - **🟡 MEDIUM**: Issues that should be addressed soon for better security/cost
136
- - **🟢 LOW**: Minor optimizations and best practice recommendations
137
-
138
- ### Common Next Steps
139
-
140
- **1. Fix Critical Issues First**
141
-
142
- ```bash
143
- # Focus on critical security issues
144
- cdk-insights scan --rule-filter Security --output table
145
- ```
146
-
147
- **2. Generate a Report for Your Team**
37
+ Then run: `npm run scan`
148
38
 
149
- ```bash
150
- # Create a markdown report for documentation
151
- cdk-insights scan --output markdown > security-report.md
152
- ```
153
-
154
- **3. Set Up Regular Checks**
39
+ ### Quick Compatibility Check
155
40
 
156
41
  ```bash
157
- # Add to your development workflow
158
- npx cdk-insights scan
159
- ```
160
-
161
- **4. Integrate with CI/CD**
162
-
163
- ```bash
164
- # Fail builds on critical issues
165
- cdk-insights scan --output json --fail-on-critical
166
- ```
167
-
168
- ### Output Formats
169
-
170
- Choose how you want to see your results:
171
-
172
- ```bash
173
- # Table format (default) - great for quick review
174
- cdk-insights scan --output table
175
-
176
- # Markdown format - perfect for GitHub issues and PRs
177
- cdk-insights scan --output markdown
178
-
179
- # JSON format - ideal for CI/CD pipelines
180
- cdk-insights scan --output json
181
-
182
- # Summary format - just the essentials
183
- cdk-insights scan --output summary
184
- ```
185
-
186
- ## 🔍 What Gets Scanned
187
-
188
- CDK Insights checks your infrastructure across these AWS services:
189
-
190
- | Service | What It Checks | Focus Areas |
191
- | ------------------- | ---------------------- | ------------------------------ |
192
- | **IAM** | Policy permissions | Security, Least privilege |
193
- | **S3** | Bucket settings | Security, Cost optimization |
194
- | **Lambda** | Function configuration | Performance, Security |
195
- | **DynamoDB** | Table settings | Cost optimization, Performance |
196
- | **RDS** | Database configuration | Security, Cost optimization |
197
- | **EC2** | Instance settings | Cost optimization, Security |
198
- | **API Gateway** | Endpoint security | Security |
199
- | **CloudTrail** | Logging setup | Security, Compliance |
200
- | **KMS** | Key policies | Security |
201
- | **SNS/SQS** | Message security | Security |
202
- | **Step Functions** | Workflow configuration | Security, Performance |
203
- | **EventBridge** | Rule configuration | Security, Performance |
204
- | **Secrets Manager** | Secret configuration | Security |
205
-
206
- ## 🎯 Common Use Cases
207
-
208
- ### Security Audits
209
-
210
- ```bash
211
- # Focus on security issues
212
- cdk-insights scan --services IAM,S3,KMS,SecretsManager
213
- ```
214
-
215
- ### Cost Optimization
216
-
217
- ```bash
218
- # Find cost savings opportunities
219
- cdk-insights scan --services EC2,DynamoDB,RDS
220
- ```
221
-
222
- ### Before Deployments
223
-
224
- ```bash
225
- # Full scan before going to production
226
- cdk-insights scan --all --output markdown
227
- ```
228
-
229
- ### In Your CI/CD Pipeline
230
-
231
- ```bash
232
- # Automated checks in your deployment process
233
- cdk-insights scan --output json | jq '.summary.totalIssues'
234
- ```
235
-
236
- ## ⚙️ Configuration
237
-
238
- Set your preferences once and CDK Insights will remember them:
239
-
240
- ```bash
241
- # Interactive setup (recommended for first-time users)
242
- cdk-insights config setup
243
- # or
244
- npm run cdk-insights config setup
245
-
246
- # Set your preferred output format
247
- cdk-insights config set output markdown
248
- # or
249
- npm run cdk-insights config set output markdown
250
-
251
- # Set default services to scan
252
- cdk-insights config set services IAM,S3,Lambda
253
- # or
254
- npm run cdk-insights config set services IAM,S3,Lambda
255
-
256
- # View your current settings
257
- cdk-insights config list
258
- # or
259
- npm run cdk-insights config list
260
-
261
- # Clear your settings
262
- cdk-insights config reset
263
- # or
264
- npm run cdk-insights config reset
265
- ```
266
-
267
- ### Configuration File
268
-
269
- CDK Insights stores configuration in `.cdk-insights.json` in your project root:
270
-
271
- ```json
272
- {
273
- "stackName": "MyStack",
274
- "output": "table",
275
- "services": ["IAM", "S3", "Lambda"],
276
- "redact": false,
277
- "withIssue": false,
278
- "summaryOnly": false,
279
- "synth": false,
280
- "ruleFilter": ["Security", "Cost Optimization"],
281
- "failOnCritical": true,
282
- "noCache": false,
283
- "cache": {
284
- "enabled": true,
285
- "ttl": 600000,
286
- "maxSize": 2000
287
- }
288
- }
289
- ```
290
-
291
- ### 📋 Configuration Reference
292
-
293
- | Field | Type | Default | Description |
294
- | ---------------- | -------- | ------- | -------------------------------------------------------- |
295
- | `stackName` | string | "" | Default stack to analyze |
296
- | `output` | string | "table" | Output format: json/table/markdown/summary |
297
- | `services` | string[] | [] | AWS services to scan (comma-separated) |
298
- | `redact` | boolean | false | Redact sensitive resource names in output |
299
- | `withIssue` | boolean | false | Create GitHub issues for findings (markdown output only) |
300
- | `summaryOnly` | boolean | false | Only show summary in console |
301
- | `synth` | boolean | false | Run cdk synth automatically before analysis |
302
- | `ruleFilter` | string[] | [] | Filter rules by category (comma-separated) |
303
- | `failOnCritical` | boolean | true | Exit with error code if critical issues found |
304
- | `noCache` | boolean | false | Disable cache and force fresh analysis |
305
- | `cache.enabled` | boolean | true | Enable/disable caching |
306
- | `cache.ttl` | number | 300000 | Cache TTL in milliseconds (5 minutes) |
307
- | `cache.maxSize` | number | 1000 | Maximum number of cached entries |
308
-
309
- ### Example Configurations
310
-
311
- #### Security-Focused
312
-
313
- ```json
314
- {
315
- "services": ["IAM", "S3", "KMS"],
316
- "ruleFilter": ["Security"],
317
- "output": "markdown",
318
- "withIssue": true,
319
- "failOnCritical": true
320
- }
321
- ```
322
-
323
- #### Performance-Optimized
324
-
325
- ```json
326
- {
327
- "cache": {
328
- "enabled": true,
329
- "ttl": 1800000,
330
- "maxSize": 3000
331
- },
332
- "output": "summary",
333
- "summaryOnly": true
334
- }
335
- ```
336
-
337
- #### CI/CD Pipeline
338
-
339
- ```json
340
- {
341
- "ci": true,
342
- "failOnCritical": true,
343
- "output": "json",
344
- "noCache": true,
345
- "services": ["IAM", "S3", "Lambda"]
346
- }
42
+ node --version # Should be 18+
43
+ ls cdk.json # Should exist in CDK project
347
44
  ```
348
45
 
349
- #### Development Workflow
350
-
351
- ```json
352
- {
353
- "output": "table",
354
- "services": ["All"],
355
- "cache": {
356
- "enabled": true,
357
- "ttl": 600000,
358
- "maxSize": 2000
359
- },
360
- "synth": true
361
- }
362
- ```
363
-
364
- ## 🔗 GitHub Integration
365
-
366
- Create GitHub issues directly from your findings:
367
-
368
- ```bash
369
- # Create issues for all findings (markdown output only)
370
- cdk-insights scan --output markdown --with-issue
371
- # or
372
- npm run cdk-insights scan --withIssue
373
-
374
- # Create issues for critical findings only
375
- cdk-insights scan --output markdown --with-issue --rule-filter Security
376
- ```
377
-
378
- > **Note**: GitHub issue creation is only available with markdown output format.
379
-
380
- ## 🛠️ Available Commands
381
-
382
- ### Analysis Commands
383
-
384
- ```bash
385
- # Main analysis command
386
- npx cdk-insights scan [stackName] [options]
387
-
388
- # Scan all stacks
389
- npx cdk-insights scan --all
390
-
391
- # Different output formats
392
- npx cdk-insights scan --output table|json|markdown|summary
393
-
394
- # Filter by services
395
- npx cdk-insights scan --services IAM,S3,Lambda
396
-
397
- # Create GitHub issues (markdown output only)
398
- npx cdk-insights scan --output markdown --with-issue
399
- ```
400
-
401
- ### Configuration Commands
402
-
403
- ```bash
404
- # List current configuration
405
- npx cdk-insights config list
406
-
407
- # Set configuration values
408
- npx cdk-insights config set <key> <value>
409
-
410
- # Remove configuration values
411
- npx cdk-insights config unset <key>
412
-
413
- # Edit configuration file
414
- npx cdk-insights config edit
415
- ```
416
-
417
- ### Cache Commands
418
-
419
- ```bash
420
- # Show cache status
421
- npx cdk-insights cache-status
422
-
423
- # Clear the cache
424
- npx cdk-insights clear-cache
425
- ```
46
+ ---
426
47
 
427
- ### Cache Configuration
48
+ ## Features — AWS CDK Security & Cost Analysis
428
49
 
429
- CDK Insights uses intelligent caching to speed up analysis. You can configure cache behavior in your `.cdk-insights.json`:
50
+ - 🔍 **Static analysis** across 20+ AWS services (IAM, S3, Lambda, DynamoDB, RDS, EC2, API Gateway, and more)
51
+ - 🤖 **AI-powered recommendations** using AWS Bedrock (Pro & Enterprise tiers)
52
+ - 📊 Multiple output formats: **table**, **JSON**, **Markdown**, or **summary**
53
+ - ⚙️ **Configurable** via `.cdk-insights.json`
54
+ - 🔗 **GitHub integration**: create issues directly from findings
55
+ - 🛡️ **Security checks** for IAM policies, S3 buckets, encryption, secrets, and more
56
+ - 💰 **Cost optimization insights** for EC2, DynamoDB, RDS, and Lambda usage
430
57
 
431
- ```json
432
- {
433
- "cache": {
434
- "enabled": true, // Enable/disable cache (default: true)
435
- "ttl": 600000, // Cache TTL in milliseconds (default: 300000 = 5 minutes)
436
- "maxSize": 2000 // Maximum cache entries (default: 1000)
437
- }
438
- }
439
- ```
58
+ ---
440
59
 
441
- **Cache Features:**
60
+ ## 💡 Usage Examples for AWS CDK Projects
442
61
 
443
- - **Persistent storage** across CLI sessions (non-CI environments only)
444
- - **Deterministic keys** that only change when CDK code changes
445
- - **Automatic invalidation** when resources are modified
446
- - **Performance tracking** with hit rates and statistics
447
- - **CI-safe** - no disk operations in CI environments
62
+ | Scenario | Command Example |
63
+ | ---------------------- | -------------------------------------------------------------------- |
64
+ | Full project scan | `npx cdk-insights scan --all --format summary` |
65
+ | Security-only focus | `npx cdk-insights scan --services IAM,S3,KMS --rule-filter Security` |
66
+ | Markdown report output | `npx cdk-insights scan --format markdown > report.md` |
67
+ | CI/CD pipeline check | `npx cdk-insights scan --format json --fail-on-critical` |
448
68
 
449
- **Cache Options:**
69
+ ---
450
70
 
451
- - `enabled`: Set to `false` to disable caching entirely
452
- - `ttl`: How long cache entries are valid (in milliseconds)
453
- - `maxSize`: Maximum number of cache entries to store
71
+ ## ⚙️ Configuration & Advanced Usage
454
72
 
455
- **Command Line Override:**
73
+ To set default configuration (output format, services, caching, etc.):
456
74
 
457
75
  ```bash
458
- # Force fresh analysis (bypass cache)
459
- npx cdk-insights scan --no-cache
76
+ npx cdk-insights config setup
460
77
  ```
461
78
 
462
- ### Utility Commands
463
-
464
- ```bash
465
- # Reset all configuration
466
- npx cdk-insights reset
467
-
468
- # Setup basic cdk-nag integration (for basic static analysis)
469
- npx cdk-insights setup-cdk-nag
470
-
471
- # Install Git pre-commit hooks
472
- npx cdk-insights hook
473
-
474
- # Synthesize CDK stacks
475
- npx cdk-insights synth [--path <path>]
476
- ```
477
-
478
- ## 📊 Understanding Your Results
479
-
480
- ### Severity Levels
481
-
482
- - **🔴 CRITICAL**: Security vulnerabilities or major issues that need immediate attention
483
- - **🟡 MEDIUM**: Issues that should be addressed soon for better security/cost
484
- - **🟢 LOW**: Minor optimizations and best practice recommendations
485
-
486
- ### Issue Types
487
-
488
- - **Security**: IAM policies, encryption, access controls
489
- - **Cost Optimization**: Resource sizing, unused resources, better pricing models
490
- - **Performance**: Configuration that could impact speed or efficiency
491
- - **Compliance**: Best practices and industry standards
492
-
493
- ## 🛠️ Troubleshooting
494
-
495
- ### Common Issues
496
-
497
- **"No stacks found"**
498
-
499
- - Make sure you're in a CDK project directory
500
- - Run `cdk synth` first to generate CloudFormation templates
501
-
502
- **"Permission denied"**
503
-
504
- - Ensure you have read access to your CDK project files
505
- - Check that your AWS credentials are configured
506
-
507
- **"Scan is slow"**
79
+ ### Enhanced Analysis via CDK Insights Aspect
508
80
 
509
- - Use `--services` to limit what gets scanned
510
- - Try `--output summary` for faster results
81
+ For precise file/line metadata and richer context, add the aspect in your CDK app:
511
82
 
512
- **"Configuration not working"**
513
-
514
- - Check that your `.cdk-insights.json` file is valid JSON
515
- - Use `cdk-insights config list` to see current settings
516
- - Use `cdk-insights config setup` for interactive configuration
517
- - Use `cdk-insights config set <field> --help` for field-specific help
518
- - Use `cdk-insights reset` to clear and start fresh
519
-
520
- **"Invalid configuration value"**
521
-
522
- - Use `cdk-insights config set <field> --help` to see valid values
523
- - Check the [Configuration Reference](#-configuration-reference) table above
524
- - Ensure boolean values are `true`/`false` (not strings)
525
- - Ensure arrays are comma-separated strings or JSON arrays
526
-
527
- **"Cache not working"**
528
-
529
- - Check cache status with `cdk-insights cache-status`
530
- - Verify cache is enabled in your configuration
531
- - Use `--no-cache` flag to bypass cache for testing
532
- - Clear cache with `cdk-insights clear-cache`
533
-
534
- **"Output format issues"**
535
-
536
- - `withIssue` only works with `markdown` output
537
- - `summaryOnly` works with all output formats
538
- - `table` output is best for console display
539
- - `json` output is best for CI/CD integration
540
-
541
- ### Configuration Migration
542
-
543
- If you're upgrading from an older version of CDK Insights, your configuration will be automatically migrated. Here's what changed:
544
-
545
- **New Fields Added:**
546
-
547
- - `failOnCritical`: Controls whether to exit with error code on critical issues
548
- - `noCache`: Disable cache globally
549
- - `cache`: Object with `enabled`, `ttl`, and `maxSize` properties
550
-
551
- **Deprecated Fields:**
552
-
553
- - None currently
554
-
555
- **Migration Steps:**
556
-
557
- 1. Run `cdk-insights config list` to see your current configuration
558
- 2. Use `cdk-insights config setup` to add any new fields interactively
559
- 3. Test your configuration with `cdk-insights scan`
560
- 4. Update CI/CD scripts if using `failOnCritical: true`
561
-
562
- ### Getting Help
563
-
564
- - **Documentation**: [docs/](docs/)
565
- - **Issues**: [GitHub Issues](https://github.com/TheLeePriest/cdk-insights/issues)
566
- - **Discussions**: [GitHub Discussions](https://github.com/TheLeePriest/cdk-insights/discussions)
567
-
568
- ## 🔧 Advanced: Enhanced Analysis with CDK Insights Aspect
569
-
570
- > **For Advanced Users**: This section is for users who want the most detailed analysis possible. The basic scanning above works great for most use cases.
571
-
572
- For the most detailed and accurate analysis, integrate the CDK Insights aspect into your CDK app. This provides enhanced metadata, better source location tracking, and more precise issue identification.
573
-
574
- ### Why Use the CDK Insights Aspect?
575
-
576
- The CDK Insights aspect provides several advantages over basic CDK Nag integration:
577
-
578
- - **🎯 Precise Source Location**: Pinpoints exact file, line, and column where issues occur
579
- - **📊 Enhanced Metadata**: Captures stack names, construct types, and resource relationships
580
- - **🔍 Better Issue Mapping**: Maps CDK constructs to CloudFormation resources accurately
581
- - **📈 Improved Analysis**: Provides richer context for AI-powered recommendations
582
- - **🏷️ Friendly Names**: Generates human-readable resource names for better reporting
583
-
584
- ### Integration Options
585
-
586
- #### Option 1: CDK Insights Aspect (Recommended)
587
-
588
- For the best analysis experience, use the CDK Insights aspect:
589
-
590
- ```typescript
591
- // bin/app.ts
83
+ ```ts
592
84
  import { App, Aspects } from 'aws-cdk-lib';
593
85
  import { CdkInsightsAspect } from 'cdk-insights';
594
86
 
595
87
  const app = new App();
596
-
597
- // Add CDK Insights aspect for enhanced analysis
598
88
  Aspects.of(app).add(new CdkInsightsAspect());
599
-
600
- // Your stacks...
89
+ // define stacks...
601
90
  app.synth();
602
91
  ```
603
92
 
604
- #### Option 2: Basic CDK Nag Integration
605
-
606
- For basic static analysis without enhanced features:
607
-
608
- ```typescript
609
- // bin/app.ts
610
- import { App, Aspects } from 'aws-cdk-lib';
611
- import { AwsSolutionsChecks } from 'cdk-nag';
612
-
613
- const app = new App();
614
-
615
- // Basic CDK Nag integration
616
- Aspects.of(app).add(new AwsSolutionsChecks());
617
-
618
- // Your stacks...
619
- app.synth();
620
- ```
621
-
622
- #### Option 3: Automated Setup
623
-
624
- Use the CLI to automatically set up CDK Nag integration:
625
-
626
- ```bash
627
- # Interactive setup (installs cdk-nag and adds to your app)
628
- cdk-insights setup-cdk-nag
629
- # or
630
- npm run cdk-insights setup-cdk-nag
631
- ```
632
-
633
- ### Comparison: CDK Insights Aspect vs Basic CDK Nag
634
-
635
- | Feature | CDK Insights Aspect | Basic CDK Nag |
636
- | ---------------------- | --------------------------------- | ------------------------- |
637
- | **Source Location** | ✅ Exact file/line/column | ❌ No source tracking |
638
- | **Stack Names** | ✅ Accurate stack identification | ❌ Generic stack names |
639
- | **Construct Types** | ✅ Precise construct mapping | ❌ Limited type info |
640
- | **Friendly Names** | ✅ Human-readable resource names | ❌ Technical resource IDs |
641
- | **Enhanced Metadata** | ✅ Rich context for analysis | ❌ Basic issue reporting |
642
- | **AI Recommendations** | ✅ Better context for AI analysis | ⚠️ Limited context |
643
-
644
- ### Installation for Enhanced Analysis
93
+ ---
645
94
 
646
- 1. **Install CDK Insights in your project**:
95
+ ## 💰 Plans & Pricing
647
96
 
648
- ```bash
649
- npm install --save-dev cdk-insights
650
- ```
97
+ CDK Insights offers flexible tiers:
651
98
 
652
- 2. **Add the aspect to your CDK app**:
99
+ - 🆓 **Free** Basic static scanning & essential checks
100
+ - 🚀 **Pro** — AI-powered insights, unlimited scanning, team features
101
+ - 🏢 **Enterprise** — Advanced compliance, unlimited usage, and dedicated support
653
102
 
654
- ```typescript
655
- // bin/app.ts
656
- import { App, Aspects } from 'aws-cdk-lib';
657
- import { CdkInsightsAspect } from 'cdk-insights';
103
+ 👉 [View full pricing & details →](https://cdkinsights.dev/#pricing)
658
104
 
659
- const app = new App();
660
- Aspects.of(app).add(new CdkInsightsAspect());
105
+ ---
661
106
 
662
- // Your stacks...
663
- app.synth();
664
- ```
107
+ ## 🧰 Requirements
665
108
 
666
- 3. **Synthesize your CDK app**:
109
+ - Node.js 18 or later
110
+ - AWS CDK v2 project
667
111
 
668
- ```bash
669
- cdk synth
670
- ```
112
+ ---
671
113
 
672
- 4. **Run enhanced analysis**:
114
+ ## 📚 Links & Resources
673
115
 
674
- ```bash
675
- npx cdk-insights scan
676
- ```
116
+ - [GitHub Repository & Issues](https://github.com/TheLeePriest/cdk-insights)
117
+ - [Documentation](https://github.com/TheLeePriest/cdk-insights/tree/main/docs)
118
+ - [Pricing & Tiers](https://cdkinsights.dev/#pricing)
119
+ - License: MIT
677
120
 
678
- ### Example: Enhanced Analysis Output
121
+ ---
679
122
 
680
- With the CDK Insights aspect, you'll get more detailed output:
123
+ Start with:
681
124
 
682
125
  ```bash
683
- 🔍 Analyzing stack: MyAppStack
684
- 📊 Found 3 issues with enhanced metadata
685
-
686
- ┌─────────────┬─────────────┬──────────┬─────────────────────┬─────────────────┐
687
- │ Resource │ Stack │ Severity │ Service │ Issue │
688
- ├─────────────┼─────────────┼──────────┼─────────────────────┼─────────────────┤
689
- │ MyFunction │ MyAppStack │ 🔴 HIGH │ Lambda │ Missing VPC │
690
- │ MyBucket │ MyAppStack │ 🟡 MEDIUM│ S3 │ No encryption │
691
- │ MyRole │ MyAppStack │ 🔴 HIGH │ IAM │ Wildcard policy │
692
- └─────────────┴─────────────┴──────────┴─────────────────────┴─────────────────┘
693
-
694
- 📍 Source Locations:
695
- - MyFunction: src/stacks/MyStack.ts:45:12
696
- - MyBucket: src/stacks/MyStack.ts:67:8
697
- - MyRole: src/stacks/MyStack.ts:23:15
126
+ npx cdk-insights scan
698
127
  ```
699
128
 
700
- ## 💰 Pricing & Plans
701
-
702
- CDK Insights offers flexible plans for teams of all sizes:
703
-
704
- - **🆓 Free Tier**: Basic static scanning with essential security checks
705
- - **🚀 Pro Tier**: AI-powered insights, unlimited scanning, and team features
706
- - **🏢 Enterprise**: Advanced compliance, unlimited usage, and dedicated support
707
-
708
- [**View all plans and pricing →**](https://cdkinsights.dev/#pricing)
709
-
710
- ## 📄 License
711
-
712
- CDK Insights is licensed under the MIT License. Some functionality integrates with cdk-nag, which is licensed under Apache License 2.0.
713
-
714
- ---
715
-
716
- **Ready to improve your CDK infrastructure?** Start with `npx cdk-insights scan` and discover what insights await! 🚀
129
+ And explore outputs, configuration, and integrations from there. 🚀
package/dist/cli/entry.js CHANGED
@@ -83185,68 +83185,71 @@ var isGeneratedByCDK = (cdkPath, constructType) => {
83185
83185
  };
83186
83186
  var enrichRecommendations = (originalMap, pathToLogicalId, unifiedResourceMap, stack, resourceIdMetadata) => {
83187
83187
  const manifest = loadManifest("cdk.out");
83188
- return Object.entries(originalMap).reduce((acc, [resourceId, group]) => {
83189
- const cdkPath = Object.keys(pathToLogicalId).find(
83190
- (p3) => pathToLogicalId[p3] === resourceId
83191
- ) ?? group.cdkPath;
83192
- const constructType = unifiedResourceMap[resourceId]?.__constructType ?? stack.Resources[resourceId]?.Type ?? "";
83193
- const githubUrl = resourceIdMetadata[resourceId]?.githubUrl;
83194
- const docUrl = resourceIdMetadata[resourceId]?.docUrl;
83195
- const constructName = resourceIdMetadata[resourceId]?.constructName;
83196
- const isGenerated = isGeneratedByCDK(cdkPath, constructType);
83197
- const displayName = unifiedResourceMap[resourceId]?.displayName;
83198
- const friendlyName = displayName ?? unifiedResourceMap[resourceId]?.__friendlyName ?? cdkPath.split("/").pop() ?? resourceId;
83199
- const locationHint = displayName ?? cdkPath ?? group.locationHint;
83200
- const enhancedFileHint = findEnhancedFileFromPath(manifest, resourceId);
83201
- const allIssues = [
83202
- ...group.sources.cdkInsights.issues,
83203
- ...group.sources.cdkNag.issues
83204
- ].map((issue) => ({
83205
- ...issue,
83206
- locationHint,
83207
- githubUrl,
83208
- docUrl,
83209
- constructName,
83210
- // Add source location if available
83211
- ...enhancedFileHint?.filePath && {
83212
- sourceLocation: {
83213
- filePath: enhancedFileHint.filePath,
83214
- line: enhancedFileHint.line || 1,
83215
- column: enhancedFileHint.column || 1,
83216
- confidence: enhancedFileHint.confidence || "low"
83217
- }
83218
- },
83219
- // Add additional metadata
83220
- stackName: enhancedFileHint?.stackName,
83221
- stackId: enhancedFileHint?.stackName,
83222
- // Using stackName as stackId for now
83223
- timestamp: (/* @__PURE__ */ new Date()).toISOString()
83224
- }));
83225
- const cdkInsightsIssues = allIssues.filter(
83226
- (issue) => issue.foundBy !== "cdkNag"
83227
- );
83228
- const cdkNagIssues = allIssues.filter(
83229
- (issue) => issue.foundBy === "cdkNag"
83230
- );
83231
- acc[resourceId] = {
83232
- ...group,
83233
- resourceId,
83234
- displayName,
83235
- cdkPath,
83236
- friendlyName,
83237
- locationHint,
83238
- constructName,
83239
- githubUrl,
83240
- docUrl,
83241
- isGenerated,
83242
- type: constructType,
83243
- sources: {
83244
- cdkInsights: { issues: cdkInsightsIssues },
83245
- cdkNag: { issues: cdkNagIssues }
83246
- }
83247
- };
83248
- return acc;
83249
- }, {});
83188
+ return Object.entries(originalMap).reduce(
83189
+ (acc, [resourceId, group]) => {
83190
+ const cdkPath = Object.keys(pathToLogicalId).find(
83191
+ (p3) => pathToLogicalId[p3] === resourceId
83192
+ ) ?? group.cdkPath;
83193
+ const constructType = unifiedResourceMap[resourceId]?.__constructType ?? stack.Resources[resourceId]?.Type ?? "";
83194
+ const githubUrl = resourceIdMetadata[resourceId]?.githubUrl;
83195
+ const docUrl = resourceIdMetadata[resourceId]?.docUrl;
83196
+ const constructName = resourceIdMetadata[resourceId]?.constructName;
83197
+ const isGenerated = isGeneratedByCDK(cdkPath, constructType);
83198
+ const displayName = unifiedResourceMap[resourceId]?.displayName;
83199
+ const friendlyName = displayName ?? unifiedResourceMap[resourceId]?.__friendlyName ?? cdkPath.split("/").pop() ?? resourceId;
83200
+ const locationHint = displayName ?? cdkPath ?? group.locationHint;
83201
+ const enhancedFileHint = findEnhancedFileFromPath(manifest, resourceId);
83202
+ const allIssues = [
83203
+ ...group.sources.cdkInsights.issues,
83204
+ ...group.sources.cdkNag.issues
83205
+ ].map((issue) => ({
83206
+ ...issue,
83207
+ locationHint,
83208
+ githubUrl,
83209
+ docUrl,
83210
+ constructName,
83211
+ // Add source location if available
83212
+ ...enhancedFileHint?.filePath && {
83213
+ sourceLocation: {
83214
+ filePath: enhancedFileHint.filePath,
83215
+ line: enhancedFileHint.line || 1,
83216
+ column: enhancedFileHint.column || 1,
83217
+ confidence: enhancedFileHint.confidence || "low"
83218
+ }
83219
+ },
83220
+ // Add additional metadata
83221
+ stackName: enhancedFileHint?.stackName,
83222
+ stackId: enhancedFileHint?.stackName,
83223
+ // Using stackName as stackId for now
83224
+ timestamp: (/* @__PURE__ */ new Date()).toISOString()
83225
+ }));
83226
+ const cdkInsightsIssues = allIssues.filter(
83227
+ (issue) => issue.foundBy !== "cdkNag"
83228
+ );
83229
+ const cdkNagIssues = allIssues.filter(
83230
+ (issue) => issue.foundBy === "cdkNag"
83231
+ );
83232
+ acc[resourceId] = {
83233
+ ...group,
83234
+ resourceId,
83235
+ displayName,
83236
+ cdkPath,
83237
+ friendlyName,
83238
+ locationHint,
83239
+ constructName,
83240
+ githubUrl,
83241
+ docUrl,
83242
+ isGenerated,
83243
+ type: constructType,
83244
+ sources: {
83245
+ cdkInsights: { issues: cdkInsightsIssues },
83246
+ cdkNag: { issues: cdkNagIssues }
83247
+ }
83248
+ };
83249
+ return acc;
83250
+ },
83251
+ {}
83252
+ );
83250
83253
  };
83251
83254
 
83252
83255
  // src/helpers/extractInlineNagFindings/nagToWAFMap.ts
@@ -84693,7 +84696,10 @@ var TerminalOutput = class _TerminalOutput {
84693
84696
  const trialDuration = trialEnd - trialStart;
84694
84697
  const elapsed = now - trialStart;
84695
84698
  const remaining = trialEnd - now;
84696
- const trialProgress = Math.max(0, Math.min(100, elapsed / trialDuration * 100));
84699
+ const trialProgress = Math.max(
84700
+ 0,
84701
+ Math.min(100, elapsed / trialDuration * 100)
84702
+ );
84697
84703
  const trialFilledBars = Math.round(trialProgress / 100 * barWidth);
84698
84704
  const trialEmptyBars = Math.max(0, barWidth - trialFilledBars);
84699
84705
  const trialProgressBar = "\u2588".repeat(trialFilledBars) + "\u2591".repeat(trialEmptyBars);
@@ -89778,10 +89784,13 @@ var runStaticAnalysis = (cloudformationTemplate, createFinding2, selectedService
89778
89784
  const resourceFilter = createResourceFilter(selectedServices);
89779
89785
  const userResources = Object.entries(cloudformationTemplate.Resources || {}).filter(
89780
89786
  ([, cloudFormationResource]) => resourceFilter(cloudFormationResource)
89781
- ).reduce((accumulatedResources, [resourceId, cloudFormationResource]) => {
89782
- accumulatedResources[resourceId] = cloudFormationResource;
89783
- return accumulatedResources;
89784
- }, {});
89787
+ ).reduce(
89788
+ (accumulatedResources, [resourceId, cloudFormationResource]) => {
89789
+ accumulatedResources[resourceId] = cloudFormationResource;
89790
+ return accumulatedResources;
89791
+ },
89792
+ {}
89793
+ );
89785
89794
  for (const serviceName of servicesToAnalyze) {
89786
89795
  try {
89787
89796
  const serviceCheckFunction = serviceChecks[serviceName];
@@ -91909,11 +91918,7 @@ var createGithubIssue = async ({
91909
91918
  if (gistUrl) {
91910
91919
  terminal.githubGistCreated(gistUrl);
91911
91920
  if (recommendations && summary) {
91912
- bodyToWrite = generateMarkdownSummary(
91913
- stackName,
91914
- summary,
91915
- gistUrl
91916
- );
91921
+ bodyToWrite = generateMarkdownSummary(stackName, summary, gistUrl);
91917
91922
  } else {
91918
91923
  const summarySection = issueBody.split("\n---\n")[0];
91919
91924
  bodyToWrite = `${summarySection}
package/dist/index.js CHANGED
@@ -54753,10 +54753,13 @@ var runStaticAnalysis = (cloudformationTemplate, createFinding2, selectedService
54753
54753
  const resourceFilter = createResourceFilter(selectedServices);
54754
54754
  const userResources = Object.entries(cloudformationTemplate.Resources || {}).filter(
54755
54755
  ([, cloudFormationResource]) => resourceFilter(cloudFormationResource)
54756
- ).reduce((accumulatedResources, [resourceId, cloudFormationResource]) => {
54757
- accumulatedResources[resourceId] = cloudFormationResource;
54758
- return accumulatedResources;
54759
- }, {});
54756
+ ).reduce(
54757
+ (accumulatedResources, [resourceId, cloudFormationResource]) => {
54758
+ accumulatedResources[resourceId] = cloudFormationResource;
54759
+ return accumulatedResources;
54760
+ },
54761
+ {}
54762
+ );
54760
54763
  for (const serviceName of servicesToAnalyze) {
54761
54764
  try {
54762
54765
  const serviceCheckFunction = serviceChecks[serviceName];
@@ -57580,7 +57583,10 @@ var TerminalOutput = class _TerminalOutput {
57580
57583
  const trialDuration = trialEnd - trialStart;
57581
57584
  const elapsed = now - trialStart;
57582
57585
  const remaining = trialEnd - now;
57583
- const trialProgress = Math.max(0, Math.min(100, elapsed / trialDuration * 100));
57586
+ const trialProgress = Math.max(
57587
+ 0,
57588
+ Math.min(100, elapsed / trialDuration * 100)
57589
+ );
57584
57590
  const trialFilledBars = Math.round(trialProgress / 100 * barWidth);
57585
57591
  const trialEmptyBars = Math.max(0, barWidth - trialFilledBars);
57586
57592
  const trialProgressBar = "\u2588".repeat(trialFilledBars) + "\u2591".repeat(trialEmptyBars);
@@ -58465,11 +58471,7 @@ var createGithubIssue = async ({
58465
58471
  if (gistUrl) {
58466
58472
  terminal2.githubGistCreated(gistUrl);
58467
58473
  if (recommendations && summary) {
58468
- bodyToWrite = generateMarkdownSummary(
58469
- stackName,
58470
- summary,
58471
- gistUrl
58472
- );
58474
+ bodyToWrite = generateMarkdownSummary(stackName, summary, gistUrl);
58473
58475
  } else {
58474
58476
  const summarySection = issueBody.split("\n---\n")[0];
58475
58477
  bodyToWrite = `${summarySection}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "cdk-insights",
3
- "version": "0.2.0-beta.8",
3
+ "version": "0.4.0",
4
4
  "description": "AWS CDK security and cost analysis tool with AI-powered insights",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",