Common Issues
Troubleshoot common CDK Insights issues. Find solutions for installation problems, analysis failures, and configuration issues.
Quick Diagnostic
Before diving into specific issues, run this quick diagnostic to identify common problems:
# Check prerequisites
node --version && npm --version && aws --version && cdk --version
# Test CDK Insights
npx cdk-insights --help
# Verify CDK app
cdk synthIf any of these commands fail, refer to the specific issue categories below for detailed solutions.
Issues by Category
Installation Issues
โ cdk-insights: command not found
Cause: CDK Insights is not installed or not in PATH
Solution:
- โUse npx to run without installation: npx cdk-insights scan
- โInstall globally: npm install -g cdk-insights
- โInstall as dev dependency: npm install --save-dev cdk-insights
โ Permission denied errors
Cause: Insufficient permissions for global installation
Solution:
- โUse npx instead of global installation
- โFix npm permissions: npm config set prefix ~/.npm-global
- โUse sudo for global install (not recommended)
โ Node.js version compatibility
Cause: Using unsupported Node.js version
Solution:
- โUpdate to Node.js 22 or higher
- โUse nvm to manage Node.js versions
- โCheck compatibility: node --version
Analysis Issues
โ No stacks found to analyze
Cause: CDK app not synthesized or no stacks defined
Solution:
- โRun cdk synth first to generate CloudFormation templates
- โCheck that your CDK app has stacks defined
- โVerify you are in the correct directory
- โUse --synth flag: npx cdk-insights scan --synth
โ CDK synthesis failed
Cause: CDK cannot synthesize templates (missing dependencies or configuration)
Solution:
- โEnsure all CDK dependencies are installed: npm install
- โVerify CDK app is valid: cdk synth
- โCheck for TypeScript compilation errors
- โEnsure AWS credentials are configured
โ AWS credentials not configured
Cause: AWS credentials not set up or expired
Solution:
- โRun aws configure to set up credentials
- โCheck environment variables: AWS_ACCESS_KEY_ID, AWS_SECRET_ACCESS_KEY
- โUse IAM roles if running on EC2
โ Analysis takes too long
Cause: Large CDK app or network issues
Solution:
- โLimit analysis scope: --services S3,IAM
- โUse caching to speed up subsequent runs
- โCheck network connectivity to AWS
Configuration Issues
โ Configuration not being applied
Cause: Invalid JSON or wrong file location
Solution:
- โValidate JSON syntax in .cdk-insights.json
- โEnsure file is in CDK project root directory
- โCheck file permissions and accessibility
โ Unknown configuration option
Cause: Using unsupported configuration option
Solution:
- โCheck documentation for supported options
- โValidate configuration against schema
- โRemove unsupported options
โ Output format not working
Cause: Invalid format specified or missing dependencies
Solution:
- โUse supported formats: table, json, markdown, summary, sarif, github-actions
- โCheck that --output flag is correctly specified
- โVerify file permissions for output files
Systematic Troubleshooting
Check Prerequisites
Verify all required tools are installed and configured
node --version # Should be 18+npm --versionaws --versioncdk --versionVerify CDK App
Ensure your CDK application is properly set up
cdk synth # Should complete without errorsls -la cdk.out # Should contain CloudFormation templatesTest CDK Insights
Run CDK Insights with verbose output
npx cdk-insights scan --help # Check available optionsnpx cdk-insights scan --output json # Test with JSON outputCheck Logs
Review error messages and logs for specific issues
npx cdk-insights scan 2>&1 | tee analysis.logcat analysis.log # Review for specific error messagesPerformance Optimization
Use Caching
Enable caching to speed up subsequent analysis runs
Implementation: CDK Insights automatically caches synthesis results
Limit Scope
Analyze only specific services or stacks when possible
Implementation: Use --services or --stacks flags to limit analysis scope
Parallel Analysis
Use --all flag to analyze multiple stacks in parallel
Implementation: npx cdk-insights scan --all
Skip Synthesis
Skip CDK synthesis if templates are already generated
Implementation: Ensure cdk.out exists before running analysis
Still Need Help?
๐ Additional Resources
๐ฌ Contact Support
- Email Support
Include error logs and system information for faster resolution
Resolved Your Issue?
Great! Now you can focus on analyzing your CDK infrastructure and improving your deployment practices.