AWS Cost Watcher Skill
Yesterday's AWS bill, every morning, with anomalies flagged before they surprise you at end of month.
The Problem
The AWS billing dashboard tells you what happened a week ago. By the time a runaway Lambda or a forgotten EC2 instance shows up in your monthly invoice, it has been burning money for 20+ days. A daily 30-second summary catches these in 1 day, not 30.
How It Works
A scheduled InTouch job runs every morning:
- A
runtimeenvtask runs the AWS CLI'sce get-cost-and-usagefor yesterday plus the trailing 30 days, with your AWS credential injected as env vars - The output JSON is passed to the
aws-cost-watcherskill - AI compares yesterday vs trailing average, flags anomalies, projects month-end
- The
messagetask delivers the digest
Why runtimeenv and not the aws tool
InTouch's aws tool covers EC2, S3, Lambda, RDS, CloudWatch, etc. — but not Cost Explorer (ce). So this skill uses runtimeenv with the standard AWS CLI, which the runtime injects credentials into automatically.
Setup
- Install this skill
- Create an
awscredential with at minimumce:GetCostAndUsagepermission - Make sure a runtime env is installed that has the AWS CLI v2 on its PATH (or install it inside the runtimeenv first run)
- Use the YAML below; schedule for 8am daily
Example YAML Job
name: aws-cost-daily
version: 1.0.0
description: Daily AWS cost summary with anomaly flagging
notifications:
- userNames: [intouch]
alertOnError: true
tasks:
- name: fetch-costs
tool: runtimeenv
properties:
credentialNames: ["aws-readonly"]
scriptContent: |
#!/bin/bash
set -euo pipefail
END=$(date -u +%Y-%m-%d)
YEST=$(date -u -d "yesterday" +%Y-%m-%d)
START=$(date -u -d "30 days ago" +%Y-%m-%d)
echo "=== YESTERDAY ($YEST) ==="
aws ce get-cost-and-usage \
--time-period Start=$YEST,End=$END \
--granularity DAILY \
--metrics UnblendedCost \
--group-by Type=DIMENSION,Key=SERVICE
echo "=== LAST 30 DAYS ==="
aws ce get-cost-and-usage \
--time-period Start=$START,End=$END \
--granularity DAILY \
--metrics UnblendedCost \
--group-by Type=DIMENSION,Key=SERVICE
- name: digest
tool: skill
properties:
skillName: aws-cost-watcher
input: |
monthly_budget: 2500
{{fetch-costs.output}}
- name: send
tool: message
properties:
subject: "AWS daily cost"
body: "{{digest.answer}}"
userNames: "intouch"
Customization
- Multi-account — add an
--profileflag in the script per account, concatenate outputs - Region detail — add
Type=DIMENSION,Key=REGIONto the--group-byfor region-level breakdown - Anomaly threshold — edit SKILL.md (default 25% above 30-day avg, $5 absolute)
- Budget — set the
monthly_budgetline in the skill input, or remove it for "no budget" mode
Cost
- Cost Explorer API: $0.01 per request — at 2 requests/day = ~$0.60/month
- AI assistant: ~$0.005 per digest with Claude Haiku
Roughly $0.75/month, vs the $100s an early-warning catch will save you.