Module: Furikake::Resources::Lambda

Defined in:
lib/furikake/resources/lambda.rb

Class Method Summary collapse

Class Method Details

.get_resourcesObject



21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
# File 'lib/furikake/resources/lambda.rb', line 21

def get_resources
  lmb = Aws::Lambda::Client.new

  req = {}
  functions = []
  loop do
    res = lmb.list_functions(req)
    functions.push(*res.functions)
    break if res.next_marker.nil?
    req[:marker] = res.next_marker
  end

  function_infos = []
  functions.map(&:to_h).each do |f|
    function = []
    function << f[:function_name]
    function << f[:function_arn]
    function << f[:runtime]
    function << f[:timeout]
    function << f[:memory_size]
    function_infos << function
  end
  function_infos
end

.reportObject



4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
# File 'lib/furikake/resources/lambda.rb', line 4

def report
  resources = get_resources
  headers = ['Function Name', 'Function ARN', 'Runtime', 'Timeout', 'Memory Size']
  if resources.empty?
    info = 'N/A'
  else
    info = MarkdownTables.make_table(headers, resources, is_rows: true, align: 'l')
  end
  documents = <<"EOS"
### Lambda Functions

#{info}
EOS
  
  documents
end