Open egimenos opened 1 year ago
Just in case someone has the same problem, the credentials were fine, the problem was that I needed to explicitly set the endpoint to trigger Localstack. As I said this was not necessary before because the endpoint is included in sqs
queue url, but I think this is something related to the sqs-consumer
library that nestjs-sqs
uses under the hood.
So now in development environment I need to pass a sqs client defining the endpoint as part of the SqsConsumerOptions
This is an example:
{
name: '...',
queueUrl: '...',
region: '...'
sqs: new SQSClient({
endpoint: 'http://localhost:4566',
})
}
@egimenos Thank you a lot for that! I was struggling to get rid of this error. I do think that this should be place somewhere on the documentation for this library.
So basically that, everything worked fine in 1.2.x. I am using Localstack, which should not make any difference, and I'm loading the credentials and config from aws CLI files.
If I try to upgrade to 2.0.0 then I get this error in the method
receiveMessage
of theconsumer.js
file fromsqs-consumer
InvalidClientTokenId: The security token included in the request is invalid.
If I go to
consumer.js
and try to log region and credentials I got his which looks as expected:console.log({region: this.sqs.config.region(), credentials: await this.sqs.config.credentials()})
Any idea on what might be happening? As I said this setup was working fine in 1.2.x and according to the docs no further configuration needs to be done if I'm not wrong.