MCPcopy Index your code
hub / github.com/diillson/aws-finops-dashboard-go

github.com/diillson/aws-finops-dashboard-go @v1.3.0

Chat with this repo
repository ↗ · DeepWiki ↗ · release v1.3.0 ↗ · + Follow
225 symbols 577 edges 27 files 109 documented · 48%
What it actually does AI analysis from the code graph — generated when you open this
loading…
README

AWS FinOps Dashboard (Go) — CLI

Uma CLI para visualizar e auditar custos na AWS (FinOps), com suporte a múltiplos perfis, combinação por conta, exportação de relatórios (CSV/JSON/PDF), análise de tendências e auditoria de otimizações (NAT Gateways caros, LBs ociosos, Volumes/EIPs sem uso, recursos sem tags etc.).


Sumário


Recursos (Features)

  • Dashboard de custos por perfil/conta com:
  • Custo do período anterior vs atual e variação percentual
  • Custos por serviço, com detalhamento opcional (usage-type) para serviços como Data Transfer, EC2-Other e VPC
  • Sumário de instâncias EC2 por estado
  • Status de Budgets (limite, atual, forecast)
  • Combinação por conta com --combine
  • Filtros por tags de alocação (--tag)
  • Período personalizável (--time-range)
  • Análise de tendências (últimos 6 meses) com --trend
  • Auditoria de otimização (--audit):
  • NAT Gateways com alto custo
  • Load Balancers ociosos
  • Volumes EBS e EIPs sem uso
  • EC2 paradas
  • Recursos sem tags (EC2, RDS, Lambda)
  • VPC Endpoints (Interface) sem uso
  • Alertas de Budget
  • Exportação: CSV, JSON e PDF
  • Configurações via TOML, YAML ou JSON
  • Verificação de atualização via GitHub Releases
  • Interface rica no terminal (pterm): banner, progress bar, tabelas etc.

Pré-requisitos

  • Go 1.24+ (recomendado)
  • AWS CLI configurado com credenciais válidas
  • Cost Explorer habilitado
  • Permissões de IAM adequadas (ver abaixo)

Instalação e Build

Clone o repositório:

git clone https://github.com/diillson/aws-finops-dashboard-go.git
cd aws-finops-dashboard-go
````

Build básico:

```bash
go build -o bin/aws-finops ./cmd/aws-finops

Executável:

./bin/aws-finops --help

Build com versão correta (ldflags)

Linux/macOS:

go build -ldflags "-s -w \
  -X github.com/diillson/aws-finops-dashboard-go/pkg/version.Version=1.2.0 \
  -X github.com/diillson/aws-finops-dashboard-go/pkg/version.Commit=$(git rev-parse --short HEAD) \
  -X github.com/diillson/aws-finops-dashboard-go/pkg/version.BuildTime=$(date -u +%Y-%m-%dT%H:%M:%SZ)" \
  -o bin/aws-finops ./cmd/aws-finops

Windows (PowerShell):

$commit = git rev-parse --short HEAD
$buildTime = (Get-Date).ToUniversalTime().ToString("yyyy-MM-ddTHH:mm:ssZ")
go build -ldflags "-s -w `
  -X github.com/diillson/aws-finops-dashboard-go/pkg/version.Version=1.2.3 `
  -X github.com/diillson/aws-finops-dashboard-go/pkg/version.Commit=$commit `
  -X github.com/diillson/aws-finops-dashboard-go/pkg/version.BuildTime=$buildTime" `
  -o bin/aws-finops ./cmd/aws-finops

Ao iniciar, verá algo como:

AWS FinOps Dashboard CLI (v1.2.0 (commit: abc1234, built at: 2025-10-23T10:20:30Z))

Sem -ldflags, o padrão é:

AWS FinOps Dashboard CLI (v0.0.0-dev (development))

Makefile (opcional)

O projeto inclui um Makefile para simplificar o build.

Uso:

make build
./bin/aws-finops --version

Uso rápido

aws-finops --help
aws-finops --version
aws-finops -p my-prod
aws-finops --all
aws-finops --all --combine
aws-finops -p prod -g Environment=Production -n finops-report -y csv -y pdf -d ./reports
aws-finops -p prod --trend
aws-finops --all --audit -n audit-$(date +%Y%m%d) -y pdf -d ./audits

