# Cost Estimates & Budgets

`keel cost` estimates an environment's monthly cost from `keel.yml` and a bundled price table. It does not require AWS credentials.

```bash
keel cost                      # this environment's estimate
keel cost --all                # every declared environment
keel cost --json               # machine-readable
keel cost --nat-gb 50 --log-gb 10   # price the usage-driven lines with your own numbers
```

In the dashboard, `$` opens the same estimate as an overlay from any tab.

## What the estimate includes

The estimate covers provisioned baseline costs at the sizes declared in `keel.yml`: Fargate or EC2 task capacity, RDS and ElastiCache instance hours, load balancer and NAT gateway hours, storage, Container Insights, and CodeBuild minutes.

Traffic-dependent costs such as data transfer, NAT processing, log volume, and request counts require usage assumptions that are not present in the config. Keel lists these under **Not included** with their rates. Add estimates with flags such as `--nat-gb`, `--log-gb`, `--transfer-gb`, and `--site-gb`.

Other pricing behavior:

- Autoscaled services are priced from their minimum to maximum capacity.
- Queue-driven services with `min: 0` show zero as the idle floor and call out the wake-up latency; Spot capacity is shown as a range rather than treated as guaranteed availability.
- Disabled schedules appear at $0 along with the cost they would incur if enabled.
- Static sites have no hourly baseline, so their usage rates appear until you pass `--site-gb` or `--site-requests`.
- Sites-only apps exclude infrastructure they do not create, including a VPC, ALB, NAT gateway, and ECR repository. CodeBuild site builds appear separately from container-image builds.
- Missing rates are marked **unpriced** rather than treated as free.
- A separate **Keel itself** section estimates supporting resources, including CodeBuild, ECR storage, account-wide DynamoDB tables, and the state bucket.

Rates are undiscounted list prices, currently verified for **us-east-1**; other regions fall back to those rates and the substitution is always reported. `make prices` regenerates the table offline as a reviewable diff.

## Budgets

```bash
keel cost budget --email you@example.com          # limit derived from the estimate + 40% headroom
keel cost budget --limit 200 --email you@example.com --threshold 50,80,100
keel cost budget-show                             # limit, actual, forecast, alert thresholds
keel cost budget --remove
```

`keel cost budget` creates an AWS Budget filtered by the `App` and `Environment` tags Keel adds to managed resources. By default, it alerts at 80% and 100% of actual spend and at 100% of forecast spend.

**Cost allocation tags must be activated first**
A tag-filtered budget reports no spend until the `App` and `Environment` cost allocation tags are active in the payer account's billing console. Activation is manual, can take up to 24 hours, and is not retroactive. Until then, the budget may incorrectly show zero spend.

AWS Budgets is a global service accessed through us-east-1; Keel handles this regardless of the environment's region.
