AWS NodeJS SDK SQSClient V3 Setting Explicit Credentials

I am trying to explicitly set the credentials for the SQSClient for AWS NodeJS SDK v3. I would rather not deal with the default credential file (~/.aws/credentials). Even if I have one, I want my explicit values to override the credential file.

The following is code I codified from some of the examples AWS provides:

import { paginateListQueues, SQSClientConfig, SQSClient } from '@aws-sdk/client-sqs';
import { AwsCredentialIdentity } from '@aws-sdk/types';

export class AwsApiClientService {

  private awsApiClient: SQSClient;
  private credentials: AwsCredentialIdentity;

  constructor(awsAccessKeyId: string, awsSecretAccessKey: string, region: string ) {
    this.credentials = { accessKeyId: awsAccessKeyId, secretAccessKey: awsSecretAccessKey }
    const config: SQSClientConfig = { credentials: this.credentials, region: region }
    const configuration = { config }
    this.awsApiClient = new SQSClient(configuration);
    this.awsApiClient.config;
  }

  public async getListOfCustomerQueues() {
    //const config: SQSPaginationConfiguration;
    const paginatedListQueues = paginateListQueues({ client: this.awsApiClient }, {});

    /** @type {string[]} */
    const urls = [];
    for await (const page of paginatedListQueues) {
      const nextUrls = page.QueueUrls?.filter((qurl) => !!qurl) || [];
      urls.push(...nextUrls);
      urls.forEach((url) => console.log(url));
    }

    return urls;
  }
}

When I debug this code, I see the values being set and I even see them in the object itself. However, when it runs it uses the values from my local aws credential file (~/.aws/credentials) and not what is explicitly set on the object.

Is there anyway to force these explicit settings and not from a local aws credential file Any assistance would be appreciated.



Comments

Popular posts from this blog

Today Walkin 14th-Sept

Hibernate Search - Elasticsearch with JSON manipulation

Spring Elasticsearch Operations