Sha256: 4c311726521023bb0bc88c50d699f829f366c7c403027ca6f2a7b59f2dc5b0f6

Contents?: true

Size: 1.74 KB

Versions: 41

Compression:

Stored size: 1.74 KB

Contents

# Copyright 2013-2014 Bazaarvoice, Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#     http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

# This list of prices was sourced from the on-demand prices current as of 12/3/2012.
# We expect the actual price we pay per instance to be roughly 1/10 the prices below.
SPOT_PRICES_BY_INSTANCE_TYPE = {
    "m1.small"    => 0.065,
    "m1.medium"   => 0.130,
    "m1.large"    => 0.260,
    "m1.xlarge"   => 0.520,
    "m3.xlarge"   => 0.580,
    "m3.2xlarge"  => 1.160,
    "t1.micro"    => 0.020,
    "m2.xlarge"   => 0.450,
    "m2.2xlarge"  => 0.900,
    "m2.4xlarge"  => 1.800,
    "c1.medium"   => 0.165,
    "c1.xlarge"   => 0.660,
    "cc1.4xlarge" => 1.300,
    "cc2.8xlarge" => 2.400,
    "cg1.4xlarge" => 2.100,
    "hi1.4xlarge" => 3.100,
    "hs1.8xlarge" => 4.600,
    "cr1.8xlarge" => 4.000,
}

def spot_price(spot_price_string, instance_type)
  case spot_price_string
    when 'false', '' then aws_no_value()
    when 'true' then spot_price_for_instance_type(instance_type)
    else spot_price_string
  end
end

def spot_price_for_instance_type(instance_type)
  # Add 10% to ensure that we have a small buffer against current spot prices increasing
  # to the on-demand prices, which theoretically could happen often.
  SPOT_PRICES_BY_INSTANCE_TYPE[instance_type] * 1.10
end

Version data entries

41 entries across 41 versions & 3 rubygems

Version Path
cloudformation-ruby-dsl-1.2.0 lib/cloudformation-ruby-dsl/spotprice.rb
cloudformation-ruby-dsl-1.1.0 lib/cloudformation-ruby-dsl/spotprice.rb
cloudformation-ruby-dsl-1.0.5 lib/cloudformation-ruby-dsl/spotprice.rb
cloudformation-ruby-dsl-1.0.4 lib/cloudformation-ruby-dsl/spotprice.rb
cloudformation-ruby-dsl-1.0.3 lib/cloudformation-ruby-dsl/spotprice.rb
cloudformation-ruby-dsl-1.0.1 lib/cloudformation-ruby-dsl/spotprice.rb
cloudformation-ruby-dsl-1.0.0 lib/cloudformation-ruby-dsl/spotprice.rb
cloudformation-ruby-dsl-0.5.4 lib/cloudformation-ruby-dsl/spotprice.rb
cloudformation-ruby-dsl-0.5.3 lib/cloudformation-ruby-dsl/spotprice.rb
cloudformation-ruby-dsl-0.5.2 lib/cloudformation-ruby-dsl/spotprice.rb
cloudformation-ruby-dsl-0.5.1 lib/cloudformation-ruby-dsl/spotprice.rb
cloudformation-ruby-dsl-0.5.0 lib/cloudformation-ruby-dsl/spotprice.rb
cloudformation-ruby-dsl-0.4.14 lib/cloudformation-ruby-dsl/spotprice.rb
cloudformation-ruby-dsl-0.4.13 lib/cloudformation-ruby-dsl/spotprice.rb
cloudformation-ruby-dsl-0.4.12 lib/cloudformation-ruby-dsl/spotprice.rb
cloudformation-ruby-dsl-0.4.11 lib/cloudformation-ruby-dsl/spotprice.rb
cloudformation-ruby-dsl-0.4.10 lib/cloudformation-ruby-dsl/spotprice.rb
cloudformation-ruby-dsl-0.4.9 lib/cloudformation-ruby-dsl/spotprice.rb
cloudformation-ruby-dsl-0.4.8 lib/cloudformation-ruby-dsl/spotprice.rb
cloudformation-ruby-dsl-0.4.7 lib/cloudformation-ruby-dsl/spotprice.rb