BeerMoneyDev / nest-aws-sdk

A thin wrapping layer around the aws-sdk package for clean NestJS dependency injection.
MIT License
93 stars 13 forks source link

CredentialsError: Missing credentials in config #18

Closed whizyrel closed 2 years ago

whizyrel commented 2 years ago

I can not seem to get this fixed. Below is the error I get even when the config is loaded in the module initialization. UnhandledPromiseRejectionWarning: CredentialsError: Missing credentials in config, if using AWS_CONFIG_FILE, set AWS_SDK_LOAD_CONFIG=1

This is an impl snippet:

@Module({
  imports: [
    AwsSdkModule.forRootAsync({
      services: [SecretsManager, STS],
      defaultServiceOptions: {
        useFactory: (config: ConfigService) => {
          const awsConfig = config.get<IAWSConfig>('aws');

          return {
            region: awsConfig.general.region,
            credentials: new Credentials(
              awsConfig.keys.accessKeyId,
              awsConfig.keys.secretAccessKey,
            ),
          };
        },
        imports: [ConfigModule],
        inject: [ConfigService],
      },
    }),
    ConfigModule.forRoot({
      isGlobal: true,
      load: [...],
    }),
  ],
});

Alas, Somebody help!

@KerryRitter @benMain

Btw, none of the other options worked (same error) including statically providing the config. Also, the project runs in a docker container

KerryRitter commented 2 years ago

Hi @whizyrel, I haven't really encountered this error so I don't have any recommendations. If you can post a repo I can take a look.