Download this file
| 1 | package economics |
| 2 | |
| 3 | import "time" |
| 4 | |
| 5 | // Bill sources. |
| 6 | const ( |
| 7 | SourceManual = "manual" |
| 8 | SourceCostExplorer = "costexplorer" |
| 9 | ) |
| 10 | |
| 11 | // Bill is economics/bills/<month>.json — the real AWS bill for one month, |
| 12 | // whole-account by-service (attribution to CARLOS is a dashboard knob, not |
| 13 | // a pull-time filter — both AWS accounts hold non-CARLOS resources). |
| 14 | type Bill struct { |
| 15 | Schema int `json:"schema"` // 1 |
| 16 | Month string `json:"month"` // "2006-01" |
| 17 | TotalUSD float64 `json:"total_usd"` |
| 18 | Services map[string]float64 `json:"services"` |
| 19 | Source string `json:"source"` // SourceManual | SourceCostExplorer |
| 20 | // PulledAt uses omitzero, not omitempty: encoding/json's omitempty never |
| 21 | // treats a zero time.Time as empty (it isn't a nil/0/"" by the encoder's |
| 22 | // own rule), so a manually-entered bill — which never sets this field — |
| 23 | // would otherwise marshal a lying "0001-01-01T00:00:00Z" pulled_at key. |
| 24 | PulledAt time.Time `json:"pulled_at,omitzero"` |
| 25 | } |
| 26 | |
| 27 | // BillsPrefix lists stored bills. |
| 28 | const BillsPrefix = "economics/bills/" |
| 29 | |
| 30 | // BillKey is the bucket key for a month's bill. |
| 31 | func BillKey(month string) string { return BillsPrefix + month + ".json" } |
| 32 | |