Module: Jets::Stack::Main::Dsl::Base

Defined in:
lib/jets/stack/main/dsl/base.rb

Instance Method Summary collapse

Instance Method Details

#code_s3_keyObject

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.



42
43
44
# File 'lib/jets/stack/main/dsl/base.rb', line 42

def code_s3_key
  "code_s3_key_placeholder"
end

#depends_on(*stacks) ⇒ Object



29
30
31
32
33
34
35
36
# File 'lib/jets/stack/main/dsl/base.rb', line 29

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

#get_att(*item) ⇒ Object

Examples:

get_attr("logical_id.attribute")
get_attr("logical_id", "attribute")
get_attr(["logical_id", "attribute"])


11
12
13
14
15
16
17
18
19
20
21
22
23
# File 'lib/jets/stack/main/dsl/base.rb', line 11

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

#handler(name) ⇒ Object

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,

)



59
60
61
# File 'lib/jets/stack/main/dsl/base.rb', line 59

def handler(name)
  "handlers/shared/functions/#{name}" # generated handler
end

#logical_id(value) ⇒ Object



25
26
27
# File 'lib/jets/stack/main/dsl/base.rb', line 25

def logical_id(value)
  value.to_s.camelize
end

#ref(value) ⇒ Object



3
4
5
# File 'lib/jets/stack/main/dsl/base.rb', line 3

def ref(value)
  "!Ref #{value.to_s.camelize}"
end