Class: Fog::AWS::Lambda::Real

Inherits:
Object
  • Object
show all
Includes:
CredentialFetcher::ConnectionMethods
Defined in:
lib/fog/aws/lambda.rb,
lib/fog/aws/requests/lambda/invoke.rb,
lib/fog/aws/requests/lambda/get_policy.rb,
lib/fog/aws/requests/lambda/get_function.rb,
lib/fog/aws/requests/lambda/add_permission.rb,
lib/fog/aws/requests/lambda/list_functions.rb,
lib/fog/aws/requests/lambda/create_function.rb,
lib/fog/aws/requests/lambda/delete_function.rb,
lib/fog/aws/requests/lambda/remove_permission.rb,
lib/fog/aws/requests/lambda/update_function_code.rb,
lib/fog/aws/requests/lambda/get_event_source_mapping.rb,
lib/fog/aws/requests/lambda/get_function_configuration.rb,
lib/fog/aws/requests/lambda/list_event_source_mappings.rb,
lib/fog/aws/requests/lambda/create_event_source_mapping.rb,
lib/fog/aws/requests/lambda/delete_event_source_mapping.rb,
lib/fog/aws/requests/lambda/update_event_source_mapping.rb,
lib/fog/aws/requests/lambda/update_function_configuration.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from CredentialFetcher::ConnectionMethods

#refresh_credentials_if_expired

Constructor Details

#initialize(options = {}) ⇒ Real

Initialize connection to Lambda

Notes

options parameter must include values for :aws_access_key_id and :aws_secret_access_key in order to create a connection

Examples

lambda = Lambda.new(
 :aws_access_key_id => your_aws_access_key_id,
 :aws_secret_access_key => your_aws_secret_access_key
)

Parameters

  • options<~Hash> - config arguments for connection. Defaults to {}.

Returns

  • Lambda object with connection to AWS.



83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
# File 'lib/fog/aws/lambda.rb', line 83

def initialize(options={})
  @use_iam_profile    = options[:use_iam_profile]
  @connection_options = options[:connection_options] || {}
  @instrumentor       = options[:instrumentor]
  @instrumentor_name  = options[:instrumentor_name] || 'fog.aws.lambda'

  options[:region] ||= 'us-east-1'
  @region = options[:region]
  @host = options[:host] || "lambda.#{options[:region]}.amazonaws.com"

  @path       = options[:path]        || '/'
  @persistent = options[:persistent]  || false
  @port       = options[:port]        || 443
  @scheme     = options[:scheme]      || 'https'
  @version    = options[:version]     || '2015-03-31'
  @connection = Fog::Core::Connection.new("#{@scheme}://#{@host}:#{@port}#{@path}", @persistent, @connection_options)

  setup_credentials(options)
end

Instance Attribute Details

#regionObject (readonly)

Returns the value of attribute region.



103
104
105
# File 'lib/fog/aws/lambda.rb', line 103

def region
  @region
end

Instance Method Details

#add_permission(params = {}) ⇒ Object

Adds a permission to the access policy associated with the specified AWS Lambda function. docs.aws.amazon.com/lambda/latest/dg/API_AddPermission.html

Parameters

  • FunctionName <~String> - Name of the Lambda function whose access policy you are updating by adding a new permission.

  • Action <~String> - AWS Lambda action you want to allow in this statement.

  • Principal <~String> - principal who is getting this permission.

  • SourceAccount <~String> - AWS account ID (without a hyphen) of the source owner.

  • SourceArn <~String> - Amazon Resource Name (ARN) of the source resource to assign permissions.

  • StatemendId. <~String> - unique statement identifier.

Returns

  • response<~Excon::Response>:

    • body<~Hash>:

      • ‘Statement’ <~Hash> - permission statement you specified in the request.



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

