无法从外部连接到AWS RDS Aurora (MySQL)集群



从外部连接到RDS Aurora Serverless (v1) MySQL集群时,连接握手超时。

我在terraform中指定集群及其安全组,并为帐户/区域利用默认的AWS VPC。

集群参数:

cluster_identifier = "some-cluster-name",
engine = "aurora-mysql",
engine_mode = "serverless",
database_name = "db",
master_username = "********",
master_password = "********",
backup_retention_period = 5,
preferred_backup_window = "07:00-09:00",
skip_final_snapshot = true,
storage_encrypted = true,
scaling_configuration = {
max_capacity = 4,
min_capacity = 1,
seconds_until_auto_pause = 300
},
vpc_security_group_ids = ["${aws_security_group.my_sg_defined_elsewhere.id}"]

安全组规则

type = "ingress",
from_port = 3306,
to_port = 3306,
protocol = "tcp",
cidr_blocks = ["0.0.0.0/0"],
ipv6_cidr_blocks = ["::/0"],
security_group_id = "${aws_security_group.my_sg_defined_elsewhere.id}"
type = "egress",
from_port = 0,
to_port = 0,
protocol = "-1",
cidr_blocks = ["0.0.0.0/0"],
ipv6_cidr_blocks = ["::/0"],
security_group_id = "${aws_security_group.my_sg_defined_elsewhere.id}"  

因为我只是使用默认的VPC,我相信它有公共子网,我假设如果我的安全组规则足以用于公共MySQL访问,那么这应该只是工作。不幸的是,使用集群生成的端点和正确的凭据,我只是在尝试连接时得到一个超时。

为了结束这个问题,由于进一步的搜索和上面Mark B的评论,我可以确认我错过了Aurora Serverless v1不支持公共端点的事实,所以我的安全组没有任何帮助。这显然是可能的与v2,但由于它不是真正的无服务器(不会减少到零),它不是我的选择。希望这能帮大家省去一些麻烦!

您可以通过ec2实例隧道路由请求,该隧道使用API Gateway来控制lambda函数,以便根据需要启动和停止实例,因此您的AWS资源仍然可以缩减到零。

作为旁注,lambda延迟与无服务器v1冷启动时间相比微不足道。

最新更新