Golang から AWS DocumentDB につなぐ

at 2019-08-23 08:18 (UTC)

Golang から AWS の DocumentDB につなぎたかったんだけどうまくいかなかった。

mongodb://<yourMasterPassword>:<insertYourPassword>@<endpoint>:27017/?ssl=true&ssl_ca_certs=rds-combined-ca-bundle.pem&replicaSet=rs0

コントロールパネルだとこんな接続文字列で接続しろと書いてある。(↓の場所ね)

Image from Gyazo

ところがこれでは動かなくて プログラムによる Amazon DocumentDB への接続 - Amazon DocumentDB の Go サンプルのような接続文字列じゃないとダメだった。

mongodb://<yourMasterPassword>:<insertYourPassword>@<endpoint>:27017/?ssl=true&sslcertificateauthorityfile=rds-combined-ca-bundle.pem&replicaSet=rs0

ssl_ca_certs → sslcertificateauthorityfile ということだ。

他のサンプルも覗いてみたけど、コントロールパネルにある接続文字列は Python 用のようだ。