Flags da CLI

-C, --config-file string   Caminho do arquivo de configuração
-p, --profiles strings     Perfis AWS (separados por vírgula)
-r, --regions strings      Regiões AWS
-a, --all                  Usa todos os perfis disponíveis
-c, --combine              Combina perfis da mesma conta
-n, --report-name string   Nome base do relatório
-y, --report-type strings  Tipos: csv, json, pdf
-d, --dir string           Diretório de saída
-t, --time-range int       Intervalo em dias (padrão: mês corrente)
-g, --tag strings          Filtro por tag (ex: Team=DevOps)
--trend                    Análise de tendência (6 meses)
--audit                    Auditoria de otimização
--breakdown-costs          Detalhamento de custos (usage-type)
--version                  Mostra a versão
--help                     Ajuda

Arquivo de configuração (TOML/YAML/JSON)

Estrutura

type Config struct {
  Profiles   []string `json:"profiles" yaml:"profiles" toml:"profiles"`
  Regions    []string `json:"regions" yaml:"regions" toml:"regions"`
  Combine    bool     `json:"combine" yaml:"combine" toml:"combine"`
  ReportName string   `json:"report_name" yaml:"report_name" toml:"report_name"`
  ReportType []string `json:"report_type" yaml:"report_type" toml:"report_type"`
  Dir        string   `json:"dir" yaml:"dir" toml:"dir"`
  TimeRange  int      `json:"time_range" yaml:"time_range" toml:"time_range"`
  Tag        []string `json:"tag" yaml:"tag" toml:"tag"`
  Audit      bool     `json:"audit" yaml:"audit" toml:"audit"`
  Trend      bool     `json:"trend" yaml:"trend" toml:"trend"`
  All        bool     `json:"all" yaml:"all" toml:"all"`
}

Exemplos

TOML

profiles = ["production", "development", "data-warehouse"]
regions = ["us-east-1", "us-west-2", "eu-central-1"]
combine = true
report_name = "aws-finops-monthly"
report_type = ["csv", "pdf"]
dir = "/home/user/reports/aws"
time_range = 30
tag = ["Environment=Production", "Department=IT"]
audit = false
trend = false

YAML

profiles:
  - production
  - development
  - data-warehouse
regions:
  - us-east-1
  - us-west-2
  - eu-central-1
combine: true
report_name: aws-finops-monthly
report_type: [csv, pdf]
dir: /home/user/reports/aws
time_range: 30
tag: ["Environment=Production", "Department=IT"]
audit: false
trend: false

JSON

{
  "profiles": ["production", "development", "data-warehouse"],
  "regions": ["us-east-1", "us-west-2", "eu-central-1"],
  "combine": true,
  "report_name": "aws-finops-monthly",
  "report_type": ["csv", "pdf"],
  "dir": "/home/user/reports/aws",
  "time_range": 30,
  "tag": ["Environment=Production", "Department=IT"],
  "audit": false,
  "trend": false
}

Como usar e precedência

aws-finops --config-file /path/config.yaml

Flags de linha de comando sobrescrevem as do arquivo.


Casos de Uso (Exemplos práticos)

aws-finops --all --combine -n monthly-costs -y csv -y pdf -d ./reports
aws-finops -p prod -p staging --audit -r us-east-1 -r eu-west-1 -n audit-jan -y pdf -d ./audits
aws-finops -p prod --trend -g Department=Engineering -t 180
aws-finops -p prod --breakdown-costs -n finops-dt -y json -y pdf -d ./reports
aws-finops -C config.yaml --report-name override --trend

Relatórios e Exportação

  • Tipos suportados: csv, json, pdf
  • Dashboard:

    • Colunas: Conta, períodos, custos por serviço, Budget, EC2
    • Auditoria:

    • Colunas: Conta, Budget, NAT Gateway, EBS, EC2, LBs, Tags

    • Exemplo:
aws-finops -p prod -n report-name -y csv -y json -y pdf -d ./out

Fluxo interno e Arquitetura

Arquitetura Hexagonal (Ports & Adapters):

  • Domain: entidades e interfaces
  • Application: casos de uso
  • Adapters:

    • driven: AWS SDK, exportação, config
    • driving: CLI (cobra)

