| name | finops-expert |
| version | 1.0.0 |
| description | Expert-level cloud financial operations, cost optimization, and cloud economics |
| category | professional |
| tags | ["finops","cloud-cost","optimization","cloud-economics","aws-cost"] |
| allowed-tools | ["Read","Write","Edit","Bash(*)"] |
FinOps Expert
Expert guidance for cloud financial operations, cost optimization, resource management, and cloud economics.
Core Concepts
FinOps Fundamentals
- Cloud cost visibility
- Usage optimization
- Rate optimization
- Architecture optimization
- Cloud unit economics
- Showback and chargeback
Cost Management
- Reserved Instances (RIs)
- Savings Plans
- Spot instances
- Right-sizing resources
- Idle resource cleanup
- Storage lifecycle policies
FinOps Practices
- Tagging strategies
- Budgets and alerts
- Cost allocation
- Forecasting and planning
- Cross-team collaboration
- Continuous optimization
AWS Cost Analysis
import boto3
from datetime import datetime, timedelta
from typing import Dict, List
import pandas as pd
class AWSCostAnalyzer:
"""Analyze AWS costs using Cost Explorer API"""
def __init__(self):
self.ce_client = boto3.client('ce')
def get_cost_and_usage(self, start_date: str, end_date: str,
granularity: str = 'DAILY',
metrics: List[str] = None) -> Dict:
"""Get cost and usage data"""
if metrics is None:
metrics = ['UnblendedCost', 'UsageQuantity']
response = self.ce_client.get_cost_and_usage(
TimePeriod={
'Start': start_date,
'End': end_date
},
Granularity=granularity,
Metrics=metrics,
GroupBy=[
{'Type': 'DIMENSION', 'Key': 'SERVICE'}
]
)
return response['ResultsByTime']
def get_top_services_by_cost(self, days: = , top_n: = ) -> pd.DataFrame:
end_date = datetime.now().strftime()
start_date = (datetime.now() - timedelta(days=days)).strftime()
results = .get_cost_and_usage(start_date, end_date, )
service_costs = {}
result results:
group result[]:
service = group[][]
cost = (group[][][])
service service_costs:
service_costs[service] += cost
:
service_costs[service] = cost
df = pd.DataFrame((service_costs.items()),
columns=[, ])
df.nlargest(top_n, )
() -> :
start_date = datetime.now().strftime()
end_date = (datetime.now() + timedelta(days=days_ahead)).strftime()
response = .ce_client.get_cost_forecast(
TimePeriod={
: start_date,
: end_date
},
Metric=,
Granularity=
)
{
: (response[][]),
: (response[][][])
}
() -> []:
response = .ce_client.get_rightsizing_recommendation(
Service=
)
recommendations = []
rec response[]:
recommendations.append({
: rec[][],
: rec[][],
: rec[][][][]
rec.get() ,
: (rec[][])
rec.get()
})
recommendations
:
():
.ec2_client = boto3.client()
.rds_client = boto3.client()
.s3_client = boto3.client()
() -> [, ]:
idle_resources = {
: [],
: [],
: [],
: []
}
instances = .ec2_client.describe_instances(
Filters=[{: , : []}]
)
reservation instances[]:
instance reservation[]:
idle_resources[].append({
: instance[],
: instance[],
: instance[][]
})
volumes = .ec2_client.describe_volumes(
Filters=[{: , : []}]
)
volume volumes[]:
idle_resources[].append({
: volume[],
: volume[],
: volume[]
})
addresses = .ec2_client.describe_addresses()
address addresses[]:
address:
idle_resources[].append({
: address[],
: address[]
})
idle_resources
() -> :
on_demand_hourly = ._get_on_demand_price(instance_type)
ri_hourly = on_demand_hourly *
hours_per_year = *
annual_on_demand = on_demand_hourly * hours_per_year * count
annual_ri = ri_hourly * hours_per_year * count
{
: instance_type,
: count,
: annual_on_demand,
: annual_ri,
: annual_on_demand - annual_ri,
: ((annual_on_demand - annual_ri) / annual_on_demand) *
}
() -> :
prices = {
: ,
: ,
: ,
: ,
:
}
prices.get(instance_type, )
Cost Allocation and Tagging
class CostAllocation:
"""Manage cost allocation with tags"""
def __init__(self):
self.ec2_client = boto3.client('ec2')
self.ce_client = boto3.client('ce')
def define_tagging_strategy(self) -> Dict[str, List[str]]:
"""Define mandatory tags"""
return {
'environment': ['prod', 'staging', 'dev'],
'team': ['engineering', 'data', 'product'],
'cost_center': ['CC001', 'CC002', 'CC003'],
'project': ['project-a', 'project-b'],
'owner': ['email addresses']
}
def audit_resource_tags(self, resource_type: str = 'instance') -> List[Dict]:
"""Audit resources for missing tags"""
mandatory_tags = ['environment', 'team', 'cost_center']
untagged_resources = []
if resource_type == 'instance':
instances = .ec2_client.describe_instances()
reservation instances[]:
instance reservation[]:
tags = {tag[]: tag[]
tag instance.get(, [])}
missing_tags = [tag tag mandatory_tags
tag tags]
missing_tags:
untagged_resources.append({
: instance[],
: missing_tags
})
untagged_resources
() -> pd.DataFrame:
response = .ce_client.get_cost_and_usage(
TimePeriod={
: start_date,
: end_date
},
Granularity=,
Metrics=[],
GroupBy=[
{: , : tag_key}
]
)
costs = []
result response[]:
group result[]:
costs.append({
: group[][].split()[]
group[][] ,
: (group[][][])
})
pd.DataFrame(costs)
Budget Management
class BudgetManager:
"""Manage AWS budgets and alerts"""
def __init__(self):
self.budgets_client = boto3.client('budgets')
self.account_id = boto3.client('sts').get_caller_identity()['Account']
def create_monthly_budget(self, name: str, amount: float,
email: str) -> Dict:
"""Create monthly cost budget with alerts"""
budget = {
'BudgetName': name,
'BudgetLimit': {
'Amount': str(amount),
'Unit': 'USD'
},
'TimeUnit': 'MONTHLY',
'BudgetType': 'COST'
}
notifications = [
{
'Notification': {
'NotificationType': 'ACTUAL',
'ComparisonOperator': 'GREATER_THAN',
'Threshold': 80,
'ThresholdType': 'PERCENTAGE'
},
'Subscribers': [{
'SubscriptionType': 'EMAIL',
'Address': email
}]
},
{
: {
: ,
: ,
: ,
:
},
: [{
: ,
: email
}]
}
]
response = .budgets_client.create_budget(
AccountId=.account_id,
Budget=budget,
NotificationsWithSubscribers=notifications
)
response
Best Practices
Cost Visibility
- Implement comprehensive tagging
- Enable Cost Explorer
- Set up cost allocation tags
- Create custom cost reports
- Use dashboards for visualization
- Monitor costs daily
Optimization
- Right-size resources regularly
- Use Reserved Instances/Savings Plans
- Leverage Spot instances for flexible workloads
- Implement auto-scaling
- Clean up idle resources
- Use storage lifecycle policies
Governance
- Set budgets and alerts
- Implement approval workflows
- Regular cost reviews
- Cross-team accountability
- Document cost optimization wins
- Automate cost controls
Anti-Patterns
❌ No tagging strategy
❌ Ignoring rightsizing recommendations
❌ Not using Reserved Instances
❌ No budget alerts
❌ Keeping idle resources
❌ Manual cost tracking
❌ Siloed cost responsibility
Resources