Skip to content

Commit

Permalink
fix: pylint note at 3.85/10
Browse files Browse the repository at this point in the history
  • Loading branch information
nataliagranato committed Mar 20, 2024
1 parent f990fe2 commit 4ffed0a
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions analise-de-custos.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,17 @@
import boto3
import datetime
import boto3

# Configuração do cliente boto3
ce_client = boto3.client('ce', region_name='us-east-1') # Substitua 'us-east-1' pela sua região

# Taxa de câmbio da AWS para converter para BRL
currency_conversion_rate = 5.50 # Substitua pelo valor da taxa de câmbio atual
CURRENCY_CONVERSION_RATE = 5.50 # Substitua pelo valor da taxa de câmbio atual

# Função para obter o período desejado de forma interativa
def get_custom_date_range():
"""
Obtém o período desejado de forma interativa.
"""
print("Digite o período desejado para análise de custos:")
start_date_str = input("Data de início (AAAA-MM-DD): ")
end_date_str = input("Data de término (AAAA-MM-DD): ")
Expand All @@ -23,6 +26,9 @@ def get_custom_date_range():

# Função para obter e listar os serviços e valores de gastos
def list_costs_by_service(start_date, end_date):
"""
Obtém e lista os serviços e valores de gastos.
"""
response = ce_client.get_cost_and_usage(
TimePeriod={
'Start': start_date.strftime('%Y-%m-%d'),
Expand All @@ -42,7 +48,7 @@ def list_costs_by_service(start_date, end_date):
for group in result['Groups']:
service_name = group['Keys'][0]
cost = float(group['Metrics']['BlendedCost']['Amount'])
cost_brl = cost * currency_conversion_rate
cost_brl = cost * CURRENCY_CONVERSION_RATE
print(f"Serviço: {service_name}, Custo em USD: ${cost:.2f}, Custo em BRL: R${cost_brl:.2f}")

if __name__ == '__main__':
Expand Down

0 comments on commit 4ffed0a

Please sign in to comment.