class Dpl::Providers::Lambda
Public Instance Methods
deploy()
click to toggle source
# File lib/dpl/providers/lambda.rb, line 59 def deploy exists? ? update : create rescue Aws::Errors::ServiceError => e error e.message end
login()
click to toggle source
# File lib/dpl/providers/lambda.rb, line 55 def login info :login end
Private Instance Methods
client()
click to toggle source
# File lib/dpl/providers/lambda.rb, line 172 def client @client ||= Aws::Lambda::Client.new(region:, credentials:) end
create()
click to toggle source
# File lib/dpl/providers/lambda.rb, line 73 def create info :create_function config = function_config config = config.merge(code: { zip_file: function_zip }) config = config.merge(tags: function_tags) if function_tags? client.create_function(config) end
credentials()
click to toggle source
# File lib/dpl/providers/lambda.rb, line 176 def credentials Aws::Credentials.new(access_key_id, secret_access_key) end
dead_letter_arn()
click to toggle source
Calls superclass method
# File lib/dpl/providers/lambda.rb, line 156 def dead_letter_arn { target_arn: super } if dead_letter_arn? end
description()
click to toggle source
Calls superclass method
# File lib/dpl/providers/lambda.rb, line 168 def description interpolate(super || msg(:description), vars:) end
environment()
click to toggle source
Calls superclass method
# File lib/dpl/providers/lambda.rb, line 152 def environment { variables: split_vars(super) } if environment? end
exists?()
click to toggle source
# File lib/dpl/providers/lambda.rb, line 67 def exists? !!client.get_function(function_name:) rescue ::Aws::Lambda::Errors::ResourceNotFoundException false end
function_code()
click to toggle source
# File lib/dpl/providers/lambda.rb, line 132 def function_code { function_name:, zip_file: function_zip, publish: publish? } end
function_config()
click to toggle source
# File lib/dpl/providers/lambda.rb, line 107 def function_config compact( function_name:, role:, handler:, description:, timeout:, memory_size:, vpc_config:, environment:, runtime:, dead_letter_config: dead_letter_arn, kms_key_arn:, tracing_config:, layers: ) end
function_zip()
click to toggle source
# File lib/dpl/providers/lambda.rb, line 144 def function_zip Zip.new(zip, tmp_filename, opts).zip end
handler()
click to toggle source
# File lib/dpl/providers/lambda.rb, line 140 def handler Handler.new(runtime, module_name, handler_name).to_s if handler_name? end
split_vars(vars)
click to toggle source
# File lib/dpl/providers/lambda.rb, line 180 def split_vars(vars) vars.map { |var| var.split('=', 2) }.to_h end
tag_resource(arn)
click to toggle source
# File lib/dpl/providers/lambda.rb, line 125 def tag_resource(arn) { resource: arn, tags: function_tags } end
tmp_filename()
click to toggle source
# File lib/dpl/providers/lambda.rb, line 184 def tmp_filename @tmp_filename ||= "#{tmp_dir}/#{repo_name}.zip" end
tracing_config()
click to toggle source
# File lib/dpl/providers/lambda.rb, line 160 def tracing_config { mode: tracing_mode } if tracing_mode? end
update()
click to toggle source
# File lib/dpl/providers/lambda.rb, line 81 def update arn = update_config client.wait_until(:function_updated, { function_name: }) update_tags(arn) if function_tags? client.wait_until(:function_updated, { function_name: }) update_code rescue Aws::Waiters::Errors::WaiterFailed error 'Update timed out.' end
update_code()
click to toggle source
# File lib/dpl/providers/lambda.rb, line 102 def update_code info :update_code client.update_function_code(function_code) end
update_config()
click to toggle source
# File lib/dpl/providers/lambda.rb, line 91 def update_config info :update_config response = client.update_function_configuration(function_config) response.function_arn end
vpc_config()
click to toggle source
# File lib/dpl/providers/lambda.rb, line 148 def vpc_config compact(subnet_ids:, security_group_ids:) end