Big News: Socket raises $60M Series C at a $1B valuation to secure software supply chains for AI-driven development.Announcement
Sign In

dil-costlens

Package Overview
Dependencies
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

dil-costlens

Estimate & Optimize AWS CDK Costs before you deploy.

latest
npmnpm
Version
0.1.0
Version published
Maintainers
1
Created
Source

CostLens-CDK

Estimate & Optimize AWS CDK Costs before you deploy.

Overview

CostLens-CDK is a developer-first tool to estimate monthly AWS costs for your CDK stacks before deployment. It synthesizes your CDK app, parses the resulting CloudFormation, estimates monthly costs for all major AWS resources, and provides LLM-powered insights. Supports CLI, CI, and PR comments.

Features

  • Supports all major AWS cost resources: EC2, EBS, RDS, Lambda, S3, DynamoDB, ElastiCache, API Gateway, ALB/NLB, NAT Gateway, CloudWatch, ECR, Data Transfer, and more.
  • Live AWS Pricing API integration with fallback to a local catalog for robust, up-to-date pricing.
  • Assumptions file for usage overrides and scenario modeling.
  • LLM-powered insights (local heuristics + Bedrock integration).
  • Beautiful CLI output and CI/PR integration.

Quick Start

1. Install dependencies

npm install

2. Build all packages

npx tsc --build

3. Synthesize your CDK app

cdk synth > cdk.out/template.json

4. Run CostLens-CDK (from built output)

node dist/cli/src/index.js analyze --region us-west-2 --format table

5. Output

  • Beautiful colorized table in the terminal
  • Optional JSON output for CI/automation
  • LLM-powered risk and optimization insights

CLI Usage

npx costlens analyze [options]

Options:

  • --region <region>: AWS region (default: us-east-1)
  • --assumptions <file>: Path to assumptions file (YAML/JSON)
  • --format <fmt>: Output format (table, json, or both)
  • --out <file>: Write JSON output to file
  • --no-free-tier: Ignore AWS free tier
  • --ci: CI mode (for GitHub Actions, etc)

Assumptions File

Override usage patterns for more accurate estimates. Example:

Lambda:
  MyFunction:
    monthlyInvocations: 10000000
    avgMsPerInvoke: 250
S3:
  MyBucket:
    storageGb: 500
    monthlyPutRequests: 100000

LLM Insights

  • Local heuristics flag risky or high-cost resources
  • Optionally integrates with Amazon Bedrock for advanced analysis
  • To enable Bedrock LLM-powered insights, set the environment variable BEDROCK_LLM=1 when running the CLI:
env BEDROCK_LLM=1 aws-vault exec dil-team-hackfest -- node dist/cli/src/index.js analyze --region us-west-2 --format table

If BEDROCK_LLM is not set, only local heuristics will be used for insights.

CI/CD Integration

  • GitHub Actions workflow included for PR cost comments
  • Example: .github/workflows/costlens-pr.yml

Extending the Catalog

  • See packages/pricing/src/catalog.json for fallback prices
  • Add more regions, instance types, or custom pricing as needed

Monorepo Structure

  • packages/core: IR types, parser, estimator
  • packages/pricing: Pricing engine (AWS API + catalog)
  • packages/reporter: CLI table and JSON output
  • packages/cli: CLI entrypoint
  • packages/llm: LLM/risk analysis

Contributing

Pull requests welcome! Please add tests and update documentation as needed.

License

Diligent

FAQs

Package last updated on 22 Aug 2025

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts