Aller au contenu principal

Concepts FinOps

Qu'est-ce que le FinOps ?​

FinOps (Financial Operations) est une pratique culturelle et une discipline qui maximise la valeur business du cloud en aidant les équipes d'ingénierie, finance et business à collaborer sur les décisions de dépenses cloud.

┌─────────────────────────────────────────────────────────────┐
│ FINOPS - LES 3 PHASES │
├─────────────────────────────────────────────────────────────┤
│ │
│ ┌─────────────────────────────────────────────────────┐ │
│ │ │ │
│ │ 1. INFORMER 2. OPTIMISER │ │
│ │ ─────────── ─────────── │ │
│ │ • Visibilité coûts • Right-sizing │ │
│ │ • Allocation • Reserved/Savings │ │
│ │ • Budgets • Spot instances │ │
│ │ • Prévisions • Nettoyage │ │
│ │ │ │
│ │ ↓ │ │
│ │ │ │
│ │ 3. OPÉRER │ │
│ │ ───────── │ │
│ │ • Gouvernance │ │
│ │ • Automatisation │ │
│ │ • Amélioration continue │ │
│ │ │ │
│ └─────────────────────────────────────────────────────┘ │
│ │
└─────────────────────────────────────────────────────────────┘

AWS Cost Explorer​

┌─────────────────────────────────────────────────────────────┐
│ AWS COST EXPLORER │
├─────────────────────────────────────────────────────────────┤
│ │
│ VUES PRINCIPALES : │
│ │
│ 1. PAR SERVICE │
│ ┌─────────────────────────────────────────────────┐ │
│ │ EC2 ████████████████████ $1,200 (40%)│ │
│ │ RDS ██████████ $600 (20%) │ │
│ │ S3 ████████ $450 (15%) │ │
│ │ Lambda ██████ $300 (10%) │ │
│ │ Other █████ $450 (15%) │ │
│ └─────────────────────────────────────────────────┘ │
│ │
│ 2. PAR TAG │
│ ┌─────────────────────────────────────────────────┐ │
│ │ Env:Production ██████████████████ $2,100 │ │
│ │ Env:Staging ████████ $600 │ │
│ │ Env:Dev ████ $300 │ │
│ └─────────────────────────────────────────────────┘ │
│ │
│ 3. PAR COMPTE │
│ ┌─────────────────────────────────────────────────┐ │
│ │ Prod Account ██████████████████ $2,100 │ │
│ │ Dev Account ████████ $600 │ │
│ │ Shared Services ████ $300 │ │
│ └─────────────────────────────────────────────────┘ │
│ │
└─────────────────────────────────────────────────────────────┘

Tagging Strategy​

Tags Essentiels​

┌─────────────────────────────────────────────────────────────┐
│ STRATÉGIE DE TAGGING │
├─────────────────────────────────────────────────────────────┤
│ │
│ TAGS OBLIGATOIRES : │
│ ┌─────────────────────────────────────────────────────┐ │
│ │ │ │
│ │ Tag Valeurs Exemple But │ │
│ │ ─── ─────────────── ─── │ │
│ │ Environment prod/staging/dev Environnement │ │
│ │ Project webapp/api/batch Projet │ │
│ │ Owner team-infra Responsable │ │
│ │ CostCenter CC-1234 Facturation │ │
│ │ │ │
│ └─────────────────────────────────────────────────────┘ │
│ │
│ TAGS RECOMMANDÉS : │
│ ┌─────────────────────────────────────────────────────┐ │
│ │ │ │
│ │ Application nom-application Identification │ │
│ │ CreatedBy terraform/console Traçabilité │ │
│ │ ExpiryDate 2024-12-31 Nettoyage │ │
│ │ Compliance pci/hipaa Conformité │ │
│ │ │ │
│ └─────────────────────────────────────────────────────┘ │
│ │
│ EXEMPLE COMPLET : │
│ { │
│ "Environment": "production", │
│ "Project": "ecommerce-api", │
│ "Owner": "team-backend", │
│ "CostCenter": "CC-5678", │
│ "Application": "checkout-service", │
│ "CreatedBy": "terraform" │
│ } │
│ │
└─────────────────────────────────────────────────────────────┘

Enforcement des Tags​

