AWS BOTO3 SQS端点URL问题

发布于 2025-02-08 04:38:02 字数 584 浏览 3 评论 0原文

我们有一个Lambda功能,将消息发送到SQS队列。 我们正在使用boto3。

我们已经建立了一个新的环境,Lambda正在私人子网上的VPC运行。 VPC终点是com.amazonaws.eu-west-2.sqs

lambda代码,

sqs = boto3.resource('sqs')
# Get the queue

queue = sqs.get_queue_by_name(QueueName=QueueID)

这给了我们以下错误 EndpointConnectionError:无法连接到端点URL:“ https://eu-west-2.queue.amazonaws.com/“

我们尝试了以下更改

sqs = boto3.client('sqs')
# Get the queue
queue = sqs.get_queue_url(QueueName=QueueID, QueueOwnerAWSAccountId='xxxxxxxxxxxx')

,我们遇到了相同的错误

,这是一个传统端点问题,但我们不知道如何在lambda函数中使用新端点。

We have a Lambda function that sends messages to SQS queue.
We are using boto3.

We have built a new environment and Lambda is running in a VPC on a private subnet.
The VPC end point is com.amazonaws.eu-west-2.sqs

Lambda code

sqs = boto3.resource('sqs')
# Get the queue

queue = sqs.get_queue_by_name(QueueName=QueueID)

This gives us the following error
EndpointConnectionError: Could not connect to the endpoint URL: "https://eu-west-2.queue.amazonaws.com/"

We have tried the following change

sqs = boto3.client('sqs')
# Get the queue
queue = sqs.get_queue_url(QueueName=QueueID, QueueOwnerAWSAccountId='xxxxxxxxxxxx')

We get the same error

It is a legacy endpoint issue but we do not know how to use the new endpoints in the Lambda function.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

游魂 2025-02-15 04:38:02

因为您使用的是SQS的VPC端点,因此需要覆盖BOTO3默认使用的地址。

这样的事情:

sqs = boto3.resource('sqs', endpoint_url="https://com.amazonaws.eu-west-2.sqs")

Because you're using a VPC endpoint for SQS you need to override the address that boto3 is using by default.

Something like this:

sqs = boto3.resource('sqs', endpoint_url="https://com.amazonaws.eu-west-2.sqs")
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文