AWS Polly Javascript SDK polly error ConfigError: Missing region in config at Request.VALIDATE_REGION

323 Views Asked by At

I have a browser app that uses Polly and Lex Javascript SDK. I get this error error ConfigError: Missing region in config at Request.VALIDATE_REGION using this code

const awsPollyCredentials = {
    accessKeyId: pollyKey,
    secretAccessKey: pollySecret,
    region: "us-east-1",
  };
new AWS.Polly(awsPollyCredentials)

which is correct according the SDK docs. It is not finding the region. Why not?

NOTE: I cannot use an AWS global config because my Lex calls use different credentials in same page. So I need a solution that gets passed into AWS.Polly()

1

There are 1 best solutions below

0
On

I gave up trying to get it to work with global credentials, even though the SDK docs says the Polly(options) accepts region. It only works in global AWS.config

const awsPollyCredentials = {
accessKeyId: pollyKey,
secretAccessKey: pollySecret,
region: "us-east-1",
};
AWS.config.credentials = awsPollyCredentials;
AWS.config.region = "us-east-1";