Skip to content

Finops

FinOps (Financial Operations) is the practice of bringing financial accountability to the variable spend model of cloud. It enables organizations to make informed decisions about cloud usage and costs.

┌─────────────────────────────────────────────────────────────────┐
│ FinOps Principles │
│ │
│ ┌──────────────────┐ │
│ │ 1. Inform │ ──▶ Visibility into costs │
│ └──────────────────┘ │
│ │ │
│ ▼ │
│ ┌──────────────────┐ │
│ │ 2. Optimize │ ──▶ Right-size resources │
│ └──────────────────┘ │
│ │ │
│ ▼ │
│ ┌──────────────────┐ │
│ │ 3. Operate │ ──▶ Continuous improvement │
│ └──────────────────┘ │
└─────────────────────────────────────────────────────────────────┘
┌─────────────────────────────────────────────────────────────────┐
│ FinOps Lifecycle │
│ │
│ ┌─────────┐ ┌─────────┐ ┌─────────┐ ┌─────────┐ │
│ │ Inform │──▶│ Optimize │──▶│ Operate │──▶│ Inform │ │
│ └─────────┘ └─────────┘ └─────────┘ └─────────┘ │
│ │ │ │ │
│ ▼ ▼ ▼ │
│ ┌─────────┐ ┌─────────┐ ┌─────────┐ │
│ │Cost │ │Rightsizing│ │Budgets │ │
│ │Reporting │ │Reserved │ │Alerts │ │
│ │ │ │Instances │ │ │ │
│ └─────────┘ └─────────┘ └─────────┘ │
│ │
│ ┌─────────┐ ┌─────────┐ ┌─────────┐ │
│ │ Tagging │ │ Spot │ │ Showback│ │
│ │ Policies│ │ Usage │ │ /Chargeback │
│ └─────────┘ └─────────┘ └─────────┘ │
└─────────────────────────────────────────────────────────────────┘
# Required tags policy
required_tags:
- Environment: [dev, staging, prod]
- Team: [platform, payments, analytics]
- CostCenter: [CC-001, CC-002, CC-003]
- Project: [project-name]
- Owner: [email]
# Terraform tagging
locals {
common_tags = {
Environment = var.environment
Team = var.team
CostCenter = var.cost_center
Project = var.project
Owner = var.owner
}
}
resource "aws_instance" "example" {
ami = var.ami_id
instance_type = var.instance_type
tags = merge(local.common_tags, var.extra_tags)
}
# AWS CUR (Cost and Usage Report)
resource "aws_cur_report_definition" "example" {
report_name = "monthly-cost"
time_unit = "HOURLY"
format = "Parquet"
compression_parquet = "SNAPPY"
additional_schema_elements = ["RESOURCES", "SPLIT_COST_ALLOCATION_DATA"]
s3_bucket = aws_s3_bucket.cur.id
s3_prefix = "cur/"
s3_region = "us-east-1"
}
# Lambda function for right-sizing recommendations
import boto3
ce = boto3.client('ce')
def get_rightsize_recommendations():
response = ce.get_rightsizing_recommendations(
Filter={
'CostCategories': {
'Key': 'Environment',
'Values': ['production']
}
},
Service='AmazonEC2',
LookbackPeriodInDays='30',
RecommendationTargetType='SAME_INSTANCE_FAMILY'
)
return response['RightsizingRecommendations']
def generate_report():
recommendations = get_rightsize_recommendations()
for rec in recommendations:
current = rec['CurrentInstance']
target = rec['RecommendedInstances'][0]
print(f"Save {rec['EstimatedMonthlySavings']} by changing")
print(f" {current['InstanceType']} -> {target['InstanceType']}")
# Analyze RI coverage
def analyze_ri_coverage():
response = ce.get_reservation_coverage(
TimePeriod={
'Start': '2024-01-01',
'End': '2024-01-31'
},
Granularity='MONTHLY'
)
for item in response['CoveragesByTime']:
coverage = float(item['Coverage']['CoveragePercentage'])
print(f"RI Coverage: {coverage:.1f}%")
if coverage < 70:
print(" Consider purchasing more Reserved Instances")
# Kubernetes Spot instance configuration
apiVersion: eksctl.io/v1alpha5
kind: ClusterConfig
metadata:
name: my-cluster
region: us-west-2
managedNodeGroups:
- name: on-demand
instanceTypes: [m5.large, m5.xlarge]
desiredCapacity: 3
- name: spot
instanceTypes: [m5n.large, m5.xlarge, m5a.xlarge]
desiredCapacity: 10
capacityType: SPOT
spotAllocationStrategy: capacity-optimized
resource "aws_budgets_budget" "example" {
name = "monthly-budget"
budget_type = "COST"
limit_amount = "10000"
limit_unit = "USD"
time_period_start = "2024-01-01"
time_unit = "MONTHLY"
notification {
comparison_operator = "GREATER_THAN"
threshold = 80
notification_type = "FORECASTED"
subscriber_email_addresses = ["team@example.com"]
}
notification {
comparison_operator = "GREATER_THAN"
threshold = 100
notification_type = "ACTUAL"
subscriber_email_addresses = ["finance@example.com"]
}
}
# Kubecost deployment
apiVersion: helm.cattle.io/v1
kind: HelmChart
metadata:
name: kubecost
namespace: kubecost
spec:
chart: kubecost
repo: https://kubecost.github.io/cost-analyzer
targetNamespace: kubecost
valuesContent: |
kubecostToken: <token>
prometheus:
nodeExporter:
enabled: false
grafana:
enabled: true
-- Query for team cost attribution
SELECT
line_item_usage_account_id as account,
product_product_name as service,
line_item_usage_type as usage_type,
SUM(line_item_unblended_cost) as cost,
resource_tags_user_team as team,
resource_tags_user_environment as environment
FROM aws_cur
WHERE line_item_usage_start_date >= DATE_TRUNC('month', CURRENT_DATE)
GROUP BY 1, 2, 3, 4, 5
ORDER BY cost DESC;
# Cost allocation report
report:
title: "Monthly Infrastructure Cost Report"
period: "January 2024"
summary:
total_cost: 45000
month_over_month_change: -5%
by_service:
- name: EC2
cost: 18000
change: -10%
- name: RDS
cost: 8000
change: 0%
- name: S3
cost: 3000
change: -2%
- name: Lambda
cost: 2000
change: 5%
by_team:
- name: Platform
cost: 15000
percentage: 33%
- name: Payments
cost: 12000
percentage: 27%
- name: Analytics
cost: 10000
percentage: 22%
- name: Other
cost: 8000
percentage: 18%
recommendations:
- action: "Rightsize 5 EC2 instances"
savings: 500
- action: "Purchase RI for stable workloads"
savings: 2000
- action: "Delete unused EBS volumes"
savings: 300
CloudToolPurpose
AWSCost ExplorerCost analysis
AWSBudgetsAlerts and budgets
AWSCost CategoriesCost allocation
AzureCost ManagementCost analysis
AzureReservationsReserved capacity
GCPBillingCost analysis
GCPCommitted UseCommitted use
ToolPurpose
KubecostKubernetes cost monitoring
CloudHealthMulti-cloud management
Spot.ioSpot instance optimization
CloudCheckrCost automation
VirtuosoFinOps platform
# Terraform enforcement
resource "aws_s3_bucket" "example" {
bucket = "my-bucket"
tags = {
Environment = "prod"
Team = "platform"
CostCenter = "CC-001"
}
}
# Always have budgets
resource "aws_budgets_budget" "warning" {
name = "warning-budget"
budget_type = "COST"
limit_amount = "5000"
limit_unit = "USD"
time_unit = "MONTHLY"
notification {
threshold = 75
notification_type = "FORECASTED"
}
}
  • Weekly: Review significant changes
  • Monthly: Full cost review
  • Quarterly: Optimization planning
# Automated rightsizing
def auto_rightsize():
recommendations = get_rightsize_recommendations()
for rec in recommendations:
if rec['SavingsPercentage'] > 20:
# Auto-apply for dev environments
if rec['Environment'] == 'dev':
apply_rightsize(rec)

FinOps enables:

  • Visibility: Understand where money is spent
  • Optimization: Reduce waste and optimize spend
  • Accountability: Teams take ownership of costs
  • Governance: Prevent budget overruns
  • Planning: Better forecasting and budgeting

Key practices:

  • Tagging: Foundation of cost allocation
  • Budgets: Alert before overspending
  • Rightsizing: Match resources to needs
  • Reserved/Spot: Use committed and spot savings
  • Automation: Continuous optimization