def add_permission(params={})
  function_name  = params.delete('FunctionName')
  action         = params.delete('Action')
  principal      = params.delete('Principal')
   = params.delete('SourceAccount')
  source_arn     = params.delete('SourceArn')
  sid            = params.delete('StatementId')

  permission = {
    'Action'      => action,
    'Principal'   => principal,
    'StatementId' => sid
  }
  permission['SourceAccount'] =  if 
  permission['SourceArn']     = source_arn     if source_arn

  request({
    :method  => 'POST',
    :path    => "/functions/#{function_name}/versions/HEAD/policy",
    :expects => 201,
    :body    => Fog::JSON.encode(permission),
    :parser  => Fog::AWS::Parsers::Lambda::Base.new
  }.merge(params))
end

#create_event_source_mapping(params = {}) ⇒ Object

Identifies a stream as an event source for a Lambda function. docs.aws.amazon.com/lambda/latest/dg/API_CreateEventSourceMapping.html

Parameters

  • BatchSize <~Integer> - largest number of records that AWS Lambda will retrieve from your event source at the time of invoking your function.

  • Enabled <~Boolean> - indicates whether AWS Lambda should begin polling the event source.

  • EventSourceArn <~String> - Amazon Resource Name (ARN) of the stream that is the event source

  • FunctionName <~String> - Lambda function to invoke when AWS Lambda detects an event on the stream.

  • StartingPosition <~String> - position in the stream where AWS Lambda should start reading.

Returns

  • response<~Excon::Response>:

    • body<~Hash>:

      • ‘BatchSize’ <~Integer> - largest number of records that AWS Lambda will retrieve from your event source at the time of invoking your function.

      • ‘EventSourceArn’ <~String> - Amazon Resource Name (ARN) of the stream that is the source of events.

      • ‘FunctionArn’ <~String> - Lambda function to invoke when AWS Lambda detects an event on the stream.

      • ‘LastModified’ <~Time> - UTC time string indicating the last time the event mapping was updated.

      • ‘LastProcessingResult’ <~String> - result of the last AWS Lambda invocation of your Lambda function.

      • ‘State’ <~String> - state of the event source mapping.

      • ‘StateTransitionReason’ <~String> - reason the event source mapping is in its current state.

      • ‘UUID’ <~String> - AWS Lambda assigned opaque identifier for the mapping.



24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
# File 'lib/fog/aws/requests/lambda/create_event_source_mapping.rb', line 24

def create_event_source_mapping(params={})
  enabled          = params.delete('Enabled')
  batch_size       = params.delete('BatchSize')
  event_source_arn = params.delete('EventSourceArn')
  function_name    = params.delete('FunctionName')
  starting_pos     = params.delete('StartingPosition')

  data = {
    'EventSourceArn'   => event_source_arn,
    'FunctionName'     => function_name,
    'StartingPosition' => starting_pos
  }
  data.merge!('BatchSize' => batch_size) if batch_size
  data.merge!('Enabled'   => enabled)    if !enabled.nil?

  request({
    :method  => 'POST',
    :path    => '/event-source-mappings/',
    :expects => 202,
    :body    => Fog::JSON.encode(data)
  }.merge(params))
end

#create_function(params = {}) ⇒ Object

Creates a new Lambda function. docs.aws.amazon.com/lambda/latest/dg/API_CreateFunction.html

Parameters

  • Code <~Hash> - code for the Lambda function.

  • Description <~String> - short, user-defined function description.

  • FunctionName <~String> - name you want to assign to the function you are uploading.

  • Handler <~String> - function within your code that Lambda calls to begin execution.

  • MemorySize <~Integer> - amount of memory, in MB, your Lambda function is given.

  • Role <~String> - ARN of the IAM role that Lambda assumes when it executes your function to access any other AWS resources.

  • Runtime <~String> - runtime environment for the Lambda function you are uploading.

  • Timeout <~Integer> - function execution time at which Lambda should terminate the function.

