Boto3 - sqs get_queue_url 导致 QueueDoesNotExist
Boto3 - sqs get_queue_url results in QueueDoesNotExist
我正在尝试从 SQS 队列中读取。为此,我需要获取队列 url。这是我的代码
sts = boto3.client('sts')
print('running as:')
pp.pprint(sts.get_caller_identity())
sqs = boto3.client('sqs')
queue_name = settings.SQS_JOBS_TASK_RESULTS_QUEUE
print('getting queue_name: ', queue_name)
res = sqs.get_queue_url(QueueName=queue_name)
从上面的代码可以看出我也在验证我的身份。
sqs.get_queue_url 总是失败
botocore.errorfactory.QueueDoesNotExist: An error occurred (AWS.SimpleQueueService.NonExistentQueue) when calling the GetQueueUrl operation: The specified queue does not exist or you do not have access to it.
我已经从 AWS Web 控制台复制粘贴了队列名称。仍然失败。
我知道我的权限没问题,因为如果我跳过这一步,从 Web 控制台复制粘贴 url 并直接跳转到读取和写入队列,就可以了。
我在这里错过了什么?
当我写这个问题时,我得到了一个灯泡,可能有一个特定的权限来获取队列 url。
瞧瞧,确保您不要忘记在您的政策中添加 sqs:GetQueueUrl
。
{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Action": [
"sqs:GetQueueAttributes",
"sqs:SendMessage",
"sqs:ReceiveMessage",
"sqs:DeleteMessage",
"sqs:DeleteMessageBatch",
"sqs:GetQueueUrl"
],
"Resource": "arn:aws:sqs:xxxxxxxxx"
}
]
}
我正在尝试从 SQS 队列中读取。为此,我需要获取队列 url。这是我的代码
sts = boto3.client('sts')
print('running as:')
pp.pprint(sts.get_caller_identity())
sqs = boto3.client('sqs')
queue_name = settings.SQS_JOBS_TASK_RESULTS_QUEUE
print('getting queue_name: ', queue_name)
res = sqs.get_queue_url(QueueName=queue_name)
从上面的代码可以看出我也在验证我的身份。
sqs.get_queue_url 总是失败
botocore.errorfactory.QueueDoesNotExist: An error occurred (AWS.SimpleQueueService.NonExistentQueue) when calling the GetQueueUrl operation: The specified queue does not exist or you do not have access to it.
我已经从 AWS Web 控制台复制粘贴了队列名称。仍然失败。
我知道我的权限没问题,因为如果我跳过这一步,从 Web 控制台复制粘贴 url 并直接跳转到读取和写入队列,就可以了。
我在这里错过了什么?
当我写这个问题时,我得到了一个灯泡,可能有一个特定的权限来获取队列 url。
瞧瞧,确保您不要忘记在您的政策中添加 sqs:GetQueueUrl
。
{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Action": [
"sqs:GetQueueAttributes",
"sqs:SendMessage",
"sqs:ReceiveMessage",
"sqs:DeleteMessage",
"sqs:DeleteMessageBatch",
"sqs:GetQueueUrl"
],
"Resource": "arn:aws:sqs:xxxxxxxxx"
}
]
}