Class: Stax::Cmd::Lambda
Instance Method Summary
collapse
Methods inherited from SubCommand
#info, stax_info, stax_info_tasks
Instance Method Details
#code(id) ⇒ Object
59
60
61
62
63
64
65
66
67
68
69
70
|
# File 'lib/stax/mixin/lambda.rb', line 59
def code(id)
url = Aws::Lambda.code(my.resource(id))
if options[:url]
puts url
else
Tempfile.new([my.stack_name, '.zip']).tap do |file|
file.write(open(url).read)
file.close
puts %x[unzip -p #{file.path}] end
end
end
|
#config(id) ⇒ Object
52
53
54
55
|
# File 'lib/stax/mixin/lambda.rb', line 52
def config(id)
cfg = Aws::Lambda.configuration(my.resource(id))
puts YAML.dump(stringify_keys(cfg.to_hash))
end
|
#ls ⇒ Object
40
41
42
43
44
45
46
47
48
49
|
# File 'lib/stax/mixin/lambda.rb', line 40
def ls
debug("Lambda functions for stack #{my.stack_name}")
names = stack_lambdas.map(&:physical_resource_id)
print_table Aws::Lambda.list.select { |l|
names.include?(l.function_name)
}.map { |l|
size = (l.code_size/1.0.megabyte).round.to_s + 'MB'
[l.function_name, l.description, l.runtime, size, l.last_modified]
}
end
|
#test(id) ⇒ Object
89
90
91
92
93
94
95
96
97
98
99
100
|
# File 'lib/stax/mixin/lambda.rb', line 89
def test(id)
Aws::Lambda.invoke(
function_name: my.resource(id),
invocation_type: options[:type],
log_type: options[:tail] ? 'Tail' : nil,
payload: options[:file] ? File.open(options[:file]) : options[:payload],
).tap do |resp|
puts resp.status_code
warn(resp.function_error) if resp.function_error
puts Base64.decode64(resp.log_result) if options[:tail]
end
end
|
#update(id, file) ⇒ Object
74
75
76
77
78
79
80
81
82
|
# File 'lib/stax/mixin/lambda.rb', line 74
def update(id, file)
Aws::Lambda.update_code(
function_name: my.resource(id),
publish: options[:publish],
zip_file: zip_thing(file),
)&.version.tap do |v|
puts "version: #{v}"
end
end
|