nijeesh4all / lambda_pg_activerecord_layer

This is an lambda layer with the depemdencies and shared libraries for making both active record and pg gem work with lambdas

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

 # lambda_pg_activerecord_layer


This is an lambda layer for making activerecord and pg work with aws lamda. when deploying to lambda compiling for that enviornment is a real pain.

i am making this as a repo hopping it can redude your suffering atleast a little bit.


gems included 

1. pg - 1.1.3 
2. activerecord - 6.0.2.2


just run `zip -r deployment.zip ./ruby/ ./lib/` for creating the deployment package.


Thanks to @mphsi for the initail code that i used to build upon

https://github.com/mphsi/ruby_lambda_pg_layer

# the section under is copy pasted and transalted from https://github.com/mphsi/ruby_lambda_pg_layer 's readme


Lambda layer designed to include the 'pg' gem in lambda-ruby functions.

Under the / ruby directory are all files generated after running 'bundle install --path =.'.
Under the / lib directory are the dependencies for the gem. These files I extracted from my computer.

To create the layer in aws lambda it is necessary to create the package (.zip) with the following command 'zip -r pg.zip ./ruby/ ./lib/'.

This layer was built for the ruby-2.5.0 runtime using version 1.1.3 of the 'pg' gem and is expected to be used with Postgres 11.

To use the new_connection method it is necessary to pass as params. a hash like the following:
  {'host' => host, 'database' => database, 'username' => username, 'password' => password}

Important: In the lambda function configuration it is necessary to overwrite the environment variable GEM_PATH with '/opt/ruby/2.5.0'.
See more at: https://medium.com/devopslinks/how-to-use-aws-lambda-layers-f4fe6624aff1


About

This is an lambda layer with the depemdencies and shared libraries for making both active record and pg gem work with lambdas


Languages

Language:Ruby 80.1%Language:Java 13.3%Language:C 6.4%Language:Makefile 0.2%Language:CSS 0.0%Language:HTML 0.0%