finops-cost-optimization
Analyze and optimize AWS costs for cloud-native infrastructure. Use when reviewing monthly AWS spend, right-sizing EC2/EKS node groups, implementing Savings Plans or Reserved Instances, optimizing Bedrock token costs for AI, reducing Data warehouse compute costs, setting up cost allocation tags, configuring AWS Budgets and anomaly detection, or performing cost reviews before large infrastructure changes. Trigger: AWS cost optimization, Savings Plans, Bedrock cost control. Do NOT trigger for: application-level performance optimization unrelated to infrastructure cost.
- License 许可
- MIT
- 最近更新
- 2026-08-27
- Stars
- ★ 1
- Forks
- 0
01 前言 Front Matter
- name
- finops-cost-optimization
- license
- MIT
- metadata
- { "author": "Community", "status": "stable", "version": "1.1", "category": "infrastructure" }
- description
- Analyze and optimize AWS costs for cloud-native infrastructure. Use when reviewing monthly AWS spend, right-sizing EC2/EKS node groups, implementing Savings Plans or Reserved Instances, optimizing Bedrock token costs for AI, reducing Data warehouse compute costs, setting up cost allocation tags, configuring AWS Budgets and anomaly detection, or performing cost reviews before large infrastructure changes. Trigger: AWS cost optimization, Savings Plans, Bedrock cost control. Do NOT trigger for: application-level performance optimization unrelated to infrastructure cost.
02 资源文件 4
- 参考文档evals/evals.json2.8 KB
- 参考文档references/aws-cost-operations.md5.7 KB
- 参考文档references/cost-analysis.md934 B
- 参考文档references/overview.md4.5 KB
03 SKILL.md 正文
FinOps / Cost Optimization
Analyze and optimize AWS infrastructure costs for cloud-native projects.
Cost Attribution (tagging strategy)
# Required tags on ALL AWS resources (enforced via SCP or Terraform)
tags = {
environment = "production" # production | staging | dev
service = "api" # api | inference | apigw | ...
team = "engineering" # team ownership
cost_center = "engineering"
managed_by = "terraform"
}
Top Cost Drivers (generic)
| Service | Cost driver | Optimization |
|---|---|---|
| EKS / EC2 | Oversized nodes, low utilization | Right-size + Spot for non-critical |
| RDS PostgreSQL | Multi-AZ + storage IOPS | Reserved instance 1yr, gp3 storage |
| AWS Bedrock | Token consumption (AI) | Haiku for classification, cache common prompts |
| Data warehouse | Warehouse running idle | Auto-suspend ≤ 1min for AI warehouse |
| Data transfer | Cross-region, NAT gateway | VPC endpoints, S3 Gateway endpoint |
| CloudWatch Logs | Log retention too long | Lifecycle policy: 30d hot, 90d cold (S3) |
Right-Sizing Workflow
# 1. Get CPU/memory utilization for last 30 days
aws cloudwatch get-metric-statistics \
--namespace AWS/EKS \
--metric-name node_cpu_utilization \
--start-time $(date -u -d '30 days ago' +%FT%TZ) \
--end-time $(date -u +%FT%TZ) \
--period 86400 \
--statistics Average
# 2. Use AWS Compute Optimizer recommendations
aws compute-optimizer get-ec2-instance-recommendations \
--filters name=Finding,values=OVER_PROVISIONED
# 3. Apply: change instance type in Terraform, roll nodes
Bedrock Cost Control
# Use model routing based on task complexity
def select_model(task: str) -> str:
CHEAP_TASKS = ["classify_intent", "summarize_short", "validate_sql"]
EXPENSIVE_TASKS = ["generate_complex_sql", "multi_step_analysis"]
if task in CHEAP_TASKS:
return "anthropic.claude-3-haiku-20240307-v1:0" # 10x cheaper
return "anthropic.claude-3-5-sonnet-20241022-v2:0"
# Prompt caching: use cache_control for repeated system prompts
# (Anthropic API — saves 90% on repeated context)
AWS Budgets
resource "aws_budgets_budget" "monthly" {
name = "example-monthly-aws"
budget_type = "COST"
limit_amount = "50000" # USD
limit_unit = "USD"
time_unit = "MONTHLY"
notification {
comparison_operator = "GREATER_THAN"
threshold = 80
threshold_type = "PERCENTAGE"
notification_type = "ACTUAL"
subscriber_email_addresses = ["finops@example.com", "oncall@example.com"]
}
}
resource "aws_ce_anomaly_monitor" "example" {
name = "example-anomaly-monitor"
monitor_type = "DIMENSIONAL"
monitor_dimension = "SERVICE"
}
→ references/overview.md | references/cost-analysis.md | references/aws-cost-operations.md — advanced patterns: pre-deployment estimation, Application Signals, Tag Everything strategy, anomaly detection + forecasting
Cost Operations (pre-deploy and anomaly cadence)
- Pre-deploy estimation: query the aws-pricing MCP before any infrastructure change; record the estimate in the change request (master catalog #57).
- Cost Explorer workflow: run a monthly Cost Explorer review per service; investigate any >10% month-over-month growth before it compounds.
- CloudWatch alarms: alarm on cost anomalies and on spike-prone metrics (data transfer, NAT gateway traffic, Lambda invocations).
- Anomaly cadence: daily anomaly-monitor review, weekly Cost Explorer review, monthly budget re-forecast (master catalog #23).
Constraints
- NEVER deploy infrastructure without cost estimate (terraform plan + aws-pricing MCP)
- NEVER leave Data warehouses running without auto-suspend
- ALWAYS tag ALL resources (untagged resources = unattributable spend)
- ALWAYS set AWS Budgets alert at 80% of monthly target
- ALWAYS use gp3 over gp2 for EBS (same or better perf, 20% cheaper)
- ALWAYS use S3 Gateway VPC endpoint (eliminates NAT gateway cost for S3)
- NEVER use On-Demand for stable, predictable workloads > 1 month
- ALWAYS review Bedrock token spend weekly during AI development
Overview
FinOps combines cultural practice (cost + engineering accountability) with automated cost controls. This skill covers AWS cost attribution via mandatory tagging, right-sizing EC2/EKS, Bedrock token cost optimization through model routing and prompt caching, Data warehouse auto-suspend, anomaly detection via AWS Budgets, and pre-deployment cost estimation using the aws-pricing MCP.
Quick Reference
| Action | Tool/Mechanism | Frequency |
|---|---|---|
| Tag audit | AWS Config + SCP rule | Continuous |
| Right-size EC2/EKS | AWS Compute Optimizer | Monthly |
| Bedrock cost review | CloudWatch + Cost Explorer | Weekly |
| Budget alerts | AWS Budgets (80% threshold) | Monthly |
| Anomaly detection | AWS Cost Anomaly Monitor | Daily |
| Data warehouse cost check | Data warehouse Account Usage views | Daily |
| Pre-deploy estimate | aws-pricing MCP tool |
Every deploy |
Workflow
- Tag every resource — Enforce
environment,service,team,cost_center,managed_bytags via Terraform provider + SCP. Untagged resources trigger auto-remediation. - Set monthly budgets — Create AWS Budget at 80% of forecast. Configure notifications to
finops@example.comandoncall@example.com. - Run Compute Optimizer — Monthly: pull EC2/EKS right-sizing recommendations. Resize under-utilized instances via Terraform PR. Apply Spot for non-critical stateless workloads.
- Optimize Bedrock tokens — Route classification tasks to Haiku, complex analysis to Sonnet. Enable prompt caching for repeated system prompts. Track token spend per model per service.
- Configure auto-suspend — Data warehouse: auto-suspend ≤ 1 minute for AI. RDS: enable Storage Auto Scaling. EBS: gp3 over gp2.
- Review and report — Weekly cost review with team leads. Investigate any >10% MoM increase. Publish cost-per-service dashboard to Grafana.
Anti-patterns
FAIL: Untagged resources deployed without cost attribution.
# BAD: No tags — cost shows as "unknown" in billing reports
resource "aws_instance" "worker" {
ami = "ami-123"
instance_type = "m5.large"
# no tags block
}
# GOOD: Mandatory tags on every resource
resource "aws_instance" "worker" {
tags = {
environment = "production"
service = "inference"
team = "ai-platform"
cost_center = "engineering"
managed_by = "terraform"
}
}
FAIL: Data warehouse running 24/7 for occasional queries.
-- BAD: No auto-suspend → warehouse runs all night for zero queries
ALTER WAREHOUSE analytics_wh SET auto_suspend = 0;
-- GOOD: Auto-suspend after 60 seconds of idle
ALTER WAREHOUSE analytics_wh SET auto_suspend = 60;
FAIL: Using On-Demand for stable, predictable workloads.
BAD: Running production RDS on On-Demand for 18+ months (pays 30-40% premium).
GOOD: Purchase 1-year or 3-year Reserved Instance / Savings Plan for predictable baselines.
FAIL: Ignoring data transfer costs in cost estimates
# BAD: deploying cross-AZ workload without considering transfer costs
resource "aws_lb" "public" {
internal = false # Internet-facing = NAT gateway for private subnets
}
# Cross-AZ: $0.01/GB each direction; NAT Gateway: $0.045/GB + $0.045/hr
# Hidden cost: 10 TB/mo cross-AZ = $100+ unaccounted
# GOOD: co-locate resources within same AZ where possible
resource "aws_lb" "internal" {
internal = true # No NAT needed
}
# Use VPC endpoints (S3 Gateway = free, endpoints = $0.01/hr vs NAT $0.045/hr)
FAIL: Over-provisioned RDS without rightsizing review
# BAD: db.r6g.8xlarge (32 vCPU, 256 GB RAM) running at 15% CPU
resource "aws_db_instance" "main" {
instance_class = "db.r6g.8xlarge"
# No utilization review ever performed
}
# GOOD: start with right-sized instance, monitor, adjust
resource "aws_db_instance" "main" {
instance_class = "db.r6g.2xlarge" # 8 vCPU, 64 GB — 4x cheaper
# Add Performance Insights to validate utilization quarterly
}
# Monthly savings: ~$1,200 → ~$300 (75% reduction at On-Demand rates)
References
| Resource | URL | Last verified |
|---|---|---|
| AWS Well-Architected — Cost Optimization Pillar | https://docs.aws.amazon.com/wellarchitected/latest/cost-optimization-pillar/ | 2026-05-25 |
| FinOps Foundation — Official Framework | https://www.finops.org/framework/ | 2026-05-25 |
| AWS Cost Management User Guide | https://docs.aws.amazon.com/cost-management/latest/userguide/ | 2026-05-25 |
Verification Checklist
- [ ] All AWS resources tagged:
environment,service,team,cost_center,managed_by - [ ] AWS Budget alert configured at 80% of monthly forecast
- [ ] Data warehouse auto-suspend ≤ 1 min for AI workload
- [ ] Bedrock token costs tracked per model per service (Haiku vs Sonnet vs Opus)
- [ ] Cost estimate obtained via
aws-pricingMCP before any infrastructure deploy - [ ] Monthly Compute Optimizer review scheduled for right-sizing
- [ ] Anomaly detection enabled via AWS Cost Anomaly Monitor
Troubleshooting
| [WARN] Known issue | Likely cause | Fix |
|---|---|---|
| Monthly AWS bill exceeds budget by 40% | Untagged resources not attributable; anomaly not detected; right-sizing not done in 6+ months | Run cost attribution per service; enable anomaly monitor; run Compute Optimizer review |
| Data warehouse cost doubled month-over-month | Warehouse running 24/7 without auto-suspend; concurrent warehouse not set | Set auto_suspend = 60 (seconds); use separate warehouses per workload; suspend during idle hours |
| Bedrock token cost unexpectedly high | All tasks routed to Sonnet/Opus; no Haiku for cheap classification | Implement model routing: Haiku for intent classification and validation, Sonnet for complex analysis only |
| Untagged resources appear in billing report | Terraform modules missing mandatory tags; drift from manual creation | Add tags block to all Terraform resources; enforce via SCP; audit quarterly with Config rules |
| Savings Plan utilization drops mid-cycle due to workload shift (known limitation) | Savings Plans are region+instance-family-flexible but cannot be changed after purchase; workload migration invalidates coverage | Use Convertible RIs or Savings Plans with compute scope; right-size and plan workload patterns before purchasing 3-year commitments |
| Savings Plans show low coverage despite active instances | Not all instance families are covered by Savings Plans (e.g., inf1, p4d GPU instances excluded) |
Check pricingModel in Cost Explorer — filter by Coverage; use separate RI for non-covered families like GPU/AI instances |
| Spot instance workload fails during peak hours | Spot interruption rate spikes during high EC2 demand periods; reclamation costs (restart + data re-fetch) exceed On-Demand savings for stateful workloads | Use On-Demand for stateful/transactional workloads; Spot only for stateless batch jobs with checkpointing; set maxPrice to 50% of On-Demand to reduce interruption rate |
04 同仓库更多 Skills
web-browsing-agent-expert
Web browsing for AI agents: driving a headless browser (Playwright, Puppeteer) from agent tooling, navigation and page-state grounding, DOM extraction and structured data capture, form interaction, session and cookie management, anti-bot mitigation awareness, and safe browsing rules (no PII exfiltration, respect robots and terms). Use when building a browsing tool or MCP server for an agent, teaching an agent to navigate and read web pages, extracting structured content from dynamic sites, or handling login walls and pagination in agent workflows. Trigger: web browsing agent, headless browser, Playwright MCP, Puppeteer, browser automation for agents, DOM extraction, page navigation, session management. Do NOT trigger for: end-to-end UI testing of an application (use playwright-expert); writing standalone scraping scripts for data pipelines (use python-expert); fetching a single public URL (use the fetch tool).
vector-databases
Design and operate vector databases for cloud-native AI features. Use when selecting between pgvector, Pinecone, or Weaviate for AI context layer or integration-hub; designing embedding schemas and index parameters; implementing ANN search with metadata filtering; managing embedding model versions; optimizing query latency; or debugging low retrieval quality. Pairs with rag-architecture for pipeline design and postgres-database-expert for pgvector specifics. Trigger: vector database, pgvector, Pinecone, Weaviate, embedding, ANN search, HNSW, cosine similarity. Do NOT trigger for: relational SQL optimization, standard PostgreSQL schema design, Redis caching.
typescript-expert
Full-stack TypeScript stack for modern projects: frontend SSR/CSR with Next.js 14 App Router and React, backend APIs with Node.js (Express/Fastify), state management with Zustand/Redux Toolkit, unit and integration testing with Vitest/Jest + React Testing Library + MSW, and static analysis with ESLint/Prettier/tsc. Use when building React components or hooks, implementing Next.js App Router or Server Components, writing Node.js REST API handlers, implementing middleware (auth, rate-limit, logging), managing client state (Zustand/RTK), writing frontend/backend tests, or running TypeScript linting/type checks. Trigger: TypeScript, Next.js, React, Zustand, Node.js, Express, Fastify, MSW, Vitest. Do NOT trigger for: Python backend development, Go microservices, iOS/mobile development.
tool-usage
Guide correct tool selection, design, and orchestration for AI agents. Use when choosing between dedicated vs Bash tools, designing MCP tool interfaces, naming tool parameters, handling tool response limits, orchestrating parallel vs sequential calls, evaluating tool accuracy, applying ACI design principles, selecting workflow patterns, or reading/filtering/transforming/generating structured data (JSON, YAML, CSV, TOML, XML). Trigger: tool selection, MCP tool design, orchestration, ACI, parallel execution, composite tool, structured data, jq, yq, dasel, mlr, csvkit. Do NOT trigger for: writing application business logic, domain-specific development (route to domain skill), database migrations.
token-efficiency
Enforce token-efficient output, compression, caching, and model routing. Use when calibrating response verbosity, applying compression strategies to logs or RAG chunks, routing tasks to the right model tier, setting thinking budgets, enforcing word limits, compressing context before reinitiation, applying KV-cache ordering, masking tool output observations, or applying clarification-first protocol before irreversible actions. Trigger: token efficiency, compression, model routing, thinking budget, KV-cache, clarification protocol. Do NOT trigger for: non-agent tooling, CI/CD pipeline scripting, infrastructure provisioning.
time-series-db
Time-series database patterns for cloud-native metrics and analytics: TimescaleDB, InfluxDB, and Amazon Timestream selection; continuous aggregates, retention policies, downsampling, and integration with Prometheus/Grafana. Use when storing business metrics over time, building custom business dashboards, designing high-frequency event storage, or querying time-bucketed aggregations. Trigger: time-series, TimescaleDB, InfluxDB, Prometheus, Grafana, hypertable, continuous aggregate, retention policy. Do NOT trigger for: relational PostgreSQL schema design, NoSQL document stores, Kafka event streaming.