awscosts 0.0.4 → 0.0.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/README.md +18 -5
- data/Rakefile +2 -0
- data/fixtures/vcr_cassettes/AWSCosts_EC2ReservedInstances/Reserved_instances/in_the_us-east-1_region/EC2_type_of_linux.yml +1817 -0
- data/fixtures/vcr_cassettes/AWSCosts_EC2ReservedInstances/Reserved_instances/in_the_us-east-1_region/EC2_type_of_rhel.yml +1817 -0
- data/fixtures/vcr_cassettes/AWSCosts_EC2ReservedInstances/Reserved_instances/in_the_us-east-1_region/EC2_type_of_sles.yml +1817 -0
- data/fixtures/vcr_cassettes/AWSCosts_EC2ReservedInstances/Reserved_instances/in_the_us-east-1_region/EC2_type_of_windows.yml +1817 -0
- data/fixtures/vcr_cassettes/AWSCosts_EC2ReservedInstances/Reserved_instances/in_the_us-east-1_region/EC2_type_of_windows_with_sql.yml +1817 -0
- data/fixtures/vcr_cassettes/AWSCosts_EC2ReservedInstances/Reserved_instances/in_the_us-east-1_region/EC2_type_of_windows_with_sql_web.yml +1817 -0
- data/lib/awscosts/ec2.rb +5 -0
- data/lib/awscosts/ec2_elastic_ips.rb +44 -0
- data/lib/awscosts/ec2_reserved_instances.rb +1 -1
- data/lib/awscosts/version.rb +1 -1
- data/spec/awscosts/ec2_elastic_ips_spec.rb +15 -0
- data/spec/awscosts/ec2_reserved_instances_spec.rb +23 -15
- metadata +11 -8
data/lib/awscosts/ec2.rb
CHANGED
@@ -2,6 +2,7 @@ require 'awscosts/ec2_on_demand'
|
|
2
2
|
require 'awscosts/ec2_reserved_instances'
|
3
3
|
require 'awscosts/ec2_elb'
|
4
4
|
require 'awscosts/ec2_ebs'
|
5
|
+
require 'awscosts/ec2_elastic_ips'
|
5
6
|
|
6
7
|
class AWSCosts::EC2
|
7
8
|
|
@@ -29,6 +30,10 @@ class AWSCosts::EC2
|
|
29
30
|
def ebs
|
30
31
|
AWSCosts::EBS.fetch(self.region.price_mapping)
|
31
32
|
end
|
33
|
+
|
34
|
+
def elastic_ips
|
35
|
+
AWSCosts::ElasticIPs.fetch(self.region.price_mapping)
|
36
|
+
end
|
32
37
|
end
|
33
38
|
|
34
39
|
|
@@ -0,0 +1,44 @@
|
|
1
|
+
class AWSCosts::ElasticIPs
|
2
|
+
|
3
|
+
def initialize data
|
4
|
+
@data= data
|
5
|
+
end
|
6
|
+
|
7
|
+
def price_one
|
8
|
+
@data['oneEIP']
|
9
|
+
end
|
10
|
+
|
11
|
+
def price_additional_per_hour
|
12
|
+
@data['perAdditionalEIPPerHour']
|
13
|
+
end
|
14
|
+
|
15
|
+
def price_non_attached_per_hour
|
16
|
+
@data['perNonAttachedPerHour']
|
17
|
+
end
|
18
|
+
|
19
|
+
def price_remap_first_100
|
20
|
+
@data['perRemapFirst100']
|
21
|
+
end
|
22
|
+
|
23
|
+
def price_remap_over_100
|
24
|
+
@data['perRemapOver100']
|
25
|
+
end
|
26
|
+
|
27
|
+
def self.fetch region
|
28
|
+
transformed= AWSCosts::Cache.get('/ec2/pricing/pricing-elastic-ips.json') do |data|
|
29
|
+
result = {}
|
30
|
+
data['config']['regions'].each do |region|
|
31
|
+
container = {}
|
32
|
+
region['types'].each do |type|
|
33
|
+
type['values'].each do |value|
|
34
|
+
container[value['rate']] = value['prices']['USD'].to_f
|
35
|
+
end
|
36
|
+
end
|
37
|
+
result[region['region']] = container
|
38
|
+
end
|
39
|
+
result
|
40
|
+
end
|
41
|
+
self.new(transformed[region])
|
42
|
+
end
|
43
|
+
|
44
|
+
end
|
data/lib/awscosts/version.rb
CHANGED
@@ -0,0 +1,15 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe AWSCosts::ElasticIPs do
|
4
|
+
use_vcr_cassette
|
5
|
+
|
6
|
+
subject { AWSCosts.region('ap-southeast-2').ec2.elastic_ips}
|
7
|
+
|
8
|
+
its(:price_one) { should == 0 }
|
9
|
+
its(:price_additional_per_hour) { should > 0 }
|
10
|
+
its(:price_non_attached_per_hour) { should > 0 }
|
11
|
+
its(:price_remap_first_100) { should == 0 }
|
12
|
+
its(:price_remap_over_100) { should > 0 }
|
13
|
+
|
14
|
+
end
|
15
|
+
|
@@ -2,26 +2,34 @@ require 'spec_helper'
|
|
2
2
|
|
3
3
|
describe AWSCosts::EC2ReservedInstances do
|
4
4
|
|
5
|
-
|
6
|
-
context "EC2 type of #{type}" do
|
7
|
-
use_vcr_cassette
|
5
|
+
describe 'Reserved instances' do
|
8
6
|
|
9
|
-
|
7
|
+
AWSCosts::Region::SUPPORTED.keys.each do |r|
|
10
8
|
|
11
|
-
|
12
|
-
|
13
|
-
|
9
|
+
context "in the #{r} region" do
|
10
|
+
[:windows, :linux, :windows_with_sql, :windows_with_sql_web, :rhel, :sles].each do |type|
|
11
|
+
context "EC2 type of #{type}" do
|
12
|
+
use_vcr_cassette
|
14
13
|
|
15
|
-
|
16
|
-
subject.upfront(:three_year).should have_key('m1.small')
|
17
|
-
end
|
14
|
+
subject { AWSCosts.region(r).ec2.reserved(type)}
|
18
15
|
|
19
|
-
|
20
|
-
|
21
|
-
|
16
|
+
it 'upfront price for 1 year term' do
|
17
|
+
subject.upfront(:one_year).should have_key('m1.small')
|
18
|
+
end
|
19
|
+
|
20
|
+
it 'upfront price for 3 year term' do
|
21
|
+
subject.upfront(:three_year).should have_key('m1.small')
|
22
|
+
end
|
23
|
+
|
24
|
+
it 'hourly price for 1 year term' do
|
25
|
+
subject.hourly(:one_year).should have_key('m1.small')
|
26
|
+
end
|
22
27
|
|
23
|
-
|
24
|
-
|
28
|
+
it 'hourly price for 3 year term' do
|
29
|
+
subject.hourly(:three_year).should have_key('m1.small')
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
25
33
|
end
|
26
34
|
end
|
27
35
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: awscosts
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.6
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2013-
|
12
|
+
date: 2013-09-24 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: httparty
|
@@ -134,6 +134,12 @@ files:
|
|
134
134
|
- fixtures/vcr_cassettes/AWSCosts_EC2ReservedInstances/EC2_type_of_windows.yml
|
135
135
|
- fixtures/vcr_cassettes/AWSCosts_EC2ReservedInstances/EC2_type_of_windows_with_sql.yml
|
136
136
|
- fixtures/vcr_cassettes/AWSCosts_EC2ReservedInstances/EC2_type_of_windows_with_sql_web.yml
|
137
|
+
- fixtures/vcr_cassettes/AWSCosts_EC2ReservedInstances/Reserved_instances/in_the_us-east-1_region/EC2_type_of_linux.yml
|
138
|
+
- fixtures/vcr_cassettes/AWSCosts_EC2ReservedInstances/Reserved_instances/in_the_us-east-1_region/EC2_type_of_rhel.yml
|
139
|
+
- fixtures/vcr_cassettes/AWSCosts_EC2ReservedInstances/Reserved_instances/in_the_us-east-1_region/EC2_type_of_sles.yml
|
140
|
+
- fixtures/vcr_cassettes/AWSCosts_EC2ReservedInstances/Reserved_instances/in_the_us-east-1_region/EC2_type_of_windows.yml
|
141
|
+
- fixtures/vcr_cassettes/AWSCosts_EC2ReservedInstances/Reserved_instances/in_the_us-east-1_region/EC2_type_of_windows_with_sql.yml
|
142
|
+
- fixtures/vcr_cassettes/AWSCosts_EC2ReservedInstances/Reserved_instances/in_the_us-east-1_region/EC2_type_of_windows_with_sql_web.yml
|
137
143
|
- fixtures/vcr_cassettes/AWSCosts_ELB.yml
|
138
144
|
- fixtures/vcr_cassettes/AWSCosts_EMR.yml
|
139
145
|
- fixtures/vcr_cassettes/AWSCosts_S3DataTransfer.yml
|
@@ -143,6 +149,7 @@ files:
|
|
143
149
|
- lib/awscosts/cache.rb
|
144
150
|
- lib/awscosts/ec2.rb
|
145
151
|
- lib/awscosts/ec2_ebs.rb
|
152
|
+
- lib/awscosts/ec2_elastic_ips.rb
|
146
153
|
- lib/awscosts/ec2_elb.rb
|
147
154
|
- lib/awscosts/ec2_on_demand.rb
|
148
155
|
- lib/awscosts/ec2_reserved_instances.rb
|
@@ -154,6 +161,7 @@ files:
|
|
154
161
|
- lib/awscosts/s3_storage.rb
|
155
162
|
- lib/awscosts/version.rb
|
156
163
|
- spec/awscosts/ec2_ebs_spec.rb
|
164
|
+
- spec/awscosts/ec2_elastic_ips_spec.rb
|
157
165
|
- spec/awscosts/ec2_elb_spec.rb
|
158
166
|
- spec/awscosts/ec2_on_demand_spec.rb
|
159
167
|
- spec/awscosts/ec2_reserved_instances_spec.rb
|
@@ -177,18 +185,12 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
177
185
|
- - ! '>='
|
178
186
|
- !ruby/object:Gem::Version
|
179
187
|
version: '0'
|
180
|
-
segments:
|
181
|
-
- 0
|
182
|
-
hash: -1851467363620844181
|
183
188
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
184
189
|
none: false
|
185
190
|
requirements:
|
186
191
|
- - ! '>='
|
187
192
|
- !ruby/object:Gem::Version
|
188
193
|
version: '0'
|
189
|
-
segments:
|
190
|
-
- 0
|
191
|
-
hash: -1851467363620844181
|
192
194
|
requirements: []
|
193
195
|
rubyforge_project:
|
194
196
|
rubygems_version: 1.8.23
|
@@ -197,6 +199,7 @@ specification_version: 3
|
|
197
199
|
summary: Programmatic access to AWS pricing
|
198
200
|
test_files:
|
199
201
|
- spec/awscosts/ec2_ebs_spec.rb
|
202
|
+
- spec/awscosts/ec2_elastic_ips_spec.rb
|
200
203
|
- spec/awscosts/ec2_elb_spec.rb
|
201
204
|
- spec/awscosts/ec2_on_demand_spec.rb
|
202
205
|
- spec/awscosts/ec2_reserved_instances_spec.rb
|