# AWS Config Rule pour vérifier les tags obligatoires
aws configservice put-config-rule \
--config-rule '{
"ConfigRuleName": "required-tags-ec2",
"Source": {
"Owner": "AWS",
"SourceIdentifier": "REQUIRED_TAGS"
},
"InputParameters": "{\"tag1Key\":\"Environment\",\"tag2Key\":\"Project\",\"tag3Key\":\"Owner\"}",
"Scope": {
"ComplianceResourceTypes": ["AWS::EC2::Instance"]
}
}'

Right-Sizing​

Identifier les Ressources Surdimensionnées​

┌─────────────────────────────────────────────────────────────┐
│ RIGHT-SIZING │
├─────────────────────────────────────────────────────────────┤
│ │
│ MÉTRIQUES À ANALYSER : │
│ │
│ CPU Utilization moyenne < 20% │
│ ┌─────────────────────────────────────────────────────┐ │
│ │ Instance CPU Avg RAM Avg Recommandation │ │
│ │ ──────── ─────── ─────── ──────────────│ │
│ │ i-web1 15% 30% Réduire │ │
│ │ i-web2 45% 60% OK │ │
│ │ i-db1 80% 85% Augmenter ? │ │
│ │ i-batch 5% 10% Spot ou smaller│ │
│ └─────────────────────────────────────────────────────┘ │
│ │
│ RÈGLES DE THUMB : │
│ │
│ CPU < 20% pendant 14+ jours → Candidat au downsizing │
│ CPU > 80% fréquemment → Candidat au upsizing │
│ Memory < 30% → Probable surdimensionnement │
│ │
│ AWS COMPUTE OPTIMIZER : │
│ Service gratuit qui analyse automatiquement et │
│ recommande les bons types d'instances │
│ │
└─────────────────────────────────────────────────────────────┘

Options de Pricing​

Comparaison​

┌─────────────────────────────────────────────────────────────┐
│ OPTIONS DE PRICING EC2 │
├─────────────────────────────────────────────────────────────┤
│ │
│ TYPE ÉCONOMIE ENGAGEMENT CAS D'USAGE │
│ ──── ──────── ────────── ─────────── │
│ │
│ On-Demand 0% Aucun Dev, tests │
│ (à la demande) Pics imprévus │
│ │
│ Reserved (RI) 30-60% 1-3 ans Production │
│ Standard Type fixe stable │
│ │
│ Reserved (RI) 20-40% 1-3 ans Production │
│ Convertible Flexible évolutive │
│ │
│ Savings Plans 30-50% 1-3 ans Compute │
│ Compute Flexible multi-service │
│ │
│ Spot 60-90% Aucun Batch, CI/CD │
│ Instances Interruptible Tolérant │
│ │
│ EXEMPLE ÉCONOMIE ANNUELLE (m5.large en us-east-1) : │
│ ┌─────────────────────────────────────────────────────┐ │
│ │ │ │
│ │ On-Demand : $0.096/h × 8760h = $840/an │ │
│ │ 1yr RI : $0.060/h × 8760h = $525/an (-37%) │ │
│ │ 3yr RI : $0.040/h × 8760h = $350/an (-58%) │ │
│ │ Spot : ~$0.030/h × 8760h = $263/an (-69%) │ │
│ │ │ │
│ └─────────────────────────────────────────────────────┘ │
│ │
└─────────────────────────────────────────────────────────────┘

Nettoyage des Ressources​

Ressources Couramment Oubliées​

┌─────────────────────────────────────────────────────────────┐
│ RESSOURCES ORPHELINES │
├─────────────────────────────────────────────────────────────┤
│ │
│ 1. EBS VOLUMES NON ATTACHÉS │
│ aws ec2 describe-volumes \ │
│ --filters Name=status,Values=available │
│ → Supprimer ou snapshot et supprimer │
│ │
│ 2. ELASTIC IPs NON UTILISÉES │
│ aws ec2 describe-addresses \ │
│ --filters Name=association-id,Values="" │
│ → Coût : $3.65/mois si non attachée ! │
│ │
│ 3. SNAPSHOTS ANCIENS │
│ aws ec2 describe-snapshots --owner-ids self \ │
│ --query 'Snapshots[?StartTime<`2023-01-01`]' │
│ → Évaluer et supprimer les obsolètes │
│ │
│ 4. OLD AMIs │
│ Garder seulement N dernières versions │
│ │
│ 5. LOAD BALANCERS INUTILISÉS │
│ ALB/NLB sans targets │
│ → Coût fixe même sans trafic │
│ │
│ 6. NAT GATEWAYS SOUS-UTILISÉS │
│ → $32/mois minimum + data │
│ Considérer NAT Instance pour dev │
│ │
│ 7. RDS INSTANCES ARRÊTÉES │
│ ⚠️ Redémarrent automatiquement après 7 jours ! │
│ → Snapshot et delete si pas besoin │
│ │
└─────────────────────────────────────────────────────────────┘

