Sha256: 5d852191fe4bfaf4fbc535ea68bd5ea3df53bc5a1527245c6c7b343f74845b48

Contents?: true

Size: 1.83 KB

Versions: 30

Compression:

Stored size: 1.83 KB

Contents

require 'set'

module Convection
  module DSL
    ##
    # Formatting helpers for Intrinsic Functions
    module IntrinsicFunctions
      def self.included(base)
        mixers << base

        super
      end

      def self.mixers
        @mixers ||= Set.new
      end

      def base64(content)
        {
          'Fn::Base64' => content
        }
      end

      def fn_and(*conditions)
        {
          'Fn::And' => conditions
        }
      end

      def fn_equals(value_1, value_2)
        {
          'Fn::Equals' => [value_1, value_2]
        }
      end

      def fn_if(condition, value_true, value_false)
        {
          'Fn::If' => [condition, value_true, value_false]
        }
      end

      def fn_import_value(value)
        {
          'Fn::ImportValue' => value
        }
      end

      def fn_not(condition)
        {
          'Fn::Not' => [condition]
        }
      end

      def fn_or(*conditions)
        {
          'Fn::Or' => conditions
        }
      end

      def fn_sub(str, *vars)
        if vars && !vars.empty?
          {
            'Fn::Sub' => [str, vars]
          }
        else
          {
            'Fn::Sub' => str
          }
        end
      end

      def find_in_map(map_name, key_1, key_2)
        {
          'Fn::FindInMap' => [map_name, key_1, key_2]
        }
      end

      def get_att(resource, attr_name)
        {
          'Fn::GetAtt' => [resource, attr_name]
        }
      end

      def get_azs(region)
        {
          'Fn::GetAZs' => region
        }
      end

      def join(delimiter, *values)
        {
          'Fn::Join' => [delimiter, values]
        }
      end

      def select(index, *objects)
        {
          'Fn::Select' => [index, objects]
        }
      end

      def fn_ref(resource)
        {
          'Ref' => resource
        }
      end
    end
  end
end

Version data entries

30 entries across 30 versions & 1 rubygems

Version Path
convection-2.3.1 lib/convection/dsl/intrinsic_functions.rb
convection-2.3.0 lib/convection/dsl/intrinsic_functions.rb
convection-2.2.29 lib/convection/dsl/intrinsic_functions.rb
convection-2.2.28.pre.beta.2 lib/convection/dsl/intrinsic_functions.rb
convection-2.2.28.pre.beta.1 lib/convection/dsl/intrinsic_functions.rb
convection-2.2.27 lib/convection/dsl/intrinsic_functions.rb
convection-2.2.26 lib/convection/dsl/intrinsic_functions.rb
convection-2.2.25 lib/convection/dsl/intrinsic_functions.rb
convection-2.2.24 lib/convection/dsl/intrinsic_functions.rb
convection-2.2.23 lib/convection/dsl/intrinsic_functions.rb
convection-2.2.22 lib/convection/dsl/intrinsic_functions.rb
convection-2.2.21 lib/convection/dsl/intrinsic_functions.rb
convection-2.2.20 lib/convection/dsl/intrinsic_functions.rb
convection-2.2.19 lib/convection/dsl/intrinsic_functions.rb
convection-2.2.18 lib/convection/dsl/intrinsic_functions.rb
convection-2.2.17 lib/convection/dsl/intrinsic_functions.rb
convection-2.2.16 lib/convection/dsl/intrinsic_functions.rb
convection-2.2.15 lib/convection/dsl/intrinsic_functions.rb
convection-2.2.14 lib/convection/dsl/intrinsic_functions.rb
convection-2.2.13 lib/convection/dsl/intrinsic_functions.rb