无法从我的 ubuntu EC2 机器连接到 AWS DocumentDB

Not able to connect to AWS DocumentDB from my ubuntu EC2 machine

我无法从我的 Amazon EC2 ubuntu 机器连接到我的 Amazon DocumentDB?我已经检查了 Amazon DocumentDB 的安全性,它目前被分配给具有 "all traffic".

的默认值

尽管我收到了下面包含的错误消息,但我已经尝试了直接从 AWS 实例页面执行以下命令。

我已遵循此 aws 指南 https://docs.aws.amazon.com/documentdb/latest/developerguide/getting-started.connect.html

Mongo shell 来自 EC2 ubuntu 机器的命令

mongo --ssl --host mydatabasename.23scnncsd3.eu-west-1.docdb.amazonaws.com:27017 --sslCAFile rds-combined-ca-bundle.pem --username webuser --password mypassword

我在 ubuntu 命令提示符中收到的错误消息如下

错误信息

MongoDB shell version v3.6.11
connecting to: mongodb://mydatabasename.23scnncsd3.eu-west-1.docdb.amazonaws.com:27017/?gssapiServiceName=mongodb
2019-03-11T21:39:37.587+0000 W NETWOK  [thread1] Failed to connect to 172.31.45.184:27017 after 5000ms milliseconds, giving up.
2019-03-11T21:39:37.595+0000 E QUERY    [thread1] Error: couldn't connect to server mydatabasename.23scnncsd3.eu-west-1.docdb.amazonaws.com:27017, connection attempt failed :
connect@src/mongo/shell/mongo.js:263:13
@(connect):1:6
exception: connect failed

我做错了什么吗?感谢任何帮助!

非常感谢,

更新

A​​mazon DocumentDB 在 VPC 内部署集群,作为其他 VPC 和 Internet 的强大网络边界。当您连接到集群时,请确保客户端计算机与集群位于同一区域和同一 VPC 中。

或者,如果您的开发环境位于不同的 Amazon VPC 中,您还可以使用 VPC Peering 并从同一区域或不同区域中的另一个 Amazon VPC 连接到您的 Amazon DocumentDB 集群。

有关故障排除的更多信息:https://docs.aws.amazon.com/documentdb/latest/developerguide/troubleshooting.html

从 VPC 外部连接到 Amazon DocumentDB 集群:https://docs.aws.amazon.com/documentdb/latest/developerguide/connect-from-outside-a-vpc.html