Class: AWSCosts::EC2
- Inherits:
-
Object
- Object
- AWSCosts::EC2
- Defined in:
- lib/awscosts/ec2.rb
Constant Summary collapse
- TYPES =
{ windows: 'mswin', linux: 'linux', windows_with_sql: 'mswinSQL', windows_with_sql_web: 'mswinSQLWeb', rhel: 'rhel', sles: 'sles' }
- REGION_MAPPING =
{ 'us-east-1' => "us-east", 'us-west-1' => "us-west", 'us-west-2' => "us-west-2", 'eu-west-1' => "eu-ireland", 'eu-central-1' => "eu-central-1", 'ap-southeast-1' => "apac-sin", 'ap-southeast-2' =>"apac-syd", 'ap-northeast-1' =>"apac-tokyo", 'sa-east-1' => "sa-east-1" }
Instance Attribute Summary collapse
-
#region ⇒ Object
readonly
Returns the value of attribute region.
Instance Method Summary collapse
- #ebs ⇒ Object
- #ebs_optimized ⇒ Object
- #elastic_ips ⇒ Object
- #elb ⇒ Object
-
#initialize(region) ⇒ EC2
constructor
A new instance of EC2.
- #on_demand(type) ⇒ Object
- #reserved(type, utilisation = :light) ⇒ Object
Constructor Details
#initialize(region) ⇒ EC2
Returns a new instance of EC2.
27 28 29 |
# File 'lib/awscosts/ec2.rb', line 27 def initialize region @region = region end |
Instance Attribute Details
#region ⇒ Object (readonly)
Returns the value of attribute region.
10 11 12 |
# File 'lib/awscosts/ec2.rb', line 10 def region @region end |
Instance Method Details
#ebs ⇒ Object
47 48 49 |
# File 'lib/awscosts/ec2.rb', line 47 def ebs AWSCosts::EBS.fetch(REGION_MAPPING[self.region.name]) end |
#ebs_optimized ⇒ Object
51 52 53 |
# File 'lib/awscosts/ec2.rb', line 51 def ebs_optimized AWSCosts::EBSOptimized.fetch(REGION_MAPPING[self.region.name]) end |
#elastic_ips ⇒ Object
55 56 57 |
# File 'lib/awscosts/ec2.rb', line 55 def elastic_ips AWSCosts::ElasticIPs.fetch(REGION_MAPPING[self.region.name]) end |
#elb ⇒ Object
43 44 45 |
# File 'lib/awscosts/ec2.rb', line 43 def elb AWSCosts::ELB.fetch(self.region.name) end |
#on_demand(type) ⇒ Object
31 32 33 34 |
# File 'lib/awscosts/ec2.rb', line 31 def on_demand(type) raise ArgumentError.new("Unknown platform: #{type}") if TYPES[type].nil? AWSCosts::EC2OnDemand.fetch(TYPES[type], self.region.name) end |
#reserved(type, utilisation = :light) ⇒ Object
36 37 38 39 40 41 |
# File 'lib/awscosts/ec2.rb', line 36 def reserved(type, utilisation = :light) r = self.region.name r = 'us-east' if r == 'us-east-1' raise ArgumentError.new("Unknown platform: #{type}") if TYPES[type].nil? AWSCosts::EC2ReservedInstances.fetch(TYPES[type], utilisation, r) end |