مدیریت هزینهها در
Infrastructure as a Service (IaaS)
مثل AWS EC2 یکی از کلیدهای موفقیت در FinOps هست. بیاید یه چالش کدنویسی باحال حل کنیم! 🚀
کد زیر هزینه یه instance رو در AWS محاسبه میکنه. به نظرتون خروجی این کد چیه؟
def calculate_instance_cost(instance_type, hours):
pricing = {
"t2.micro": 0.0116,
"m5.large": 0.096,
"c5.xlarge": 0.17
}
if instance_type not in pricing:
return "Error: Invalid instance type"
cost = pricing[instance_type] * hours
return round(cost, 2)
result = calculate_instance_cost("m5.large", 10)
print(result)