Principais componentes:

  • cmd/aws-finops/main.go
  • internal/adapter/driving/cli
  • internal/application/usecase
  • internal/adapter/driven/aws
  • pkg/console
  • pkg/version

Fluxo:

  1. Inicializa CLI e casos de uso
  2. Lê config/flags
  3. Executa dashboard/auditoria/tendência
  4. Exibe no terminal e exporta relatórios
  5. Verifica atualização (ignorada em -dev)

Permissões AWS necessárias

Dashboard e tendência:

ce:GetCostAndUsage
budgets:DescribeBudgets
ec2:DescribeInstances
ec2:DescribeRegions
sts:GetCallerIdentity

Auditoria:

ec2:DescribeVolumes
ec2:DescribeAddresses
rds:DescribeDBInstances
lambda:ListFunctions
elasticloadbalancing:DescribeLoadBalancers
elasticloadbalancing:DescribeTargetGroups
elasticloadbalancing:DescribeTargetHealth

Solução de problemas (Troubleshooting)

  • No AWS profiles found: configure com aws configure --profile <nome>
  • credential validation failed: renove STS/SSO
  • Cost Explorer vazio: habilite-o na conta
  • AccessDenied: ajuste políticas IAM
  • PDF cortado: use JSON/CSV
  • Versão incorreta: use -ldflags no build

Observações de desempenho

  • Processamento concorrente com worker pool
  • Feedback visual com pterm.MultiPrinter
  • Cache de clientes AWS
  • --combine reduz chamadas redundantes

Segurança

  • Sem logging de credenciais
  • Usa perfis padrão da AWS CLI
  • Princípio de menor privilégio

Screenshots

Dashboard

Dashboard

Tendência

Trend

Auditoria

Audit


Licença e Créditos

Inspirado em:

Licença: MIT

Port Go e melhorias:

Contribuições são bem-vindas — abra issues ou PRs com sugestões 🚀

Extension points exported contracts — how you extend this code

ConfigRepository (Interface)
ConfigRepository defines the interface for loading configuration files. [1 implementers]
internal/domain/repository/config_repository.go
ConsoleInterface (Interface)
ConsoleInterface define a interface para saída no console. [1 implementers]
internal/shared/types/console.go
AWSRepository (Interface)
(no doc) [1 implementers]
internal/domain/repository/aws_repository.go
StatusHandle (Interface)
StatusHandle é uma interface para atualizar uma mensagem de status (spinner). [1 implementers]
internal/shared/types/console.go
ExportRepository (Interface)
(no doc) [1 implementers]
internal/domain/repository/export_repository.go
TableInterface (Interface)
TableInterface define a interface para criar e manipular tabelas. [1 implementers]
internal/shared/types/console.go

Core symbols most depended-on inside this repo

AddColumn
called by 48
internal/shared/types/console.go
Println
called by 33
internal/shared/types/console.go
cleanRichTags
called by 29
internal/adapter/driven/export/export_repository.go
LogError
called by 22
internal/shared/types/console.go
LogSuccess
called by 22
internal/shared/types/console.go
getServiceClient
called by 21
internal/adapter/driven/aws/aws_repository.go
generateFilename
called by 20
internal/adapter/driven/export/export_repository.go
LogInfo
called by 16
internal/shared/types/console.go

Shape

Method 156
Struct 35
Function 21
TypeAlias 7
Interface 6

Languages

Go100%

Modules by API surface

internal/adapter/driven/aws/aws_repository.go34 symbols
internal/application/usecase/dashboard_usecase.go32 symbols
internal/adapter/driven/export/export_repository.go26 symbols
internal/domain/repository/export_repository.go22 symbols
internal/domain/repository/aws_repository.go22 symbols
pkg/console/console.go21 symbols
internal/shared/types/console.go21 symbols
internal/domain/entity/ec2.go7 symbols
internal/adapter/driving/cli/app.go6 symbols
pkg/version/version.go4 symbols
internal/domain/entity/cost.go4 symbols
internal/domain/entity/commitments.go4 symbols

For agents

$ claude mcp add aws-finops-dashboard-go \
  -- python -m otcore.mcp_server <graph>

⬇ download graph artifact

Ask about this repo answers extend the page