LoginSignup
1
1

More than 3 years have passed since last update.

NLBでTLS終端を行いAtlasのLiveMigrationを行う

Posted at

MongoDB AtlasのLiveMigrationを用いるときの覚書2

前回 AWS上のMongoDBをAtlasにLiveMigrationする の続き

Atlas上でLiveMigrationを実行する際、Is SSL enabled? というトグルスイッチがある。

Atlasのドキュメントでは

If the source cluster uses TLS/SSL, toggle the SSL button.
If the source replica set uses TLS/SSL and is not using a public Certificate Authority (CA), copy the contents of the source cluster’s CA file into the provided text box.

とある。
これは LiveMigrationのバックエンドである mongomirror シェルにおける --ssl オプション に該当しているものと考えられる。

もともとEC2上のDBサーバーは、同一のプライベートサブネット内のAPサーバーからのみアクセスされており、TLS/SSL起動オプションは指定していない。

今回LiveMigrationを利用するためインターネット経由でDBサーバーへアクセスできるようにする必要があり、そのためにNLBを導入した。
インターネットを経由するので、Is SSL enabled?は有効にして、Atlasとの通信は暗号化したい。
TLS/SSL起動オプションを付与してDBサーバーを再起動することは避けたいため、NLBにてTLS終端することで、この課題を解決する。
下図の1の通信が該当する。

[Atlas LiveMigration] <-1-> [NLB] <-2-> [MongoDB on EC2]

方法は以下の通り、
1. NLBのListenerの設定を TLS 27017とする。
2. 証明書はACMに存在するものを利用する。
3. ターゲットグループ側のProtocol/PortはTCP 27017にする。
4. Route53で所有するドメインにおいて任意のサブドメインを作成し、NLBへのエイリアスに紐付ける。

こうすると、

コマンド 接続可否
mongo mongodb://<LBのDNS> --ssl
mongo mongodb://<LBのDNS> --ssl --sslAllowInvalidCertificates
mongo mongodb://<Route53で設定したDNS>
mongo mongodb://<Route53で設定したDNS> --ssl

となる。

AtlasでLiveMigrationのHostには、<Route53で設定したDNS> を利用することで安全にLiveMigrationが利用できる。

参考
- Amazon Web Services ブログ 新機能 – Network Load Balancer の TLS 終端

1
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
1