Class: CloudCostTracker::Billing::AWS::RDS::ServerBillingPolicy
- Inherits:
-
ResourceBillingPolicy
- Object
- ResourceBillingPolicy
- CloudCostTracker::Billing::AWS::RDS::ServerBillingPolicy
- Defined in:
- lib/cloud_cost_tracker/billing/rds/servers.rb
Overview
The default billing policy for Amazon RDS server runtime costs
Constant Summary collapse
- CENTS_PER_HOUR =
The YAML pricing data is read from config/billing
YAML.load(File.read File.join( CONSTANTS_DIR, 'rds-aws-servers', 'us-east-on_demand-mysql.yml'))
Constants included from CloudCostTracker
Instance Method Summary collapse
- #billing_type ⇒ Object
-
#get_cost_for_duration(rds_server, duration) ⇒ Object
Returns the runtime cost for a given RDS server over some duration (in seconds).
-
#zone_setting(resource) ⇒ Object
returns either ‘multi_az’ or ‘standard’, depending on whether this RDS server is multi-AZ.
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_type ⇒ Object
25 |
# File 'lib/cloud_cost_tracker/billing/rds/servers.rb', line 25 def billing_type ; "RDS Instance runtime" end |
#get_cost_for_duration(rds_server, duration) ⇒ Object
Returns the runtime cost for a given RDS server over some duration (in seconds)
13 14 15 16 17 |
# File 'lib/cloud_cost_tracker/billing/rds/servers.rb', line 13 def get_cost_for_duration(rds_server, duration) hourly_cost = CENTS_PER_HOUR[zone_setting(rds_server)][rds_server.flavor_id] (hourly_cost * duration) / SECONDS_PER_HOUR end |
#zone_setting(resource) ⇒ Object
returns either ‘multi_az’ or ‘standard’, depending on whether this RDS server is multi-AZ
21 22 23 |
# File 'lib/cloud_cost_tracker/billing/rds/servers.rb', line 21 def zone_setting(resource) resource.multi_az ? 'multi_az' : 'standard' end |