Script de Nettoyage​

#!/bin/bash
# cleanup-orphans.sh

echo "=== Recherche de ressources orphelines ==="

echo -e "\n1. EBS Volumes non attachés:"
aws ec2 describe-volumes \
--filters Name=status,Values=available \
--query 'Volumes[*].[VolumeId,Size,CreateTime]' \
--output table

echo -e "\n2. Elastic IPs non utilisées:"
aws ec2 describe-addresses \
--query 'Addresses[?AssociationId==null].[PublicIp,AllocationId]' \
--output table

echo -e "\n3. Snapshots > 90 jours:"
NINETY_DAYS_AGO=$(date -d '90 days ago' '+%Y-%m-%d')
aws ec2 describe-snapshots --owner-ids self \
--query "Snapshots[?StartTime<'${NINETY_DAYS_AGO}'].[SnapshotId,VolumeSize,StartTime]" \
--output table

echo -e "\n4. Load Balancers sans targets:"
for alb in $(aws elbv2 describe-load-balancers --query 'LoadBalancers[*].LoadBalancerArn' --output text); do
targets=$(aws elbv2 describe-target-groups --load-balancer-arn $alb --query 'TargetGroups[*].TargetGroupArn' --output text)
if [ -z "$targets" ]; then
echo "ALB sans targets: $alb"
fi
done

echo -e "\n=== Analyse terminée ==="

AWS Budgets​

Configuration​

┌─────────────────────────────────────────────────────────────┐
│ AWS BUDGETS │
├─────────────────────────────────────────────────────────────┤
│ │
│ TYPES DE BUDGETS : │
│ │
│ • Cost Budget : Limite de dépenses │
│ • Usage Budget : Limite d'utilisation (heures, GB) │
│ • Reservation Budget : Couverture RI/Savings Plans │
│ │
│ EXEMPLE DE CONFIGURATION : │
│ ┌─────────────────────────────────────────────────────┐ │
│ │ │ │
│ │ Budget Name: Monthly-Production │ │
│ │ Amount: $5,000 │ │
│ │ Period: Monthly │ │
│ │ │ │
│ │ Alertes: │ │
│ │ • 50% ($2,500) → Email info │ │
│ │ • 80% ($4,000) → Email warning │ │
│ │ • 100% ($5,000) → Email + SMS │ │
│ │ • 110% forecasted → Email alerte │ │
│ │ │ │
│ └─────────────────────────────────────────────────────┘ │
│ │
└─────────────────────────────────────────────────────────────┘
# Créer un budget
aws budgets create-budget \
--account-id 123456789012 \
--budget '{
"BudgetName": "Monthly-Limit",
"BudgetLimit": {
"Amount": "5000",
"Unit": "USD"
},
"TimeUnit": "MONTHLY",
"BudgetType": "COST"
}' \
--notifications-with-subscribers '[{
"Notification": {
"NotificationType": "ACTUAL",
"ComparisonOperator": "GREATER_THAN",
"Threshold": 80
},
"Subscribers": [{
"SubscriptionType": "EMAIL",
"Address": "team@example.com"
}]
}]'

Résumé des Recommandations​

DomaineActionÉconomie Potentielle
TaggingImplémenter tags obligatoiresVisibilité
Right-sizingRéduire instances sous-utilisées20-40%
Reserved/SPEngager sur charge stable30-60%
SpotUtiliser pour workloads flexibles60-90%
NettoyageSupprimer ressources orphelines10-20%
BudgetsAlertes proactivesContrôle

Prochaine section : Lab FinOps