AthenaにVPCエンドポイント経由でJDBC接続できるようになったが少し詰まった話

こちらのリリースにあるようにAthenaにVPCエンドポイント経由で接続できるようになりました。これで、プライベートなサブネットからもJDBC接続できるようになりました!

aws.amazon.com

試してみる

早速、前に記事書いたこちらのDockerイメージでテストしてみました。

yomon.hatenablog.com

このイメージはこちらのAthenaJDBC42のJDBCドライバーを利用しています。 https://docs.aws.amazon.com/ja_jp/athena/latest/ug/connect-with-jdbc.htmldocs.aws.amazon.com

何故か止まる

処理が止まる。名前も引けるし、AWS CLIも通るし、何が悪いのか。

デバッグログを見てみたら。あ、Glueのカタログ取れないで止まっている・・

log4j:WARN No appenders could be found for logger (com.simba.athena.amazonaws.AmazonWebServiceClient).
log4j:WARN Please initialize the log4j system properly.
log4j:WARN See http://logging.apache.org/log4j/1.2/faq.html#noconfig for more info.
Oct 09 10:27:20.798 TRACE 1 com.simba.athena.athena.api.AJClient.checkGlueSupport(): +++++ enter +++++
Oct 09 10:27:20.800 DEBUG 1 com.simba.athena.athena.api.AJClient.checkGlueSupport: Performing AWS Glue availability detection.
Oct 09 10:27:20.801 DEBUG 1 com.simba.athena.athena.api.AJClient.checkGlueSupport: Aws::Glue - GlueClient - getCatalogImportStatus +++++ enter +++++

一応、最新のドライバの場合のログも貼っておきます。

Oct 09 11:06:54.412 DEBUG 1 com.simba.athena.athena.api.AJClient.buildGlueClient: Building Glue client with region = 'ap-northeast-1'.
Oct 09 11:06:54.727 DEBUG 1 com.simba.athena.athena.api.AJClient.AJClient: Building Athena Streaming client with endpoint = 'https://athena.ap-northeast-1.amazonaws.com:444' and region = 'ap-northeast-1'.
Oct 09 11:06:54.751 TRACE 1 com.simba.athena.athena.api.AJClient.checkGlueSupport(): +++++ enter +++++
Oct 09 11:06:54.752 DEBUG 1 com.simba.athena.athena.api.AJClient.checkGlueSupport: Performing AWS Glue availability detection.
Oct 09 11:06:54.756 DEBUG 1 com.simba.athena.athena.api.AJClient.checkGlueSupport: Aws::Glue - GlueClient - getCatalogImportStatus +++++ enter +++++
Oct 09 11:06:54.757 DEBUG 1 com.simba.athena.athena.api.AJClient.checkGlueSupport: Build a test AWS Glue Client with the retry policy.
Oct 09 11:06:54.757 TRACE 1 com.simba.athena.athena.api.AJClient.buildGlueClient(): +++++ enter +++++
Oct 09 11:06:54.758 DEBUG 1 com.simba.athena.athena.api.AJClient.buildGlueClient: Building Glue client with region = 'ap-northeast-1'.

結論

内部的な動きを理解してなかったので、少し詰まりましたが、Glueのエンドポイントも有効化することでカタログ取得できてAthenaにVPC Endpoint経由でJDBC接続できるようになりました。

他のハマりポイント

AthenaのStream APIは444ポートを使うので、その点も要注意です。