我有一个AWS访问密钥,并且已经创建了一个SQS队列,但仍然无法使用python boto访问SQS
作者:互联网
因此,我有一个AWS访问密钥ID及其相应的AWS秘密密钥.此外,从AWS仪表板中,我已经在SQS中创建了一个队列,并将测试消息放入该队列中.我已经下载了适用于Python的boto.但是,当我尝试运行最基本的命令时,出现错误:
import boto.sqs
conn = boto.sqs.connect_to_region('us-west-2',
aws_access_key_id = settings.AWSAccessKeyId,
aws_secret_access_key = settings.AWSSecretKey)
print conn.get_all_queues()
exit()
我收到以下错误:
Traceback (most recent call last):
File "my_prog.py", line 43, in <module>
print conn.get_all_queues()
File "/usr/local/lib/python2.7/dist-packages/boto/sqs/connection.py", line 446, in get_all_queues
return self.get_list('ListQueues', params, [('QueueUrl', Queue)])
File "/usr/local/lib/python2.7/dist-packages/boto/connection.py", line 1186, in get_list
raise self.ResponseError(response.status, response.reason, body)
boto.exception.SQSError: SQSError: 403 Forbidden
<?xml version="1.0"?>
<ErrorResponse xmlns="http://queue.amazonaws.com/doc/2012-11-05/">
<Error>
<Type>Sender</Type>
<Code>OptInRequired</Code>
<Message>The AWS Access Key Id needs a subscription for the service.</Message>
<Detail/>
</Error>
<RequestId>45255e1e-aaff-548b-9d71-105bda134530</RequestId>
</ErrorResponse>
密钥是正确的,我正在其他环境中成功使用它们.
解决方法:
我一直在努力奋斗了几个小时,在我将问题发布到这里之后,我便找到了答案.
诀窍在于,显然您不能为此使用AWS根密钥,您必须创建一个IAM用户并向该用户授予SQS权限.
标签:amazon-web-services,amazon-sqs,boto,python 来源: https://codeday.me/bug/20191119/2039570.html