title: Error trying to connect Celery through SQS using STS
body: <p>I'm trying to use Celery with SQS as broker. In order to use the SQS from my container I need to assume a role and for that I'm using STS. My code looks like this:</p>
  <pre class="lang-py prettyprint-override"><code>role_info = {
      'RoleArn': 'arn:aws:iam::xxxxxxx:role/my-role-execution',
      'RoleSessionName': 'roleExecution'
  }
  sts_client = boto3.client('sts', region_name='eu-central-1')
  credentials = sts_client.assume_role(**role_info)
  
  aws_access_key_id = credentials[&quot;Credentials&quot;]['AccessKeyId']
  aws_secret_access_key = credentials[&quot;Credentials&quot;]['SecretAccessKey']
  aws_session_token = credentials[&quot;Credentials&quot;][&quot;SessionToken&quot;]
  
  os.environ[&quot;AWS_ACCESS_KEY_ID&quot;] = aws_access_key_id
  os.environ[&quot;AWS_SECRET_ACCESS_KEY&quot;] = aws_secret_access_key
  os.environ[&quot;AWS_DEFAULT_REGION&quot;] = 'eu-central-1'
  os.environ[&quot;AWS_SESSION_TOKEN&quot;] = aws_session_token
  
  broker = &quot;sqs://&quot;
  backend = 'redis://redis-service:6379/0'
  
  celery = Celery('tasks', broker=broker, backend=backend)
  
  celery.conf[&quot;task_default_queue&quot;] = 'my-queue'
  celery.conf[&quot;broker_transport_options&quot;] = {
      'region': 'eu-central-1',
      'predefined_queues': {
         'my-queue': {
              'url': 'https://sqs.eu-central-1.amazonaws.com/xxxxxxx/my-queue'
          }
      }
  }
  </code></pre>
  <p>In the same file I have the following task:</p>
  <pre class="lang-py prettyprint-override"><code>@celery.task(name='my-queue.my_task')
  def my_task(content) -&gt; int:
      print(&quot;hello&quot;)
      return 0
  </code></pre>
  <p>When I execute the following code I get an error:</p>
  <pre class="lang-py prettyprint-override"><code>[2020-09-24 10:38:03,602: CRITICAL/MainProcess] Unrecoverable error: ClientError('An error occurred (AccessDenied) when calling the ListQueues operation: Access to the resource https://eu-central-1.queue.amazonaws.com/ is denied.',)
  Traceback (most recent call last):
    File &quot;/usr/local/lib/python3.6/site-packages/kombu/transport/virtual/base.py&quot;, line 921, in create_channel
      return self._avail_channels.pop()
  IndexError: pop from empty list
  
  During handling of the above exception, another exception occurred:
  
  Traceback (most recent call last):
    File &quot;/usr/local/lib/python3.6/site-packages/celery/worker/worker.py&quot;, line 208, in start
      self.blueprint.start(self)
    File &quot;/usr/local/lib/python3.6/site-packages/celery/bootsteps.py&quot;, line 119, in start
      step.start(parent)
    File &quot;/usr/local/lib/python3.6/site-packages/celery/bootsteps.py&quot;, line 369, in start
      return self.obj.start()
    File &quot;/usr/local/lib/python3.6/site-packages/celery/worker/consumer/consumer.py&quot;, line 318, in start
      blueprint.start(self)
    File &quot;/usr/local/lib/python3.6/site-packages/celery/bootsteps.py&quot;, line 119, in start
      step.start(parent)
    File &quot;/usr/local/lib/python3.6/site-packages/celery/worker/consumer/connection.py&quot;, line 23, in start
      c.connection = c.connect()
    File &quot;/usr/local/lib/python3.6/site-packages/celery/worker/consumer/consumer.py&quot;, line 405, in connect
      conn = self.connection_for_read(heartbeat=self.amqheartbeat)
    File &quot;/usr/local/lib/python3.6/site-packages/celery/worker/consumer/consumer.py&quot;, line 412, in connection_for_read
      self.app.connection_for_read(heartbeat=heartbeat))
    File &quot;/usr/local/lib/python3.6/site-packages/celery/worker/consumer/consumer.py&quot;, line 439, in ensure_connected
      callback=maybe_shutdown,
    File &quot;/usr/local/lib/python3.6/site-packages/kombu/connection.py&quot;, line 422, in ensure_connection
      callback, timeout=timeout)
    File &quot;/usr/local/lib/python3.6/site-packages/kombu/utils/functional.py&quot;, line 341, in retry_over_time
      return fun(*args, **kwargs)
    File &quot;/usr/local/lib/python3.6/site-packages/kombu/connection.py&quot;, line 275, in connect
      return self.connection
    File &quot;/usr/local/lib/python3.6/site-packages/kombu/connection.py&quot;, line 823, in connection
      self._connection = self._establish_connection()
    File &quot;/usr/local/lib/python3.6/site-packages/kombu/connection.py&quot;, line 778, in _establish_connection
      conn = self.transport.establish_connection()
    File &quot;/usr/local/lib/python3.6/site-packages/kombu/transport/virtual/base.py&quot;, line 941, in establish_connection
      self._avail_channels.append(self.create_channel(self))
    File &quot;/usr/local/lib/python3.6/site-packages/kombu/transport/virtual/base.py&quot;, line 923, in create_channel
      channel = self.Channel(connection)
    File &quot;/usr/local/lib/python3.6/site-packages/kombu/transport/SQS.py&quot;, line 100, in __init__
      self._update_queue_cache(self.queue_name_prefix)
    File &quot;/usr/local/lib/python3.6/site-packages/kombu/transport/SQS.py&quot;, line 105, in _update_queue_cache
      resp = self.sqs.list_queues(QueueNamePrefix=queue_name_prefix)
    File &quot;/usr/local/lib/python3.6/site-packages/botocore/client.py&quot;, line 337, in _api_call
      return self._make_api_call(operation_name, kwargs)
    File &quot;/usr/local/lib/python3.6/site-packages/botocore/client.py&quot;, line 656, in _make_api_call
      raise error_class(parsed_response, operation_name)
  botocore.exceptions.ClientError: An error occurred (AccessDenied) when calling the ListQueues operation: Access to the resource https://eu-central-1.queue.amazonaws.com/ is denied.
  </code></pre>
  <p>If I use <code>boto3</code> <strong>directly</strong> without Celery, I'm able to connect to the queue and retrieve data without this error. I don't know why Celery/Kombu try to list queues when I specify the <code>predefined_queues</code> configuration, tha is used to avoid these behavior (from docs):</p>
  <blockquote>
  <p>If you want Celery to use a set of predefined queues in AWS, and to never attempt to list SQS queues, nor attempt to create or delete them, pass a map of queue names to URLs using the predefined_queue_urls setting</p>
  </blockquote>
  <p><a href="https://docs.celeryproject.org/en/stable/getting-started/brokers/sqs.html#predefined-queues" rel="nofollow noreferrer">Source here</a></p>
  <p>Anyone know what happens? How I should modify my code in order to make it work?. Seems that Celery is not using the credentials at all.</p>
  <p>The versions I'm using:</p>
  <pre class="lang-py prettyprint-override"><code>celery==4.4.7
  boto3==1.14.54
  kombu==4.5.0
  </code></pre>
  <p>Thanks!</p>
  <p>PS: I created and <a href="https://github.com/celery/kombu/issues/1255" rel="nofollow noreferrer">issue</a> in Github to track if this can be a library error or not...</p>