Returns

  • response<~Excon::Response>:

    • body<~Hash>:

      • ‘CodeSize’ <~Integer> - size, in bytes, of the function .zip file you uploaded.

      • ‘Description’ <~String> - user-provided description.

      • ‘FunctionArn’ <~String> - Amazon Resource Name (ARN) assigned to the function.

      • ‘FunctionName’ <~String> - name of the function.

      • ‘Handler’ <~String> - function Lambda calls to begin executing your function.

      • ‘LastModified’ <~Time> - timestamp of the last time you updated the function.

      • ‘MemorySize’ <~Integer> - memory size, in MB, you configured for the function.

      • ‘Role’ <~String> - ARN of the IAM role that Lambda assumes when it executes your function to access any other AWS resources.

      • ‘Runtime’ <~String> - runtime environment for the Lambda function.

      • ‘Timeout’ <~Integer> - function execution time at which Lambda should terminate the function.



31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
# File 'lib/fog/aws/requests/lambda/create_function.rb', line 31

def create_function(params={})
  runtime       = params.delete('Runtime') || 'nodejs'
  code          = params.delete('Code')
  function_name = params.delete('FunctionName')
  handler       = params.delete('Handler')
  role          = params.delete('Role')

  data = {
    'Runtime'      => runtime,
    'Code'         => code,
    'FunctionName' => function_name,
    'Handler'      => handler,
    'Role'         => role
  }

  description = params.delete('Description')
  data.merge!('Description' => description) if description

  memory_size = params.delete('MemorySize')
  data.merge!('MemorySize' => memory_size)  if memory_size

  timeout = params.delete('Timeout')
  data.merge!('Timeout' => timeout) if timeout

  request({
    :method  => 'POST',
    :path    => '/functions',
    :expects => 201,
    :body    => Fog::JSON.encode(data),
    :parser  => Fog::AWS::Parsers::Lambda::Base.new
  }.merge(params))
end

#delete_event_source_mapping(params = {}) ⇒ Object

Removes an event source mapping. docs.aws.amazon.com/lambda/latest/dg/API_DeleteEventSourceMapping.html

Parameters

  • UUID <~String> - event source mapping ID.

Returns

  • response<~Excon::Response>:

    • body<~String>:



13
14
15
16
17
18
19
20
# File 'lib/fog/aws/requests/lambda/delete_event_source_mapping.rb', line 13

def delete_event_source_mapping(params={})
  mapping_id = params.delete('UUID')
  request({
    :method  => 'DELETE',
    :path    => "/event-source-mappings/#{mapping_id}",
    :expects => 202
  }.merge(params))
end

#delete_function(params = {}) ⇒ Object

Deletes the specified Lambda function code and configuration. docs.aws.amazon.com/lambda/latest/dg/API_DeleteFunction.html

Parameters

  • FunctionName <~String> - Lambda function to delete.

Returns

  • response<~Excon::Response>:

    • body<~String>:



13
14
15
16
17
18
19
20
# File 'lib/fog/aws/requests/lambda/delete_function.rb', line 13

def delete_function(params={})
  function_name = params.delete('FunctionName')
  request({
    :method  => 'DELETE',
    :path    => "/functions/#{function_name}",
    :expects => 204
  }.merge(params))
end

#get_event_source_mapping(params = {}) ⇒ Object

Returns configuration information for the specified event source mapping. docs.aws.amazon.com/lambda/latest/dg/API_GetEventSourceMapping.html

Parameters

  • UUID <~String> - AWS Lambda assigned ID of the event source mapping.

Returns

  • response<~Excon::Response>:

    • body<~Hash>:

      • ‘BatchSize’ <~Integer> - largest number of records that AWS Lambda will retrieve from your event source at the time of invoking your function.

      • ‘EventSourceArn’ <~String> - Amazon Resource Name (ARN) of the stream that is the source of events.

      • ‘FunctionArn’ <~String> - Lambda function to invoke when AWS Lambda detects an event on the stream.

      • ‘LastModified’ <~Time> - UTC time string indicating the last time the event mapping was updated.

      • ‘LastProcessingResult’ <~String> - result of the last AWS Lambda invocation of your Lambda function.

      • ‘State’ <~String> - state of the event source mapping.

      • ‘StateTransitionReason’ <~String> - reason the event source mapping is in its current state.

      • ‘UUID’ <~String> - AWS Lambda assigned opaque identifier for the mapping.

      • ‘Code’ <~Hash> - object for the Lambda function location.

      • ‘Configuration’ <~Hash> - function metadata description.



