Sha256: 954c17b3c13b3e63f8773a3ae371ad313dcd316fadd76fa581ac3ec50569a914

Contents?: true

Size: 1.65 KB

Versions: 80

Compression:

Stored size: 1.65 KB

Contents

module Jets::Stack::Main::Dsl
  module Base
    def ref(value)
      "!Ref #{value.to_s.camelize}"
    end

    # Examples:
    #   get_attr("logical_id.attribute")
    #   get_attr("logical_id", "attribute")
    #   get_attr(["logical_id", "attribute"])
    def get_att(*item)
      item = item.flatten
      options = item.last.is_a?(Hash) ? item.pop : {}

      # list is an Array
      list = if item.size == 1
                item.first.split('.')
              else
                item
              end
      list.map! { |s| s.to_s.camelize } unless options[:autoformat] == false
      { "Fn::GetAtt" => list }
    end

    def logical_id(value)
      value.to_s.camelize
    end

    def depends_on(*stacks)
      if stacks == []
        @depends_on
      else
        @depends_on ||= []
        @depends_on += stacks
      end
    end

    # Due to `if Jets::Stack.has_resources?` check early on in the bootstraping process
    # The code has not been built at that point. So we use a placeholder and will replace
    # the placeholder as part of the cfn template build process after the code has been built
    # and the code_s3_key with md5 is available.
    def code_s3_key
      "code_s3_key_placeholder"
    end

    # resource(:hello,
    #   function_name: "hello",
    #   code: {
    #     s3_bucket: "!Ref S3Bucket",
    #     s3_key: code_s3_key
    #   },
    #   description: "Hello world",
    #   handler: handler_function("hello.lambda_handler"),
    #   memory_size: 128,
    #   role: "!Ref IamRole",
    #   runtime: "python3.6",
    #   timeout: 20,
    # )
    def handler(name)
      "handlers/shared/functions/#{name}" # generated handler
    end
  end
end

Version data entries

80 entries across 80 versions & 2 rubygems

Version Path
jets-4.0.12 lib/jets/stack/main/dsl/base.rb
jets-4.0.11 lib/jets/stack/main/dsl/base.rb
jets-5.0.13 lib/jets/stack/main/dsl/base.rb
jets-5.0.12 lib/jets/stack/main/dsl/base.rb
jets-5.0.11 lib/jets/stack/main/dsl/base.rb
jets-5.0.10 lib/jets/stack/main/dsl/base.rb
jets-5.0.9 lib/jets/stack/main/dsl/base.rb
jets-5.0.8 lib/jets/stack/main/dsl/base.rb
jets-5.0.7 lib/jets/stack/main/dsl/base.rb
jets-5.0.6 lib/jets/stack/main/dsl/base.rb
jets-5.0.5 lib/jets/stack/main/dsl/base.rb
jets-5.0.4 lib/jets/stack/main/dsl/base.rb
jets-5.0.3 lib/jets/stack/main/dsl/base.rb
jets-5.0.2 lib/jets/stack/main/dsl/base.rb
jets-5.0.1 lib/jets/stack/main/dsl/base.rb
jets-5.0.0 lib/jets/stack/main/dsl/base.rb
jets-4.0.10 lib/jets/stack/main/dsl/base.rb
jets-5.0.0.beta1 lib/jets/stack/main/dsl/base.rb
jets-4.0.9 lib/jets/stack/main/dsl/base.rb
jets-4.0.8 lib/jets/stack/main/dsl/base.rb