ssut / nestjs-sqs

A project to make SQS easier to use within NestJS, with decorator-based handling and seamless NestJS-way integration.
MIT License
214 stars 53 forks source link

Upgrade to AWS SDK v3 #47

Closed jyustman closed 1 year ago

jyustman commented 1 year ago

Hi, this seems to be working. Needs a little attention on package.json and package-lock.json, but hopefully this gets you close enough to wrap it up.

sarcastic-verma commented 1 year ago

Any update on this? Looking forward to getting it merged soon.

roeysha commented 1 year ago

@ssut +1

ssut commented 1 year ago

I will merge this soon.

lamkn06 commented 1 year ago

@ssut how about this PR? Looking forward to getting it merged soon.

Sohett commented 1 year ago

Any update ? Something blocking ?

Sohett commented 1 year ago

I will merge this soon.

I don't want to be pushy, but what's blocking you from merging @ssut ? I kind of rely on this before being able to deploy on prod 🙏

ssut commented 1 year ago

I apologize for the delay. I have manually merged this PR (https://github.com/ssut/nestjs-sqs/commit/4cc940e4daa90933f228a4cbdfba28c0b31c7671) as I had to change some more tiny things and wanted to check if this changes won't affect the tests. I am going to release v2.0.0 as soon as possible!

ssut commented 1 year ago

I just published v2.0.0: https://github.com/ssut/nestjs-sqs/releases/tag/v2.0.0 (npm: https://www.npmjs.com/package/@ssut/nestjs-sqs/v/2.0.0).

Sohett commented 1 year ago

@ssut thanks for the new release.

I don't understand how you setup the AWS credentials though.

I read on the AWS doc SDK v3 (and on bbb/sqs-producer) that you should just provide a AWS_ACCESS_KEY_ID and a AWS_SECRET_ACCESS_KEY as .env variables.

Nevertheless it's not working anymore for me 😢 now with this new release.

    const sqsError = new SQSError(message);
                     ^
SQSError: SQS receive message failed: The specified queue does not exist for this wsdl version.
    at toSQSError (/node_modules/sqs-consumer/dist/errors.js:40:22)
    at Consumer.receiveMessage (/node_modules/sqs-consumer/dist/consumer.js:159:43)
    at processTicksAndRejections (node:internal/process/task_queues:96:5)
alexisbellido commented 1 year ago

@Sohett , are you using AWS CLI on your computer? If so, can you try renaming your ~/.aws directory to ~/.aws-temp and see if the problem persists? I was just seeing a similar error and this is what I did to solve it.

Here's the error I was getting:

SQSError: SQS receive message failed: Access to the resource https://sqs.us-east-2.amazonaws.com/ is denied.
    at toSQSError (/my-path-to/node_modules/sqs-consumer/dist/consumer.js:48:22)
    at Consumer.receiveMessage (/my-path-to/node_modules/sqs-consumer/dist/consumer.js:162:19)
    at processTicksAndRejections (node:internal/process/task_queues:96:5)

I noticed this by adding a console.log(this.sqs) to /my-path-to/node_modules/sqs-consumer/dist/consumer.js:162:19 and noticing that the accessKeyId property was being picked from my ~/.aws/credentials file.

I just started figuring out this so I'd appreciate it if anybody else could confirm.

Sohett commented 1 year ago

@Sohett , are you using AWS CLI on your computer? If so, can you try renaming your ~/.aws directory to ~/.aws-temp and see if the problem persists? I was just seeing a similar error and this is what I did to solve it.

Here's the error I was getting:

SQSError: SQS receive message failed: Access to the resource https://sqs.us-east-2.amazonaws.com/ is denied.
    at toSQSError (/my-path-to/node_modules/sqs-consumer/dist/consumer.js:48:22)
    at Consumer.receiveMessage (/my-path-to/node_modules/sqs-consumer/dist/consumer.js:162:19)
    at processTicksAndRejections (node:internal/process/task_queues:96:5)

I noticed this by adding a console.log(this.sqs) to /my-path-to/node_modules/sqs-consumer/dist/consumer.js:162:19 and noticing that the accessKeyId property was being picked from my ~/.aws/credentials file.

I just started figuring out this so I'd appreciate it if anybody else could confirm.

I am indeed using the AWS CLI, but this is not the root cause. I just tested your proposed solution and it did not solve it.

Though you helped me solve it! By doing the same as you (console.log in the sqs-consumer node package), I noticed the region was set to eu-west-1, which is the one by default!

🤦 I was not passing the AWS_REGION in my credentials ! Working like a charm now.