22
23
24
25
26
27
28
# File 'lib/fog/aws/requests/lambda/get_event_source_mapping.rb', line 22

def get_event_source_mapping(params={})
  mapping_id = params.delete('UUID')
  request({
    :method  => 'GET',
    :path    => "/event-source-mappings/#{mapping_id}"
  }.merge(params))
end

#get_function(params = {}) ⇒ Object

Returns the configuration information of the Lambda function. docs.aws.amazon.com/lambda/latest/dg/API_GetFunction.html

Parameters

  • FunctionName <~String> - Lambda function name.

Returns

  • response<~Excon::Response>:

    • body<~Hash>:

      • ‘Code’ <~Hash> - object for the Lambda function location.

      • ‘Configuration’ <~Hash> - function metadata description.



16
17
18
19
20
21
22
23
# File 'lib/fog/aws/requests/lambda/get_function.rb', line 16

def get_function(params={})
  function_name = params.delete('FunctionName')
  request({
    :method  => 'GET',
    :path    => "/functions/#{function_name}/versions/HEAD",
    :parser  => Fog::AWS::Parsers::Lambda::Base.new
  }.merge(params))
end

#get_function_configuration(params = {}) ⇒ Object

Returns the configuration information of the Lambda function. docs.aws.amazon.com/lambda/latest/dg/API_GetFunction.html

Parameters

  • FunctionName <~String> - Lambda function name.

Returns

  • response<~Excon::Response>:

    • body<~Hash>:

      • ‘CodeSize’ <~Integer> - size, in bytes, of the function .zip file you uploaded.

      • ‘Description’ <~String> - user-provided description.

      • ‘FunctionArn’ <~String> - Amazon Resource Name (ARN) assigned to the function.

      • ‘FunctionName’ <~String> - name of the function.

      • ‘Handler’ <~String> - function Lambda calls to begin executing your function.

      • ‘LastModified’ <~Time> - timestamp of the last time you updated the function.

      • ‘Memorysize’ <~String> - memory size, in MB, you configured for the function.

      • ‘Role’ <~String> - ARN of the IAM role that Lambda assumes when it executes your function to access any other AWS resources.

      • ‘Runtime’ <~String> - runtime environment for the Lambda function.

      • ‘Timeout’ <~Integer> - function execution time at which Lambda should terminate the function.



24
25
26
27
28
29
30
31
# File 'lib/fog/aws/requests/lambda/get_function_configuration.rb', line 24

def get_function_configuration(params={})
  function_name = params.delete('FunctionName')
  request({
    :method  => 'GET',
    :path    => "/functions/#{function_name}/versions/HEAD/configuration",
    :parser  => Fog::AWS::Parsers::Lambda::Base.new
  }.merge(params))
end

#get_policy(params = {}) ⇒ Object

Returns the access policy, containing a list of permissions granted via the AddPermission API, associated with the specified bucket. docs.aws.amazon.com/lambda/latest/dg/API_GetPolicy.html

Parameters

  • FunctionName <~String> - Function name whose access policy you want to retrieve.

Returns

  • response<~Excon::Response>:

    • body<~Hash>:

      • ‘Policy’ <~Hash> - The access policy associated with the specified function.



15
16
17
18
19
20
21
22
# File 'lib/fog/aws/requests/lambda/get_policy.rb', line 15

def get_policy(params={})
  function_name = params.delete('FunctionName')
  request({
    :method  => 'GET',
    :path    => "/functions/#{function_name}/versions/HEAD/policy",
    :parser => Fog::AWS::Parsers::Lambda::Base.new
  }.merge(params))
end

#invoke(params = {}) ⇒ Object

