Sha256: 6957433540acf67c6cd073cc310953075a087437313601f19a844a766fa8bb5c

Contents?: true

Size: 1.73 KB

Versions: 53

Compression:

Stored size: 1.73 KB

Contents

module Fog
  module AWS
    class CloudFormation
      class Real
        require 'fog/aws/parsers/cloud_formation/estimate_template_cost'

        # Returns the estimated monthly cost of a template.
        #
        # * options [Hash]:
        #   * TemplateBody [String] Structure containing the template body.
        #   or (one of the two Template parameters is required)
        #   * TemplateURL [String] URL of file containing the template body.
        #   * Parameters [Hash] Hash of providers to supply to template
        #
        # @return [Excon::Response]:
        #   * body [Hash:
        #     * Url [String] - An AWS Simple Monthly Calculator URL with a query string that describes the resources required to run the template.
        #
        # @see http://docs.amazonwebservices.com/AWSCloudFormation/latest/APIReference/API_EstimateTemplateCost.html

        def estimate_template_cost(options = {})
          params = {}

          if options['Parameters']
            options['Parameters'].keys.each_with_index do |key, index|
              index += 1 # params are 1-indexed
              params.merge!({
                "Parameters.member.#{index}.ParameterKey"   => key,
                "Parameters.member.#{index}.ParameterValue" => options['Parameters'][key]
              })
            end
          end

          if options['TemplateBody']
            params['TemplateBody'] = options['TemplateBody']
          elsif options['TemplateURL']
            params['TemplateURL'] = options['TemplateURL']
          end

          request({
            'Action'    => 'EstimateTemplateCost',
            :parser     => Fog::Parsers::AWS::CloudFormation::EstimateTemplateCost.new
          }.merge!(params))
        end
      end
    end
  end
end

Version data entries

53 entries across 51 versions & 2 rubygems

Version Path
fog-aws-3.30.0 lib/fog/aws/requests/cloud_formation/estimate_template_cost.rb
fog-aws-3.29.0 lib/fog/aws/requests/cloud_formation/estimate_template_cost.rb
fog-aws-3.28.0 lib/fog/aws/requests/cloud_formation/estimate_template_cost.rb
fog-aws-3.27.0 lib/fog/aws/requests/cloud_formation/estimate_template_cost.rb
fog-aws-3.26.0 lib/fog/aws/requests/cloud_formation/estimate_template_cost.rb
fog-aws-3.25.0 lib/fog/aws/requests/cloud_formation/estimate_template_cost.rb
fog-aws-3.24.0 lib/fog/aws/requests/cloud_formation/estimate_template_cost.rb
fog-aws-3.23.0 lib/fog/aws/requests/cloud_formation/estimate_template_cost.rb
fog-aws-3.22.0 lib/fog/aws/requests/cloud_formation/estimate_template_cost.rb
fog-aws-3.21.1 lib/fog/aws/requests/cloud_formation/estimate_template_cost.rb
fog-aws-3.21.0 lib/fog/aws/requests/cloud_formation/estimate_template_cost.rb
fog-aws-3.20.0 lib/fog/aws/requests/cloud_formation/estimate_template_cost.rb
fog-aws-3.19.0 lib/fog/aws/requests/cloud_formation/estimate_template_cost.rb
fog-aws-3.18.0 lib/fog/aws/requests/cloud_formation/estimate_template_cost.rb
fog-aws-3.17.0 lib/fog/aws/requests/cloud_formation/estimate_template_cost.rb
fog-aws-3.16.0 lib/fog/aws/requests/cloud_formation/estimate_template_cost.rb
fog-aws-3.15.0 lib/fog/aws/requests/cloud_formation/estimate_template_cost.rb
fog-aws-3.14.0 lib/fog/aws/requests/cloud_formation/estimate_template_cost.rb
fog-aws-3.13.0 lib/fog/aws/requests/cloud_formation/estimate_template_cost.rb
fog-aws-3.12.0 lib/fog/aws/requests/cloud_formation/estimate_template_cost.rb