Search code examples
scalaapache-sparksslaws-glueaws-glue-spark

Connecting to Presto database using AWS Glue. Unable to pass SSL Keystore or Certificate


I have issue connecting to Presto using AWS glue job. The code is written in Spark Scala. I am trying to connect to Presto using the below code.

val datanot_in_hz = sqlcontext.read.format("jdbc").option("url", jdbcConUrl).option("driver", "io.prestosql.jdbc.PrestoDriver").option("SSL","true").option("SSLKeyStorePath","s3://test/presto_client.keystore").option("query", datanot_in_hz_sql).option("user", dbUserName).option("password", dbPassword).load()

I get the below error

2020-12-18 20:36:52,376 ERROR [main] glue.ProcessLauncher (Logging.scala:logError(70)): Exception in User Class: java.sql.SQLException : Error setting up SSL: s3:/test/presto_client.keystore (No such file or directory) io.prestosql.jdbc.PrestoDriverUri.setupClient(PrestoDriverUri.java:235) io.prestosql.jdbc.PrestoDriver.connect(PrestoDriver.java:88) org.apache.spark.sql.execution.datasources.jdbc.JdbcUtils$$anonfun$createConnectionFactory$1.apply(JdbcUtils.scala:63) org.apache.spark.sql.execution.datasources.jdbc.JdbcUtils$$anonfun$createConnectionFactory$1.apply(JdbcUtils.scala:54) org.apache.spark.sql.execution.datasources.jdbc.JDBCRDD$.resolveTable(JDBCRDD.scala:56) org.apache.spark.sql.execution.datasources.jdbc.JDBCRelation$.getSchema(JDBCRelation.scala:210) org.apache.spark.sql.execution.datasources.jdbc.JdbcRelationProvider.createRelation(JdbcRelationProvider.scala:35) org.apache.spark.sql.execution.datasources.DataSource.resolveRelation(DataSource.scala:318) org.apache.spark.sql.DataFrameReader.loadV1Source(DataFrameReader.scala:223) org.apache.spark.sql.DataFrameReader.load(DataFrameReader.scala:211) org.apache.spark.sql.DataFrameReader.load(DataFrameReader.scala:167) sddsurwithDAXreporting$.main(sddsurwithDAXreportingPresto.scala:89) sddsurwithDAXreporting.main(sddsurwithDAXreportingPresto.scala) sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) java.lang.reflect.Method.invoke(Method.java:498) com.amazonaws.services.glue.SparkProcessLauncherPlugin$class.invoke(ProcessLauncher.scala:38) com.amazonaws.services.glue.ProcessLauncher$$anon$1.invoke(ProcessLauncher.scala:67) com.amazonaws.services.glue.ProcessLauncher.launch(ProcessLauncher.scala:108) com.amazonaws.services.glue.ProcessLauncher$.main(ProcessLauncher.scala:21) com.amazonaws.services.glue.ProcessLauncher.main(ProcessLauncher.scala)

I tried passing pem certificate but still it fails with the same error. I have checked all the permission. I have a jar file which I access from the same folder, I am able to access that. When I run the same code from my machine using Eclipse it runs fine. Can someone please help? I am fairly new to scala and this is my first attempt in using SSL certificate to connect to a database.


Solution

  • AWS support recommended to copy file from S3 to tmp folder as during runtime as Glue was not able to read the path correctly