Invokes a specified Lambda function. docs.aws.amazon.com/lambda/latest/dg/API_Invoke.html

Parameters

  • ClientContext <~Hash> - client-specific information to the Lambda function you are invoking.

  • FunctionName <~String> - Lambda function name.

  • InvocationType <~String> - function invocation type.

  • LogType <~String> - logs format for function calls of “RequestResponse” invocation type.

  • Payload <~Integer> - Lambda function input.

Returns

  • response<~Excon::Response>:

    • body<~Hash> - JSON representation of the object returned by the Lambda function.



17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
# File 'lib/fog/aws/requests/lambda/invoke.rb', line 17

def invoke(params={})
  headers = {}
  if client_context = params.delete('ClientContext')
    headers['X-Amz-Client-Context'] =
      Base64::encode64(Fog::Json.encode(client_context))
  end
  if client_type = params.delete('InvocationType')
    headers['X-Amz-Client-Type'] = client_type
  end
  if log_type = params.delete('LogType')
    headers['X-Amz-Log-Type'] = log_type
  end
  payload = Fog::JSON.encode(params.delete('Payload'))
  function_name = params.delete('FunctionName')

  request({
    :method  => 'POST',
    :path    => "/functions/#{function_name}/invocations",
    :headers => headers,
    :body    => payload,
    :expects => [200, 202, 204]
  }.merge(params))
end

#list_event_source_mappings(params = {}) ⇒ Object

Returns a list of event source mappings where you can identify a stream as an event source. docs.aws.amazon.com/lambda/latest/dg/API_ListEventSourceMappings.html

Parameters

  • EventSourceArn <~String> - Amazon Resource Name (ARN) of the stream.

  • FunctionName <~String> - name of the Lambda function.

  • Marker <~String> - opaque pagination token returned from a previous ListEventSourceMappings operation.

  • MaxItems <~Integer> - maximum number of event sources to return in response.

Returns

  • response<~Excon::Response>:

    • body<~Hash>:

      • ‘EventSourceMappings’ <~Array> - array of EventSourceMappingConfiguration objects.

      • ‘NextMarker’ <~String> - present if there are more event source mappings.



17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
# File 'lib/fog/aws/requests/lambda/list_event_source_mappings.rb', line 17

def list_event_source_mappings(params={})
  event_source_arn = params.delete('EventSourceArn')
  function_name    = params.delete('FunctionName')
  marker           = params.delete('Marker')
  max_items        = params.delete('MaxItems')

  query = {}
  query.merge!('EventSourceArn' => event_source_arn) if event_source_arn
  query.merge!('FunctionName'   => function_name)    if function_name
  query.merge!('Marker'         => marker)           if marker
  query.merge!('MaxItems'       => max_items)        if max_items

  request({
    :method => 'GET',
    :path   => '/event-source-mappings/',
    :query  => query
  }.merge(params))
end

#list_functions(params = {}) ⇒ Object

Returns a list of your Lambda functions. docs.aws.amazon.com/lambda/latest/dg/API_ListFunctions.html

Parameters

  • Marker <~String> - opaque pagination token returned from a previous ListFunctions operation. If present, indicates where to continue the listing.

  • MaxItems <~Integer> - Specifies the maximum number of AWS Lambda functions to return in response.

Returns

  • response<~Excon::Response>:

    • body<~Hash>:

      • ‘Functions’ <~Array> - list of Lambda functions.

      • ‘NextMarker’ <~String> - present if there are more functions.



17
18
19
20
21
22
23
# File 'lib/fog/aws/requests/lambda/list_functions.rb', line 17

def list_functions(params={})
  request({
    :method => 'GET',
    :path   => '/functions/',
    :parser => Fog::AWS::Parsers::Lambda::Base.new
  }.merge(params))
end

#reloadObject



105
106
107
# File 'lib/fog/aws/lambda.rb', line 105

def reload
  @connection.reset
end

#remove_permission(params = {}) ⇒ Object

