AWS Aurora MySQL serverless: how to connect from MySQL Workbench

前端 未结 8 1222
忘掉有多难
忘掉有多难 2020-12-13 18:46

I was trying to use AWS Aurora Serverless for MySQL in my project, but I am impossible to connect to it, though I have the endpoint, username, password.

What I have

8条回答
  •  孤城傲影
    2020-12-13 19:13

    A common pattern used by customers for connecting to VPC only services (like Aurora Serverless, Amazon Neptune, Amazon DocDB etc) is to have a middle layer (EC2 instance, or ALB etc) and making the middle layer accessible from outside the VPC. If your use case is just trying out some queries or connecting a workbench, then the easiest thing to do is:

    1. Resolve the DNS of the serverless db and obtain its IP
    2. Create an ALB in your VPC, with a target group to the IP that you found in #1
    3. Create a new security group and attach that to your ALB
    4. Update the SG to allow inbound from where ever you want. If you want public internet access, then allow inbound from all IPs, enable an internet gateway in your VPC, and use a public subnet for your ALB.

    Once all of this is done, you would end up with a new DNS - that points to your ALB. Make sure that your ALB is set up correctly by:

    1. Using telnet to connect to your ALB endpoint. telnet alb-endpoint alb-port. If it succeeds, then you have a full end to end connection (not jsut to your ALB, but all the way through).
    2. Verify ALB metrics to make sure that all health checks are passing.

    Once this is done, use the ALB endpoint in workbench, and you are good to go.

    This pattern is recommended only for non production systems. The concerning step is the one where you resolve the DNS to an IP - that IP is ephemeral, it can change when scale compute or failover happens in the background.

    Hope this helps, let me know if you need more details on any step. Here is a related answer for Neptune:

    Connect to Neptune on AWS from local machine

提交回复
热议问题