Why am I getting a SQSError: 404 when trying to connect using Boto to an ElasticMQ service that is behind Ambassador?

11/14/2018

I have an elasticmq docker container which is deployed as a service using Kubernetes. Furthermore, this service is exposed to external users by way of Ambassador.

Here is the yaml file for the service.

  ---
  kind: Service
  apiVersion: v1
  metadata:
    name: elasticmq
    annotations:
      getambassador.io/config: |
        ---
        apiVersion: ambassador/v1
        kind:  Mapping
        name:  elasticmq
        prefix: /
        host: elasticmq.localhost.com
        service: elasticmq:9324
  spec:
    selector:
      app: elasticmq
    ports:
    - port: 9324
      protocol: TCP
  ---
  kind: Deployment
  apiVersion: apps/v1
  metadata:
    name: elasticmq
    labels:
      app: elasticmq
  spec:
    replicas: 1
    selector:
      matchLabels:
        app: elasticmq
    template:
      metadata:
        labels:
          app: elasticmq
      spec:
        containers:
        - name: elasticmq
          image: elasticmq
          imagePullPolicy: IfNotPresent
          ports:
          - containerPort: 9324
          livenessProbe:
            exec:
              command:
              - /bin/bash
              - -c
              - nc -zv localhost 9324 -w 1
            initialDelaySeconds: 60
            periodSeconds: 5
          volumeMounts:
            - name: elastimq-conf-volume
              mountPath: /elasticmq/elasticmq.conf
        volumes:
          - name: elastimq-conf-volume
            hostPath:
              path: /path/elasticmq.conf

Now I can check that the elasticmq container is healthy and Ambassador worked by doing a curl:

$ curl  elasticmq.localhost.com?Action=ListQueues&Version=2012-11-05
[1] 10355
<ListQueuesResponse xmlns="http://queue.amazonaws.com/doc/2012-11-05/">
<ListQueuesResult>

</ListQueuesResult>
<ResponseMetadata>
<RequestId>00000000-0000-0000-0000-000000000000</RequestId>
</ResponseMetadata>
</ListQueuesResponse>[1]+  Done

On the other hand, when I try to do the same thing using Boto3, I get a SQSError: 404 not found.

This is my Python script:

import boto.sqs.connection
conn = boto.sqs.connection
c = conn.SQSConnection(proxy_port=80, proxy='elasticmq.localhost.com', is_secure=False, aws_access_key_id='x', aws_secret_access_key='x'
c.get_all_queues('')

I thought it had to do with the outside host specified in elasticmq.conf, so I changed that to this:

include classpath("application.conf")

// What is the outside visible address of this ElasticMQ node (used by rest-sqs)
node-address {
    protocol = http
    host = elasticmq.localhost.com
    port = 80
    context-path = ""
}

rest-sqs {
    enabled = true
    bind-port = 9324
    bind-hostname = "0.0.0.0"
    // Possible values: relaxed, strict
    sqs-limits = relaxed
}

I thought changing the elasticmq conf would work, but it doesn't. How can I get this to work?

-- fanoffan
boto
elastic-mq
kubernetes
networking
python-3.x

0 Answers