jegesh / python-sqs-listener

A simple wrapper for boto3 for listening, and sending, to an AWS SQS queue
Other
154 stars 72 forks source link

botocore.exceptions.ClientError: An error occurred (AccessDenied) when calling the ListQueues operation: Access to the resource https://queue.amazonaws.com/ is denied. #44

Closed danielortizglobant closed 2 years ago

danielortizglobant commented 3 years ago

Im trying to follow the tutorial but shows me and error

from sqs_listener import SqsListener
import os

os.environ["AWS_ACCOUNT_ID"] = "xxxxx"

import boto3
# create a boto3 client
client = boto3.client('sqs')

class MyListener(SqsListener):
    def handle_message(self, body, attributes, messages_attributes):
        print('here')

listener = MyListener('https://sqs.us-east-1.amazonaws.com/xxxxxx/yyyyyyyy',
                      error_queue='my-error-queue', region_name='us-east-1', )
listener.listen()
acepace commented 3 years ago

You need to give your AWS account permissions to also ListQueues in the right region. This is because SqsListener doesn't just try to access the queues directly but to list and check if they exist.

lordvault commented 3 years ago

I had the same issue, my organization work with different queues and as a restriction each component is only allowed to see the required queues. As result was not possible to call the list_queues. After look the logic on the _initialize_client the list_queues is used to get the queue_url or create it if not exist. Would be wondefull if this list_queues could be conditioned to a param, check_queues_config = True, or something like that.

By the moment i extended the SqsListener class and override the method removing the list_queue and setting on True the variables.

jegesh commented 2 years ago

@lordvault you're more than welcome to submit a PR with that feature!