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

When I try to publish I getInvalidClientTokenId #40

Open shotap opened 1 year ago

shotap commented 1 year ago

Hi, I'm running nestjs application inside of EKS pod, when I try to publish to a queue I get the error:

InvalidClientTokenId: The security token included in the request is invalid.

I publish using the SQS service:

import { SqsService } from '@ssut/nestjs-sqs';
import { Message } from '@ssut/nestjs-sqs/dist/sqs.types';

@Injectable()
export class TestService {
  constructor(readonly sqsService: SqsService) {}

  public publishToTestQueue(messages: Message<Test>) {
    return this.sqsService.send('test-q', messages);
  }
}

I initialise the service:

@Module({
  imports: [
    SqsModule.registerAsync({
      imports: [ConfigModule],
      useFactory: async (configService: ConfigService) => ({
        consumers: [],
        producers: [
          {
            name: 'test-q',
            queueUrl: configService.get('TEST_Q'),
            region: configService.get('AWS_REGION'),
          },
        ],
      }),
      inject: [ConfigService],
    }),
  ],
})

I initiate the AWS SDK without security keys, I have a role attached to the pod and I want the app to utilize the role:

AWS.config.update({ region: this.configService.get('AWS_REGION') });

What am I missing here?

hammad-ulhassan commented 1 year ago

@shotap were you able to resolve the issue? i am getting same error