使用AWS SAM本地调用lambda访问通过VPC连接的AWS Neptune。

0

【以下的问题经过翻译处理】 我需要能够在本地调用一个lambda函数,该函数访问AWS Neptune。我已经通过EC2设置了SSH本地转发。如何在lambda函数中使用sam local invoke使其工作?

profile picture
EXPERT
asked 8 months ago63 views
1 Answer
0

【以下的回答经过翻译处理】 解决方案可能取决于您的桌面操作系统以及运行SAM CLI的位置。 Docker在每个操作系统上的行为都有所不同。在MacOS上运行时,如果我将'wss://docker.for.mac.localhost:8182/gremlin'作为我的Neptune端点(仅将gremlin更改为其他语言的ocsparql),我可以访问SSH隧道。我认为这也适用于host.docker.internal作为更通用的主机名,可以将其转发回桌面操作系统上的localhost

另一件需要考虑的事情是SSL验证。 Neptune不再允许您在集群端禁用SSL。如果您只是为了测试/开发而这样做,可以忽略SSL验证。特别是对于Gremlin,您可以通过在创建DriverRemoteConnection时添加verify_ssl=False参数来实现此功能:

conn = DriverRemoteConnection(neptune_endpoint, 'g', pool_size=1, message_serializer=serializer.GraphSONSerializersV2d0(), verify_ssl=False)
g = traversal().withRemote(conn)

profile picture
EXPERT
answered 8 months ago

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.

Guidelines for Answering Questions