Analyzes multi-cloud spending patterns, identifies underutilized resources, reserved capacity opportunities, and provides actionable savings recommendations for AWS, Azure, and GCP
Provides intelligent cost analysis and optimization recommendations across AWS, Azure, and GCP infrastructure. Identifies specific waste patterns and delivers quantified savings opportunities with implementation commands.
Real use cases:
analyze-spend
kilo cloud-cost-optimizer analyze-spend \
--platform <aws|azure|gcp|all> \
--days <integer> \
--output <json|csv|html> \
--threshold <percentage>
Real example: kilo cloud-cost-optimizer analyze-spend --platform all --days 30 --output html --threshold 15
idle-detector
kilo cloud-cost-optimizer idle-detector \
--resource-type <ec2|ebs|elastic-ip|load-balancer|azure-vm|gcp-disk> \
--idle-threshold-hours <integer> \
--region <region-name>
Real example: kilo cloud-cost-optimizer idle-detector --resource-type ec2 --idle-threshold-hours 72 --region us-east-1
reservation-advisor
kilo cloud-cost-optimizer reservation-advisor \
--platform <aws|azure|gcp> \
--term <1-year|3-year> \
--payment-option <all-upfront|partial-upfront|no-upfront> \
--confidence <0.7-0.99>
Real example: kilo cloud-cost-optimizer reservation-advisor --platform aws --term 3-year --payment-option partial-upfront --confidence 0.85
right-size-recommendations
kilo cloud-cost-optimizer right-size-recommendations \
--platform <aws|azure|gcp> \
--metric <cpu|memory|network|all> \
--utilization-threshold <0.1-0.5> \
--instance-family <specific-family>
Real example: kilo cloud-cost-optimizer right-size-recommendations --platform aws --metric cpu --utilization-threshold 0.2
storage-analyzer
kilo cloud-cost-optimizer storage-analyzer \
--service <s3|azure-blob|gcp-storage> \
--bucket <bucket-name> \
--days-access <integer> \
--transition-to <standard|ia|archive>
Real example: kilo cloud-cost-optimizer storage-analyzer --service s3 --bucket my-app-logs --days-access 90 --transition-to ia
tag-compliance
kilo cloud-cost-optimizer tag-compliance \
--required-tags <comma-separated> \
--platform <aws|azure|gcp> \
--resource-types <comma-separated>
Real example: kilo cloud-cost-optimizer tag-compliance --required-tags Environment,Owner,Project --platform aws --resource-types ec2,s3,lambda
forecast-spend
kilo cloud-cost-optimizer forecast-spend \
--platform <aws|azure|gcp> \
--days <30|60|90> \
--include-commitments <true|false>
Real example: kilo cloud-cost-optimizer forecast-spend --platform aws --days 30 --include-commitments true
# Set environment variables (loaded from ~/.openclaw/config/ext/custom-overrides.json)
export AWS_ACCESS_KEY_ID="AKIAIOSFODNN7EXAMPLE"
export AWS_SECRET_ACCESS_KEY="wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY"
export AWS_DEFAULT_REGION="us-east-1"
export AZURE_SUBSCRIPTION_ID="12345678-1234-1234-1234-123456789012"
export GCP_PROJECT_ID="my-project-123456"
export COST_THRESHOLD_DAYS=30
Multi-cloud spending analysis:
kilo cloud-cost-optimizer analyze-spend \
--platform all \
--days 30 \
--output json \
--threshold 15 > cost-analysis-$(date +%Y%m%d).json
Idle EC2 detection:
kilo cloud-cost-optimizer idle-detector \
--resource-type ec2 \
--idle-threshold-hours 168 \
--region us-east-1 \
--output csv > idle-ec2-us-east-1-$(date +%Y%m%d).csv
Reservation recommendations:
kilo cloud-cost-optimizer reservation-advisor \
--platform aws \
--term 3-year \
--payment-option partial-upfront \
--confidence 0.85 > reservations-recommendations-$(date +%Y%m%d).txt
After receiving recommendations:
Before changes:
# Capture baseline
aws cloudwatch get-metric-statistics --namespace AWS/EC2 --metric-name CPUUtilization --start-time $(date -d '7 days ago' -Iseconds) --end-time $(date -Iseconds) --period 86400 --statistics Average
az monitor metrics list --resource <resource-id> --metric "Percentage CPU" --interval PT1H
gcloud monitoring time-series list --filter='metric.type="compute.googleapis.com/instance/cpu/utilization"' --project=$GCP_PROJECT_ID
After changes:
# Wait 24-48 hours, then compare costs
kilo cloud-cost-optimizer analyze-spend --platform aws --days 2 --output json | jq '.total_savings_expected'
--dry-run flag first, verify metrics manually, implement deletion schedule with 48-hour grace periodCostOptimized=true and OptimizationDate=YYYY-MM-DD, create AWS Config rules to prevent deletion of tagged resourcesaws ec2 describe-reserved-instances-offerings has capacity in target region, Azure az vm reservation list shows availabilityaws ec2 describe-reserved-instances --filters Name=scope,Values=Availability Zone matches actual deployment zones before purchaseaws resourcegroupstaggingapi get-resources to ensure no resources orphaned without required tagsExample 1: Detect unattached EBS volumes
$ kilo cloud-cost-optimizer idle-detector --resource-type ebs --idle-threshold-hours 24 --region us-west-2
Found 47 unattached EBS volumes in us-west-2:
- vol-0a1b2c3d4e5f6g7h8 (100 GiB, gp3) - $10.30/month, unattached for 15 days
- vol-1a2b3c4d5e6f7g8h9 (500 GiB, io2) - $75.00/month, unattached for 89 days
Total potential savings: $2,467/month
# Implementation command (review first):
aws ec2 delete-volume --volume-id vol-0a1b2c3d4e5f6g7h8
Example 2: Reserved instance purchase recommendation
$ kilo cloud-cost-optimizer reservation-advisor --platform aws --term 1-year --payment-option all-upfront
Based on 90-day usage analysis:
Instance: m5.large (2 vCPU, 8 GiB)
Current on-demand spend: $1,872/year
1-year All Upfront RI: $1,125 (40% savings)
Savings: $747/year
Risk: Low (95% utilization consistency)
Purchase command:
aws ec2 purchase-reserved-instances-offering \
--reserved-instances-offering-id 1234abcd-12ab-34cd-56ef-1234567890ab \
--instance-count 3 \
--dry-run
Example 3: EC2 right-sizing analysis
$ kilo cloud-cost-optimizer right-size-recommendations --platform aws --metric cpu --utilization-threshold 0.15
Instance: i-0a1b2c3d4e5f6g7h8 (m5.xlarge)
Avg CPU: 8% (max 12%)
Avg Memory: 4.2 GiB / 16 GiB (26%)
Current cost: $196/month
Recommended: m5.large ($98/month)
Savings: $98/month
Confidence: 97% (based on 30-day metrics)
Downgrade command:
aws ec2 modify-instance-attribute --instance i-0a1b2c3d4e5f6g7h8 --instance-type m5.large
Example 4: S3 storage class transition
$ kilo cloud-cost-optimizer storage-analyzer --service s3 --bucket prod-backups --days-access 180
Bucket: prod-backups (2.4 TB total)
Objects not accessed in 180+ days: 1.8 TB (75%)
Current cost: $55/month (Standard)
After transition to Intelligent-Tiering: $33/month
Savings: $22/month ($264/year)
Batch transition command (dry-run first):
aws s3 cp s3://prod-backups s3://prod-backups --storage-class INTELLIGENT_TIERING --recursive --dryrun
Example 5: Multi-cloud cost anomaly detection
$ kilo cloud-cost-optimizer analyze-spend --platform all --days 7 --threshold 25
AWS: EC2 costs increased 34% ($2,100 → $2,814)
Root cause: New m5.8xlarge instance launched 2024-01-15
Action: Verify instance necessity, right-size or terminate
Azure: Storage costs increased 67% ($450 → $752)
Root cause: Premium SSD provisioned for dev environment
Action: Convert to Standard SSD
GCP: Compute Engine costs stable, BigQuery costs increased 22%
Root cause: Unoptimized queries in analytics pipeline
Action: Implement partitioned tables, add WHERE clauses
Total unexpected spend: $1,216
If idle resource deletion was incorrect:
# AWS - Restore deleted EBS volume (if snapshot exists)
aws ec2 create-volume --snapshot-id snap-0a1b2c3d4e5f6g7h8 --availability-zone us-east-1a
# Azure - Recreate deleted VM from latest snapshot
az vm create --resource-group my-group --name my-vm --attach-os-disk my-vm-osdisk --os-type linux
# GCP - Restore deleted persistent disk
gcloud compute disks create my-disk --source-snapshot my-snapshot --zone us-central1-a
If right-sizing caused performance issues:
# AWS - Revert instance type
aws ec2 modify-instance-attribute --instance i-0a1b2c3d4e5f6g7h8 --instance-type m5.xlarge
# Azure - Change VM size back
az vm resize --resource-group my-group --name my-vm --size Standard_D4s_v3
# GCP - Update machine type
gcloud compute instances set-machine-type my-instance --machine-type n1-standard-4 --zone us-central1-a
If reserved instance purchase was wrong:
# AWS - Cancel RI within 5 years (prorated refund)
aws ec2 modify-reserved-instances --reserved-instances-ids 1234abcd-5678-... --instance-count 1
# Azure - Exchange RI (if within 5 years)
az vm reservation exchange --reservation-order-id 11111111-1111-1111-1111-111111111111 --reservation-id 22222222-2222-2222-2222-222222222222
# GCP - Cancel commitment (minimum 1 year)
gcloud compute commitments remove-iam-policy-binding my-commitment --member='user:[email protected]' --role='roles/compute.viewer'
If storage transition errors occurred:
# Restore S3 objects from Standard-IA to Standard (within 30 days)
aws s3 copy s3://my-bucket/key s3://my-bucket/key --storage-class STANDARD --metadata-directive COPY
# Restore Azure blob from Archive (requires rehydration, 1-15 hours)
az storage blob rehydrate --container-name mycontainer --name myblob --tier Hot
# Restore GCP Nearline/Coldline to Standard (7-day minimum retention)
gsutil rewrite -s standard gs://my-bucket/gs://my-bucket/**
Complete rollback (undo all optimizations in last 24 hours):
# Generate rollback script from audit log
kilo cloud-cost-optimizer generate-rollback --since "24 hours ago" --platform all --output rollback-$(date +%Y%m%d-%H%M%S).sh
# Execute rollback with confirmation
bash rollback-$(date +%Y%m%d-%H%M%S).sh --dry-run
bash rollback-$(date +%Y%m%d-%H%M%S).sh --execute
Restore from backup before optimization:
# If pre-optimization backup created
kilo cloud-cost-optimizer restore-state --backup-file /backups/cloud-state-$(date -d 'yesterday' +%Y%m%d).json --region all
Issue: "InvalidClientTokenId" from AWS CLI
aws sts get-caller-identityAWS_ACCESS_KEY_ID and AWS_SECRET_ACCESS_KEY are correct, not expired, have required IAM permissions (ce:GetCostAndUsage, ec2:Describe*, s3:ListAllMyBuckets)Issue: "SubscriptionNotRegistered" from Azure CLI
az account showAZURE_SUBSCRIPTION_ID matches active subscription, run az account set --subscription $AZURE_SUBSCRIPTION_ID, register required providers: az provider register --namespace Microsoft.CostManagementIssue: "Permission denied" on GCP
gcloud auth listgcloud auth activate-service-account --key-file=$GOOGLE_APPLICATION_CREDENTIALS, ensure service account has roles: roles/billing.viewer, roles/compute.viewer, roles/storage.objectViewerIssue: No data returned for analysis
Issue: High false-positive rate on idle detection
--idle-threshold-hours matches business cycle (weekends vs weekdays), validate CloudWatch metrics have sufficient granularity--metric-average-period 300 for 5-minute granularity, cross-reference with application logs before terminationAfter any optimization cycle, verify:
0 6 * * 1 kilo cloud-cost-optimizer analyze-spend --platform all --days 7 --output html > /reports/cost-$(date +\%Y\%m\%d).html# AWS CLI v2
curl "https://awscli.amazonaws.com/awscli-exe-linux-x86_64.zip" -o "awscliv2.zip"
unzip awscliv2.zip
sudo ./aws/install
# Azure CLI
curl -sL https://aka.ms/InstallAzureCLIDeb | sudo bash
# GCloud SDK
curl -O https://dl.google.com/dl/cloudsdk/channels/rapid/downloads/google-cloud-cli-467.0.0-linux-x86_64.tar.gz
tar -xf google-cloud-cli-*.tar.gz
./google-cloud-sdk/install.sh
# Python dependencies
pip3 install --user pandas matplotlib
JSON:
{
"timestamp": "2024-01-20T14:30:00Z",
"platform": "aws",
"total_monthly_savings": 4523.67,
"recommendations": [
{
"type": "idle_resource",
"resource_id": "vol-0a1b2c3d4e5f6g7h8",
"region": "us-east-1",
"monthly_cost": 10.30,
"action": "delete",
"confidence": "high",
"justification": "Unattached for 15 days, no attachment history"
}
]
}
CSV:
type,resource_id,region,monthly_cost,action,confidence
idle_resource,vol-0a1b2c3d4e5f6g7h8,us-east-1,10.30,delete,high
rightsizing,i-0a1b2c3d4e5f6g7h8,us-west-2,196.00,m5.large,medium
reservation,m5.large,us-east-1,747.00,1-year-all-upfront,high
HTML (with embedded charts): Interactive dashboard with savings by category, time series trends, implementation progress tracker
GitHub Actions workflow: