This guide gets you from zero to your first Canopy audit in under five minutes.
- Python 3.11+
- AWS credentials — Canopy needs read access to EC2, CloudWatch, and the Pricing API. Configure via
aws configureor exportAWS_ACCESS_KEY_ID/AWS_SECRET_ACCESS_KEY. - (Optional) Electricity Maps API key — set
ELECTRICITY_MAPS_API_KEYfor real-time carbon intensity data. Without it, Canopy falls back to built-in static data for 48 regions.
For audit (read-only):
{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Action": [
"ec2:DescribeInstances",
"ec2:DescribeRegions",
"cloudwatch:GetMetricStatistics",
"pricing:GetProducts"
],
"Resource": "*"
}
]
}For canopy apply (requires write access):
{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Action": [
"ec2:TerminateInstances",
"ec2:StopInstances",
"ec2:StartInstances",
"ec2:ModifyInstanceAttribute"
],
"Resource": "*"
}
]
}git clone https://github.com/mahabubul470/canopy-cloud.git
cd canopy-cloud
python -m venv .venv
source .venv/bin/activate
pip install -e .Verify:
canopy --version
# canopy v0.3.0Before auditing, see which regions are cleanest:
canopy regionsThis shows all 48 AWS + GCP regions ranked by grid carbon intensity, with efficiency tiers:
| Tier | Criteria |
|---|---|
| Platinum | CFE% ≥ 95% or grid intensity ≤ 20 gCO₂/kWh |
| Gold | CFE% ≥ 75% or grid intensity ≤ 100 gCO₂/kWh |
| Silver | CFE% ≥ 50% or grid intensity ≤ 300 gCO₂/kWh |
| Bronze | Everything else |
Filter by provider:
canopy regions --provider aws
canopy regions --provider gcpcanopy audit --provider awsCanopy will:
- Discover all running EC2 instances (across all regions, or a specific one with
--region) - Fetch metrics — 7-day rolling average CPU utilization from CloudWatch
- Estimate cost — via the AWS Pricing API, with a static fallback for 25+ common instance types
- Estimate carbon — using a power model (CPU draw + PUE) multiplied by the region's grid intensity
- Compute EcoWeight — a normalized 0–1+ score blending cost and carbon
- Detect optimizations — idle resources, right-sizing opportunities, and greener regions
- Display results — a ranked table of workloads and a list of recommendations with estimated savings
canopy audit --provider aws --region us-east-1canopy audit --provider aws --output jsonThe audit produces two tables:
Each workload shows:
- Cost/mo — estimated monthly cost in USD
- Carbon/mo — estimated monthly emissions in kg CO₂
- EcoWeight — the combined efficiency score
- Status — Excellent (≤ 0.7), Good (≤ 0.9), Warning (≤ 1.0), Over (≤ 1.2), Critical (> 1.2)
Three types of recommendations:
| Type | Trigger | Action |
|---|---|---|
| IDLE | Avg CPU < 2% over 7 days | Consider terminating the instance |
| RIGHTSIZE | Avg CPU < 15% over 7 days | Downsize to a smaller instance in the same family |
| REGION_MOVE | A same-provider region is 50%+ cleaner | Migrate the workload to the greener region |
Each recommendation includes estimated monthly savings in both dollars and kg CO₂.
For dashboards or compliance:
# JSON report
canopy report --provider aws --output json --out audit-report.json
# CSV report
canopy report --provider aws --output csv --out audit-report.csvThe CSV contains two sections: workload scores and recommendations. Both formats include the full savings summary.
Create canopy.yaml in your project root:
# Weight cost more heavily than carbon
alpha: 0.7
beta: 0.3
# Set budget thresholds
budget_hourly_usd: 5.0
carbon_hourly_gco2: 200.0
# Adjust detection sensitivity
idle_cpu_threshold: 3.0
rightsize_cpu_threshold: 20.0Canopy automatically loads canopy.yaml from:
- The current directory
~/.config/canopy/canopy.yaml
Or pass it explicitly:
canopy audit --config canopy.yamlOnce you've reviewed the audit results, you can act on them:
# Dry run — see what would happen without changing anything
canopy apply --provider aws --dry-run
# Apply with interactive CLI approval (one-by-one)
canopy apply --provider aws
# Skip confirmation (auto-approve all)
canopy apply --provider aws --yes
# Send approval request to Slack instead
canopy apply --provider aws --approval slack
# Create a GitHub issue for approval
canopy apply --provider aws --approval githubThe apply engine supports three actions:
- Terminate idle instances
- Rightsize under-utilized instances (stop, modify type, start)
- Region move — creates a tracking issue (too destructive to automate)
All actions are recorded in the audit log at ~/.config/canopy/audit-log/.
If you installed the dashboard extra (pip install -e ".[dashboard]"):
canopy dashboard --port 8080Open http://localhost:8080 to see:
- Overview cards (workloads, cost, carbon, savings)
- Workload table with EcoWeight scores
- Region carbon intensity chart
- Recent audit log entries
If you installed the MCP extra (pip install -e ".[mcp]"), Canopy exposes tools that LLM hosts (like Claude) can call:
# List available servers
canopy mcp list
# Start a server (communicates over stdio)
canopy mcp serve electricity
canopy mcp serve billing-aws- Phase 4 — ML-based CARL scheduling, multi-cloud policy orchestration, and cost anomaly detection.