Hello,
I'm running localstack to emulate SQS queues, and I've created a producer queue and a consumer queue, with the urls: http://localhost:4576/queue/producer and http://localhost:4576/queue/consumer-1.
In my lambda function, I initialize the AWS SDK config as so:
const awsConfig = new AWS.Config({
accessKeyId: '123',
secretAccessKey: 'abc',
endpoint: `${sqsHost}:${sqsPort}`,
sslEnabled: false,
});
where sqsHost is docker.for.mac.localhost and sqsPort is 4576, the default for SQS on Localstack. This all works fine, and when I run the listQueues function on the AWS SQS client I see both of my queues' URLs.
However, I cannot send messages to the queues, as the QueueUrl param to the sendMessage function would need to be http://localhost:4576/queue/producer, which doesn't make sense in the docker network the SAM lambda executes in. To remedy this, I've tried to pass in http://docker.for.mac.localhost:4576/queue/producer, which instead causes a 500 Internal Server Error. My guess is that when I try to use localhost, which is the actual QueueUrl, the lambda function breaks because there is nothing to access on the Docker internal network on the SQS port, but when I use docker.for.mac.localhost the SQS client doesn't understand how to find it, because there is no queue with that url.
Any advice on navigating around this issue would be greatly appreciated!
Unrelated to your question but maybe helpful...
I found ElasticMQ to be a much better alternative and works great within a
Docker network that I created to run alongside with SAM Local Containers.
https://github.com/adamw/elasticmq
Only issue I had with boto3 was that I wasn’t using the connection params
expected but as you mentioned List Queues work it could be something else.
On Mon, 5 Feb 2018 at 08:47, Zach Schultz notifications@github.com wrote:
Hello,
I'm running localstack to emulate SQS queues, and I've created a producer
queue and a consumer queue, with the urls:
http://localhost:4576/queue/producer and
http://localhost:4576/queue/consumer-1.In my lambda function, I initialize the AWS SDK config as so:
const awsConfig = new AWS.Config({ accessKeyId: '123', secretAccessKey: 'abc', endpoint: `${sqsHost}:${sqsPort}`, sslEnabled: false, });where sqsHost is docker.for.mac.localhost and sqsPort is 4576, the
default for SQS on Localstack.This all works fine, and when I run the listQueues function on the AWS
SQS client I see both of my queues. However, I cannot send messages to the
queues, as the QueueUrl param shows up as
http://localhost:4576/queue/producer, and trying to pass in
http://docker.for.mac.localhost:4576/queue/producer instead causes a 500
Internal Server Error. My guess is that when I try to use localhost,
which is the actual QueueUrl, the lambda function breaks because there is
nothing to access on the Docker internal network on the SQS port, but when
I use docker.for.mac.localhost the SQS client doesn't understand how to
find it.Any advice on navigating around this issue would be greatly appreciated!
—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
https://github.com/awslabs/aws-sam-local/issues/293, or mute the thread
https://github.com/notifications/unsubscribe-auth/ADL4BAILPozQfsEIWjQ6_C_FJUq-Q6ipks5tRzBlgaJpZM4R5vzN
.
localstack sits on top of elasticmq for it's sqs implementation fyi
I am able to use GoAWS by running it in a docker container as the same docker network that I run localstack on, so this issue seems to be specific to how localstack exposes sqs on 4576.
Bump...same issue here. Looking for a way to tell the executing docker container about the localhost SQS services - bridge network param maybe?
Love the discussion here but this really isn't the place for this kind of question, our slack channel, aws forums or stackoverflow are to be a better sport for questions like this). There are ways to have docker communicate to your host machine (consult docker docs) or you can run localstack in a docker network with the cli.