Class: Maze::Aws::Sam

Inherits:
Object
  • Object
show all
Defined in:
lib/maze/aws/sam.rb

Overview

Interacts with the AWS SAM CLI to invoke Lambda functions Note that the SAM CLI must be installed on the host machine as it does not run in a Docker container! For this reason the “start-api” command is not supported as it could easily cause port clashes and zombie processes

Class Attribute Summary collapse

Class Method Summary collapse

Class Attribute Details

.last_exit_codeObject (readonly)

Returns the value of attribute last_exit_code.



14
15
16
# File 'lib/maze/aws/sam.rb', line 14

def last_exit_code
  @last_exit_code
end

.last_responseObject (readonly)

Returns the value of attribute last_response.



14
15
16
# File 'lib/maze/aws/sam.rb', line 14

def last_response
  @last_response
end

Class Method Details

.invoke(directory, lambda, event = nil) ⇒ void

This method returns an undefined value.

Invoke the given lambda with an optional event

This happens synchronously so there is no need to wait for a response

Parameters:

  • directory (String)

    The directory containing the lambda

  • lambda (String)

    The name of the lambda to invoke

  • event (String, nil) (defaults to: nil)

    An optional event file to invoke with



25
26
27
28
29
30
31
# File 'lib/maze/aws/sam.rb', line 25

def invoke(directory, lambda, event = nil)
  command = build_invoke_command(lambda, event)

  output, @last_exit_code = Maze::Runner.run_command("cd #{directory} && #{command}")

  @last_response = parse(output)
end

.reset!void

This method returns an undefined value.

Reset the last response and last exit code



36
37
38
39
# File 'lib/maze/aws/sam.rb', line 36

def reset!
  @last_response = nil
  @last_exit_code = nil
end