AWS Ruby Lambda Layer with Mysql2

Hey there, I’m trying to create a MySQL2 dependency layer for my Ruby 2.7 lambda functions.

I’ve got a Lambda Layer

  Type: AWS::Serverless::LayerVersion
    LayerName: ruby-2.7-lambda-dependencies
    Description: Dependencies for ruby lambda functions
    ContentUri: ../pt-lambda/rubyLayer2
      - ruby2.7
    RetentionPolicy: Retain

that I’m using to package up my dependencies, most notably mysql2.

However when I invoke a lambda that uses this layer, I received the dreaded: “ cannot open shared object file: No such file or directory - /opt/ruby/gems/2.7.0/gems/mysql2-0.5.3/lib/mysql2/” error.

I’ve confirmed that all necessary .so files live in /opt/lib and the program is able to call the /opt/ruby/gems/2.7.0/gems/mysql2-0.5.3/lib/mysql2.rb file, but it throws that error right after when the file is required.

Not sure what’s going on but could use some guidance, any help is appreciated. thanks!