Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

InvalidClientTokenId error after upgrading to 2.0.0 locally. #49

Open
egimenos opened this issue May 15, 2023 · 2 comments
Open

InvalidClientTokenId error after upgrading to 2.0.0 locally. #49

egimenos opened this issue May 15, 2023 · 2 comments

Comments

@egimenos
Copy link
Contributor

egimenos commented May 15, 2023

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 the consumer.js file from sqs-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()})


{
  region: Promise { 'eu-central-1' },
  credentials: { accessKeyId: 'dummy', secretAccessKey: 'dummy' }
}

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.

@egimenos
Copy link
Contributor Author

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',
    })

  }

@rmogio-encora
Copy link

@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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants