I'm having trouble when trying to connect my PostgresDB host in EC2 from Lambda. I'm using Ruby 2.7 runtime.
When I try to install gem 'pg', deploy the gem folder vendor to Lambda. Then I require 'pg' in lambda function, it just has an error message: 'Task timed out'.
Do I need to deploy any postgres-client lib for Amazon Linux 2 or gem is enough?
Here is my code.
$LOAD_PATH.unshift *Dir['./vendor/bundle/ruby/2.7.0/gems/**/lib']
$LOAD_PATH.unshift *Dir['./vendor/bundle/ruby/2.7.0/gems/pg-1.2.3/lib']
require 'json'
require 'net/http'
require 'active_record'
require 'pg'
def lambda_handler(event:, context:)
{ statusCode: 200 }
end