# Cost AWS

> Analyzes and reduces AWS spend with Cost Explorer, Budgets, Compute Optimizer, and Cost Optimization Hub CLI queries. Use when working with cost explorer, optimization, cost aws or when the user mentions cost explorer, optimization, cost aws.

- Skill: `opknock/cost-aws` (Agent Skill)
- Install (CLI): `npx get-skill add opknock/cost-aws`
- Raw SKILL.md: https://api.skillmd.com/api/skills/opknock/cost-aws/raw
- Safety review: pending
- Works with: Claude Code, Claude.ai, OpenAI Codex
- Category: DevOps & Infra
- License: MIT
- Author: OpKnock (https://skillmd.com/u/opknock)
- Updated: 2026-11-23
- Page: https://skillmd.com/skills/opknock/cost-aws

---


Analyzes and reduces AWS spend with Cost Explorer, Budgets, Compute Optimizer, and Cost Optimization Hub CLI queries.

## Agentic Workflow: Read -> Reason -> Act (cost-aws)

You are **Cost Aws** (finops/general) — a sub-agent that **Reads, Reasons, and Acts** via `allowed-tools`.

### 1. Read — finops context for `cost-aws`
- Domain: Analyzes and reduces AWS spend with Cost Explorer, Budgets, Compute Optimizer, and Cost Optimization Hub CLI queries.
- **cost-explorer**: Query AWS cost and usage data, forecasts, and reservations via the ce API. — `aws ce get-cost-and-usage --time-period Start=2026-07-01,End=2026-08-01 --granul`
- **optimization**: Find rightsizing and cost optimization recommendations. — `aws cost-optimization-hub list-recommendations --category Compute`
- Check `knowledge` and `prerequisites: aws`

### 2. Reason — think for `cost-aws`
- For `cost-explorer`: Query AWS cost and usage data, forecasts, and reservations via the ce API. — decide which checks to run
- For `optimization`: Find rightsizing and cost optimization recommendations. — decide which checks to run
- Evaluate trust/policy: `kdesk trust` + `kdesk doctor` patterns for your inputs

### 3. Act — execute with `cost-aws` tools
- Tools: `Glob`, `Grep`, `Read`, `Aws` (see frontmatter `tools`/`allowed-tools`)
- Use `safe_path` for any write; record evidence (paths, checksums)
- Fingerprint: `cost-aws:3164efd3`

# AWS Cost Optimization

Find and eliminate AWS waste using native Cost Explorer and optimization APIs.

## When to Use

- Monthly cost review by service or team
- Detecting spend anomalies before they compound
- Rightsizing EC2, RDS, and EBS resources
- Validating reservations and Savings Plans coverage

## Cost exploration

```bash
aws ce get-cost-and-usage --time-period Start=2026-07-01,End=2026-08-01 --granularity DAILY --metrics UnblendedCost --group-by Type=DIMENSION,Key=SERVICE
```

Group by `Type=TAG,Key=team` when your org enforces cost-allocation tags.

## Find savings

```bash
aws cost-optimization-hub list-recommendations --category Compute
aws compute-optimizer get-ec2-instance-recommendations
```

Rightsize only after 14 days of steady-state utilization data; avoid churning on bursty jobs.

## Budgets and alerts

```bash
aws budgets create-budget --account-id 123456789012 --budget file://budget.json --notifications-with-subscribers file://notifications.json
```

Budget JSON example:

```json
{
  "BudgetLimit": {"Amount": "10000", "Unit": "USD"},
  "BudgetName": "monthly-engineering",
  "BudgetType": "COST",
  "TimeUnit": "MONTHLY",
  "TimePeriod": {"Start": "2026-08-01"}
}
```

## Anomaly detection

```bash
aws ce get-anomalies --monitor-arn <monitor-arn> --date-interval Start=2026-07-01
aws ce get-anomaly-monitors
```

## Best practices

- Tag everything; untagged resources are invisible to owners.
- Use Savings Plans for steady compute and Spot for interruptible work.
- Archive old S3 objects with lifecycle policies before buying more storage.
- Review the weekly cost anomaly report and close monitors with known reasons.

## Capabilities

### cost-explorer
Query AWS cost and usage data, forecasts, and reservations via the ce API.

**Parameters:**
- `time-period` (string): Start and end dates in YYYY-MM-DD format
- `granularity` (string): DAILY, MONTHLY, or HOURLY aggregation
- `metrics` (string): Metrics like UnblendedCost, BlendedCost, UsageQuantity

**Commands:**
- `aws ce get-cost-and-usage --time-period Start=2026-07-01,End=2026-08-01 --granularity MONTHLY --metrics UnblendedCost --group-by Type=DIMENSION,Key=SERVICE`
- `aws ce get-cost-forecast --time-period Start=2026-08-01,End=2026-09-01 --metric UNBLENDED_COST --granularity MONTHLY`
- `aws ce get-reservation-coverage --time-period Start=2026-07-01,End=2026-08-01`
- `aws ce get-reservation-utilization --time-period Start=2026-07-01,End=2026-08-01 --granularity DAILY`
- `aws ce get-anomalies --monitor-arn arn:aws:ce::123456789012:anomalymonitor/abc --date-interval Start=2026-07-01`

**Examples:**
- aws ce get-cost-and-usage --time-period Start=2026-07-01,End=2026-08-01 --granularity DAILY --metrics UnblendedCost --group-by Type=TAG,Key=team
- aws ce get-cost-and-usage --time-period Start=2026-07-01,End=2026-08-01 --granularity MONTHLY --metrics UnblendedCost --filter '{"Dimensions":{"Key":"SERVICE","Values":["Amazon Simple Storage Service"]}}'
- aws ce get-cost-forecast --metric UNBLENDED_COST --granularity DAILY

### optimization
Find rightsizing and cost optimization recommendations.

**Parameters:**
- `category` (string): Optimization category: Compute, Storage, License
- `account-ids` (string): AWS account id list to scan
- `implementation-effort` (string): Low, Medium, High effort filter for recommendations

**Commands:**
- `aws cost-optimization-hub list-recommendations --category Compute`
- `aws compute-optimizer get-ec2-instance-recommendations --account-ids 123456789012`
- `aws compute-optimizer get-ebs-volume-recommendations --account-ids 123456789012`
- `aws savingsplans list-savings-plans`
- `aws budgets describe-budgets --account-id 123456789012`

**Examples:**
- aws cost-optimization-hub list-recommendations --category Storage --implementation-effort High | jq '.items[] | {resourceId, estimatedSavings}'
- aws compute-optimizer get-ec2-instance-recommendations | jq '.instanceRecommendations[] | {instanceArn, finding}'
- aws budgets describe-budgets --account-id 123456789012 --budget-type COST

## References
- [AWS Cost Management Docs](https://docs.aws.amazon.com/cost-management/)
- [Compute Optimizer](https://docs.aws.amazon.com/compute-optimizer/)
- [Cost Optimization Hub](https://docs.aws.amazon.com/aws-cost-management/latest/userguide/cost-optimization-hub.html)

