2
我是AWS新手。 我正在關注AWS教程快速入門。 我遵循AWS sqs代碼和sqs文檔。AWS sqs隊列沒有列出所有隊列
這是下面的代碼,我寫了
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)[email protected]:~/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)[email protected]:~/rahul/PythonPractise/Boto3_Practise$
我的問題是,
爲什麼隊列客戶端不能列出隊列從「資源」 創建,爲什麼資源不列出從客戶端創建的隊列。
當我做
(env1)[email protected]:~/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
是因爲這些區域的?
是的,該地區很重要。在撥打電話之前明確地設置我 – Mircea