Has anyone created a (native backend) holy-lambda function that connets to an RDS Mysql database?
I keep getting this error... (db hostname edited to avoid leaking 馃檪 )
{:type com.zaxxer.hikari.pool.HikariPool$PoolInitializationException, :message "Failed to initialize pool: Cannot connect to MySQL server on
not sure if I've forgotten some dependencies or something else is going on. The same code and config works perfectly on my machine, but doens't work when using sam local invoke or when running in Lambda.
same RDS database, same credentials
Do you have all the permissions set on Lambda?
yes I was about to write that, VPC, security groups, and the execution role allowing VPC access are all set
I wonder if these extra stack trace elements might help...
[com.mysql.cj.jdbc.*exceptions*.SQLError createSQLException "SQLError.java" 110]} {:type java.lang.ClassCastException, :message "com.mysql.cj.*exceptions*.CJException cannot be cast to com.mysql.cj.*exceptions*.UnableToConnectException", :at [com.mysql.cj.jdbc.ConnectionImpl createNewIO "ConnectionImpl.java" 825]}], :trace [[com.mysql.cj.jdbc.ConnectionImpl createNewIO "ConnectionImpl.java" 825] [com.mysql.cj.jdbc.ConnectionImpl <init> "ConnectionImpl.java" 448] [com.mysql.cj.jdbc.ConnectionImpl getInstance "ConnectionImpl.java" 241] [com.mysql.cj.jdbc.NonRegisteringDriver connect "NonRegisteringDriver.java" 198] [com.zaxxer.hikari.util.DriverDataSource getConnection "DriverDataSource.java" 121] [com.zaxxer.hikari.pool.PoolBase newConnection "PoolBase.java" 358] [com.zaxxer.hikari.pool.PoolBase newPoolEntry "PoolBase.java" 206] [com.zaxxer.hikari.pool.HikariPool createPoolEntry "HikariPool.java" 477] [com.zaxxer.hikari.pool.HikariPool checkFailFast "HikariPool.java" 560] [com.zaxxer.hikari.pool.HikariPool <init> "HikariPool.java" 115] [com.zaxxer.hikari.HikariDataSource <init> "HikariDataSource.java" 81] [hikari_cp.core$make_datasource invokeStatic "core.clj" 265]
the part that gets me is that this happens on AWS Lambda or in sam local invoke, so I don't think it's about security groups or IAM roles or VPCs or anything of the sorts...
the same code/configuration works when I invoke it directly at the repl or in a test
Btw, why you want to use hikari for Lambda? Connection pool doesnt make sense for Lambda environment.
hmmm it's not a matter of "want" but a matter of "copy pasting my code from other applications to use mysql in this one" 馃槈
Ok, just for your information using connection pool is risky. You will quickly kill the connection limit.
that explains a lot, I've done that in my dev env already lol
I would try without Hikari.
ok, let me try that first and see how it goes
okay, after ripping out conman (which was bringing in Hikari) and simplifying a few things, sam local invoke is now working properly. Deploying now to Lambda, fingers crossed.. but already very promising ,thanks for the tip @karol.wojcik!
confirmed, DB connection is now working in Lambda as well! can't say "thanks" enough @karol.wojcik 馃檪
You are very welcome 馃槈