Skip to contents

Fetch billing data - with some internal munging for ease of use

Usage

aws_billing(date_start, date_end = as.character(Sys.Date()))

Arguments

date_start, date_end

Start and end date to get billing data for. Date format expected: yyyy-MM-dd. required

Value

tibble with columns:

  • id: "blended", "unblended"

  • date: date, in format yyyy-MM-dd

  • service: AWS service name, spelled out in full

  • linked_account: account number

  • cost: cost in USD

  • acronym: short code for the service; if none known, this row will have the value in service

Blended vs. Unblended

  • Unblended: Unblended costs represent your usage costs on the day they are charged to you

  • Blended: Blended costs are calculated by multiplying each account’s service usage against something called a blended rate. A blended rate is the average rate of on-demand usage, as well as Savings Plans- and reservation-related usage, that is consumed by member accounts in an organization for a particular service.

Historical data

If you supply a date_start older than 14 months prior to today's date you will likely see an error like "You haven't enabled historical data beyond 14 months". See https://docs.aws.amazon.com/cost-management/latest/userguide/ce-advanced-cost-analysis.html #nolint for help

See also

Other billing: aws_billing_raw()

Examples

if (FALSE) { # interactive()
library(lubridate)
library(dplyr)

start_date <- today() - months(13)
z <- aws_billing(date_start = start_date)
z %>%
  filter(id == "blended") %>%
  group_by(service) %>%
  summarise(sum_cost = sum(cost)) %>%
  filter(sum_cost > 0) %>%
  arrange(desc(sum_cost))

z %>%
  filter(id == "blended") %>%
  filter(cost > 0) %>%
  arrange(service)

z %>%
  filter(id == "blended") %>%
  group_by(service) %>%
  summarise(sum_cost = sum(cost)) %>%
  filter(service == "Amazon Relational Database Service")
}