awscost
is library to get AWS estimate billing costs.
This library probides two ways to get costs.
- ClowdWatch API
- CostExplorer API
import (
"fmt"
"time"
"github.com/evalphobia/awscost/costexplorer"
)
func main() {
endDate := time.Now().AddDate(0, 0, -1)
// costs, err := cloudwatch.FetchDailyCost(endDate)
costs, err := costexplorer.FetchDailyCost(endDate)
if err != nil {
return panic(err)
}
// set date to show it on the report
costs.SetDate(endDate)
text := costs.FormatAsOutputReport()
// show cost data
fmt.Println(text)
// post cost data to slack channel
err = sendCostToSlack(text)
if err != nil {
return panic(err)
}
}
Name | Description |
---|---|
AWSCOST_LANG |
Supported languages are en , ja . See the language file |