Remove individual permissions from an access policy associated with a Lambda function by providing a Statement ID. docs.aws.amazon.com/lambda/latest/dg/API_RemovePermission.html

Parameters

  • FunctionName <~String> - Lambda function whose access policy you want to remove a permission from.

  • StatementId <~String> - Statement ID of the permission to remove.

Returns

  • response<~Excon::Response>:

    • body<~String>:



14
15
16
17
18
19
20
21
22
# File 'lib/fog/aws/requests/lambda/remove_permission.rb', line 14

def remove_permission(params={})
  function_name = params.delete('FunctionName')
  statement_id  = params.delete('StatementId')
  request({
    :method  => 'DELETE',
    :path    => "/functions/#{function_name}/versions/HEAD/policy/#{statement_id}",
    :expects => 204
  }.merge(params))
end

#update_event_source_mapping(params = {}) ⇒ Object

Change the parameters of the existing mapping without losing your position in the stream. docs.aws.amazon.com/lambda/latest/dg/API_UpdateEventSourceMapping.html

Parameters

  • UUID <~String> - event source mapping identifier.

  • BatchSize <~Integer> - maximum number of stream records that can be sent to your Lambda function for a single invocation.

  • Enabled <~Boolean> - specifies whether AWS Lambda should actively poll the stream or not.

  • FunctionName <~String> - Lambda function to which you want the stream records sent.

Returns

  • response<~Excon::Response>:

    • body<~Hash>:

      • ‘BatchSize’ <~Integer> - largest number of records that AWS Lambda will retrieve from your event source at the time of invoking your function.

      • ‘EventSourceArn’ <~String> - Amazon Resource Name (ARN) of the stream that is the source of events.

      • ‘FunctionArn’ <~String> - Lambda function to invoke when AWS Lambda detects an event on the stream.

      • ‘LastModified’ <~Time> - UTC time string indicating the last time the event mapping was updated.

      • ‘LastProcessingResult’ <~String> - result of the last AWS Lambda invocation of your Lambda function.

      • ‘State’ <~String> - state of the event source mapping.

      • ‘StateTransitionReason’ <~String> - reason the event source mapping is in its current state.

      • ‘UUID’ <~String> - AWS Lambda assigned opaque identifier for the mapping.



23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
# File 'lib/fog/aws/requests/lambda/update_event_source_mapping.rb', line 23

def update_event_source_mapping(params={})
  function_name = params.delete('FunctionName')
  mapping_id    = params.delete('UUID')

  batch_size = params.delete('BatchSize')
  enabled    = params.delete('Enabled')

  update = {}
  update.merge!('BatchSize'    => batch_size)    if batch_size
  update.merge!('Enabled'      => enabled)       if !enabled.nil?
  update.merge!('FunctionName' => function_name) if function_name

  request({
    :method  => 'PUT',
    :path    => "/event-source-mappings/#{mapping_id}",
    :expects => 202,
    :body    => Fog::JSON.encode(update)
  }.merge(params))
end

#update_function_code(params = {}) ⇒ Object

Updates the code for the specified Lambda function. docs.aws.amazon.com/lambda/latest/dg/API_UpdateFunctionCode.html

Parameters

  • FunctionName <~String> - existing Lambda function name whose code you want to replace.

  • S3Bucket <~String> - Amazon S3 bucket name where the .zip file containing your deployment package is stored.

  • S3Key <~String> - Amazon S3 object (the deployment package) key name you want to upload.

  • S3ObjectVersion <~String> - Amazon S3 object (the deployment package) version you want to upload.

  • ZipFile <~String> - Based64-encoded .zip file containing your packaged source code.

