0
1

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 1 year has passed since last update.

EC2 Instance Connect Endpoint経由でElastiCacheにも接続しちゃう話

0
Posted at

背景

Twitter でプロフィール写真変えているのにここではそのままになっている @___nix___ です。

さて、

EC2 Instance Connect Endpoint経由でRDSに接続してみた

の記事から始まり、次のステップとして

[祝!]EC2 Instance Connect Endpoint経由でRDS(3389)に接続できた話

までできましたね。

更に先に進みましょう。

何するの?

前回は RDS に接続できたので、今回は ElastiCache に接続してみましょう。

構築手順

基本的な手順は同じですのでこちらも併せてご覧ください。
[祝!]EC2 Instance Connect Endpoint経由でRDS(3389)に接続できた話

ElastiCache と VPCエンドポイント用に SecurityGroup を準備

ここでも省略しますが、クラメソさんの記事を参考にしてください。

ElastiCache(Redis) を構築

もちろん 3389 ポートで。

VPCエンドポイントも構築

こちらのスクショも使い回しです。

ElastiCache(Redis) のプライベートIPを調べる

host xxxxxxxx.xxxxxx.ng.0001.apne1.cache.amazonaws.com
172.31.62.7

VPCエンドポイントのIDを調べる

これはAWSマネージドコンソールから取得してください。

open-tunnel を実行

3389 を 13389 にポートフォアディングします。

/usr/local/bin/aws ec2-instance-connect open-tunnel --instance-connect-endpoint-id eice-0af4f69191c240d32 --private-ip-address 172.31.62.7 --local-port 13389 --remote-port 3389 &

以下のメッセージが出ればOKです。

Listening for connections on port 13389.

redis-cli で接続してみる

もうここまで来るとドキドキはありません。

redis-cli -h 127.0.0.1 -p 13389
[1] Accepted new tcp connection, opening websocket tunnel.
127.0.0.1:13389> ping
PONG
127.0.0.1:13389> quit
[1] Closing tcp connection.

はい、接続できちゃいました。

編集後記

基本的にポートを変更できて 22 か 3389 に変更できるAWSリソースであれば接続できてしまうのではないかと思われます。

AWSリソースへのアクセスだけでなく、色々と想像が膨らむわけですが、これ以上の詮索はやめておきましょう。

悪い使い方はせずに正しく使おう!

0
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
0
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?