Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Current code from a Ruby 3.3 Lambda #37

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

jordan-brough
Copy link
Contributor

I'm opening this PR as an FYI for the community.

The code in the main branch of this repo is currently outdated (as of 2025-01-24) and has some issues with newer versions of Ruby. This PR provides the source code for aws_lambda_ric from a Ruby 3.3 Lambda.

Just FYI in case it's helpful for someone who needs to roll their own version of this gem with a modern version of Ruby.

Code I ran in a Lambda to query the source code
require "aws-sdk-s3"
require "json"

def lambda_handler(event:, context:)
  s3 = Aws::S3::Client.new
  bucket = "my-bucket"
  base_dir = "/var/runtime/gems/aws_lambda_ric-3.0.0"

  Dir.glob("#{base_dir}/**/*").each do |path|
    next if File.directory?(path)
    key = path.sub("#{base_dir}/", "")

    File.open(path, "rb") do |file|
      s3.put_object(bucket:, key:, body: file)
    end
  end
end

Note: Tests aren't included in the source code so updated tests aren't in this PR.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant