6
5

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

Cloud SQL プライベートIPでの接続

Last updated at Posted at 2018-10-03

はじめに

Cloud SQLを使用する場合、今まではグローバルIPでの接続となるため、セキュリティを考慮し、cloud proxyやSSL等を使う事が推奨されていたが、今回、PrivateIPでの接続がベータで使えるようになったので試してみた。

公式
https://cloud.google.com/sql/docs/mysql/private-ip

インスタンスの作成

作成時、接続の設定でプライベートIPがチェック出来る様になっている。

image.png

作成後、プライベートIPが振られる。
image.png

接続確認

あとは作成時に指定したVPC(今回はdefault)から接続が可能なはずなのでGCEから接続。
繋がらない。。。

原因

Cloud SQLとGCEインスタンスのリージョンが異なっていた事が原因。

公式ページを見ると確かにリージョンは同一である事と書いてあった。
ちなみにゾーンは異なってもOKでした。

リージョン ゾーン 接続結果
同じ 同じ OK
同じ 異なる OK
異なる 異なる NG

終わりに

プライベートIPが使えるようになった事でオンプレの構成をそのままGCPに持っていく事がやっと可能になったー

6
5
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
6
5

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?