AWS sqs队列未列出所有队列 [英] AWS sqs queues don't list all queues

查看:109
本文介绍了AWS sqs队列未列出所有队列的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是AWS的新手. 我正在关注AWS教程快速入门. 我一直在关注AWS sqs代码和sqs文档.

I am new to AWS. I am following AWS tutorials quick start. I was following the AWS sqs code and sqs documentation.

这是我编写的以下代码

import boto3
from boto3.session import Session

session = Session(aws_access_key_id="aswe343ffsf34r3fef3f",
                       aws_secret_access_key="3423d23r2fwwfe232r2r",
                    region_name="ap-southeast-1")

sqs = session.resource("sqs")
q_client = boto3.client("sqs")


sqs.create_queue(QueueName='test-One',
            Attributes = {'DelaySeconds': '5'
})


sqs.create_queue(QueueName='test-Three',
            Attributes = {'DelaySeconds': '5' })

#print "The queue path is : ",queue.url
#print dict(queue.attributes)
#print " DILAY  ",queue.attributes.get("DelaySeconds")

q_client.create_queue(QueueName='test-Two',Attributes = {
    "DelaySeconds" : "5"
})

#q_client.delete_queue(QueueUrl = 'https://us-west-2.queue.amazonaws.com/978916941101/test')

q = q_client.list_queues()

print "QUEUE - URLS ",q.get("QueueUrls")

qList = sqs.queues.all()

for q in qList:
    print q.url

以上代码的输出为

(env1)rahul@ubuntu:~/rahul/PythonPractise/Boto3_Practise$ python clientTwo.py
QUEUE - URLS  ['https://us-west-2.queue.amazonaws.com/978916941101/test-Two']
https://ap-southeast-1.queue.amazonaws.com/978916941101/test
https://ap-southeast-1.queue.amazonaws.com/978916941101/test-1
https://ap-southeast-1.queue.amazonaws.com/978916941101/test-One
https://ap-southeast-1.queue.amazonaws.com/978916941101/test-Three
(env1)rahul@ubuntu:~/rahul/PythonPractise/Boto3_Practise$

我的问题是

为什么队列客户端无法列出从资源"创建的队列 以及为什么资源不列出从客户端创建的队列.

why queue Client is not able to list queues created from "resource" and why resource is does not list the queues created from client.

当我这样做

(env1)rahul@ubuntu:~/rahul/PythonPractise/Boto3_Practise$ aws configure list
  Name                    Value             Type    Location
  ----                    -----             ----    --------
   profile                <not set>             None    None
   access_key     ****************ef3f shared-credentials-file
  secret_key     ****************2r2r shared-credentials-file
   region                us-west-2      config-file    ~/.aws/config

是因为地区吗?

推荐答案

您可以从自定义会话中创建资源,该自定义会话的区域为ap-southeast-1.您从设置为us-west-2的boto3默认会话创建客户端.声明区域时,您只能访问该区域中的资源.

You create the resource from your custom session, which has ap-southeast-1 as the region. You create the client from the boto3 default session, which you have set to us-west-2. When you declare a region, you only have access to resources in that region.

这篇关于AWS sqs队列未列出所有队列的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