Returns

  • response<~Excon::Response>:

    • body<~Hash>:

      • ‘CodeSize’ <~Integer> - size, in bytes, of the function .zip file you uploaded.

      • ‘Description’ <~String> - user-provided description.

      • ‘FunctionArn’ <~String> - Amazon Resource Name (ARN) assigned to the function.

      • ‘FunctionName’ <~String> - name of the function.

      • ‘Handler’ <~String> - function Lambda calls to begin executing your function.

      • ‘LastModified’ <~Time> - timestamp of the last time you updated the function.

      • ‘Memorysize’ <~String> - memory size, in MB, you configured for the function.

      • ‘Role’ <~String> - ARN of the IAM role that Lambda assumes when it executes your function to access any other AWS resources.

      • ‘Runtime’ <~String> - runtime environment for the Lambda function.

      • ‘Timeout’ <~Integer> - function execution time at which Lambda should terminate the function.



28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
# File 'lib/fog/aws/requests/lambda/update_function_code.rb', line 28

def update_function_code(params={})
  function_name = params.delete('FunctionName')

  s3_bucket     = params.delete('S3Bucket')
  s3_key        = params.delete('S3Key')
  s3_object_ver = params.delete('S3ObjectVersion')
  zip_file      = params.delete('ZipFile')

  update = {}
  update.merge!('S3Bucket'        => s3_bucket)     if s3_bucket
  update.merge!('S3Key'           => s3_key)        if s3_key
  update.merge!('S3ObjectVersion' => s3_object_ver) if s3_object_ver
  update.merge!('ZipFile'         => zip_file)      if zip_file

  request({
    :method  => 'PUT',
    :path    => "/functions/#{function_name}/versions/HEAD/code",
    :body    => Fog::JSON.encode(update),
    :parser  => Fog::AWS::Parsers::Lambda::Base.new
  }.merge(params))
end

#update_function_configuration(params = {}) ⇒ Object

Updates the configuration parameters for the specified Lambda function. docs.aws.amazon.com/lambda/latest/dg/API_UpdateFunctionConfiguration.html

Parameters

  • FunctionName <~String> - name of the Lambda function.

  • Description <~String> - short user-defined function description.

  • Handler <~String> - function that Lambda calls to begin executing your function.

  • MemorySize <~Integer> - amount of memory, in MB, your Lambda function is given.

  • Role <~String> - ARN of the IAM role that Lambda will assume when it executes your function.

  • Timeout <~Integer> - function execution time at which AWS Lambda should terminate the function.

Returns

  • response<~Excon::Response>:

    • body<~Hash>:

      • ‘CodeSize’ <~Integer> - size, in bytes, of the function .zip file you uploaded.

      • ‘Description’ <~String> - user-provided description.

      • ‘FunctionArn’ <~String> - Amazon Resource Name (ARN) assigned to the function.

      • ‘FunctionName’ <~String> - name of the function.

      • ‘Handler’ <~String> - function Lambda calls to begin executing your function.

      • ‘LastModified’ <~Time> - timestamp of the last time you updated the function.

      • ‘Memorysize’ <~String> - memory size, in MB, you configured for the function.

      • ‘Role’ <~String> - ARN of the IAM role that Lambda assumes when it executes your function to access any other AWS resources.

      • ‘Runtime’ <~String> - runtime environment for the Lambda function.

      • ‘Timeout’ <~Integer> - function execution time at which Lambda should terminate the function.



29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
# File 'lib/fog/aws/requests/lambda/update_function_configuration.rb', line 29

def update_function_configuration(params={})
  function_name = params.delete('FunctionName')

  description = params.delete('Description')
  handler     = params.delete('Handler')
  memory_size = params.delete('MemorySize')
  role        = params.delete('Role')
  timeout     = params.delete('Timeout')

  update = {}
  update.merge!('Description' => description) if description
  update.merge!('Handler'     => handler)     if handler
  update.merge!('MemorySize'  => memory_size) if memory_size
  update.merge!('Role'        => role)        if role
  update.merge!('Timeout'     => timeout)     if timeout

  request({
    :method  => 'PUT',
    :path    => "/functions/#{function_name}/versions/HEAD/configuration",
    :body    => Fog::JSON.encode(update),
    :parser  => Fog::AWS::Parsers::Lambda::Base.new
  }.merge(params))
end