AWS SDK for Ruby
Developer Guide

Configuring a Lambda Function to Receive Notifications

The following example configures the Lambda function named my-notification-function in the us-west-2 region to accept notifications from the resource with the ARN my-resource-arn.

require 'aws-sdk-lambda' # v2: require 'aws-sdk' client = Aws::Lambda::Client.new(region: 'us-west-2') args = {} args[:function_name] = 'my-notification-function' args[:statement_id] = 'lambda_s3_notification' args[:action] = 'lambda:InvokeFunction' args[:principal] = 's3.amazonaws.com' args[:source_arn] = 'my-resource-arn' client.add_permission{args]