Class: CloudCostTracker::Billing::AWS::RDS::ServerStorageBillingPolicy

Inherits:
ResourceBillingPolicy show all
Defined in:
lib/cloud_cost_tracker/billing/rds/server_storage.rb

Overview

The default billing policy for Amazon RDS server storage costs

Constant Summary collapse

CENTS_PER_GB_PER_MONTH =

The YAML pricing data is read from config/billing

YAML.load(File.read File.join(
CONSTANTS_DIR, 'rds-aws-servers', 'us-east-on_demand-storage.yml'))

Constants included from CloudCostTracker

VERSION

Instance Method Summary collapse

Methods inherited from ResourceBillingPolicy

#initialize, #setup, #write_billing_record_for

Methods included from CloudCostTracker

account_coding_class, connect_to_database, create_billing_agents, create_coding_agents, env, read_accounts

Constructor Details

This class inherits a constructor from CloudCostTracker::Billing::ResourceBillingPolicy

Instance Method Details

#billing_typeObject



24
# File 'lib/cloud_cost_tracker/billing/rds/server_storage.rb', line 24

def billing_type ; "RDS Instance storage" end

#get_cost_for_duration(rds_server, duration) ⇒ Object

Returns the storage cost for a given RDS server over some duration (in seconds)



13
14
15
16
# File 'lib/cloud_cost_tracker/billing/rds/server_storage.rb', line 13

def get_cost_for_duration(rds_server, duration)
  CENTS_PER_GB_PER_MONTH[zone_setting(rds_server)] *
  rds_server.allocated_storage * duration / SECONDS_PER_MONTH
end

#zone_setting(resource) ⇒ Object

returns either ‘multi_az’ or ‘standard’, depending on whether this RDS server is multi-AZ



20
21
22
# File 'lib/cloud_cost_tracker/billing/rds/server_storage.rb', line 20

def zone_setting(resource)
  resource.multi_az ? 'multi_az' : 'standard'
end