Getting MissingAuthenticationTokenException for Polly.synthesizeSpeech with node.js sdk

0

Hello! I'm getting MissingAuthenticationTokenException error for basic invocation. Maybe i do something stupid?

import { Polly } from "@aws-sdk/client-polly";
assert(process.env.AWS_POLLY_REGION)
polly = new Polly({ region: process.env.AWS_POLLY_REGION });
const params = {
        OutputFormat: "ogg_vorbis",
        Text:"hello world",
        VoiceId: "Maxim",
};
const { AudioStream } = await polly.synthesizeSpeech(params);

Configured for polly permission:

{
    "Version": "2012-10-17",
    "Statement": [
        {
            "Effect": "Allow",
            "Action": [
                "polly:SynthesizeSpeech"
            ],
            "Resource": "*"
        }
    ]
}

Any other services like sqs or dynamodb works well.

cainr
posta un anno fa305 visualizzazioni
1 Risposta
0
Risposta accettata

The error usually happens because the request must contain either a valid (registered) Amazon Web Services access key ID or X.509 certificate. https://docs.aws.amazon.com/AWSJavaSDK/latest/javadoc//index.html?com/amazonaws/services/computeoptimizer/model/MissingAuthenticationTokenException.html

For further insights, please take a look on this documentation and let me know if you still face an issue : https://docs.aws.amazon.com/sdk-for-javascript/v3/developer-guide/polly-examples.html

AWS
con risposta un anno fa
  • I am encountering an unusual issue. I have verified the environment variables and can confirm that both AWS_SECRET_ACCESS_KEY and AWS_ACCESS_KEY_ID are present.

    When I simulate access with the following command: aws iam simulate-principal-policy --policy-source-arn arn:aws:iam::771234567890:role/service-role/mySQSQueueConsumer-role-56pqpuif --action-names polly:SynthesizeSpeech { "EvaluationResults": [ { "EvalActionName": "polly:SynthesizeSpeech", "EvalResourceName": "*", "EvalDecision": "allowed", "MatchedStatements": [ { "SourcePolicyId": "role_mySQSQueueConsumer-role-56pqpuif_mySQSQueueConsumer", "SourcePolicyType": "IAM Policy", "StartPosition": { "Line": 13, "Column": 4 }, "EndPosition": { "Line": 20, "Column": 4 } } ], "MissingContextValues": [] } ] }

    In the same AWS Lambda function, I am also using Amazon DynamoDB, and it works seamlessly without any issue.

    Are there any concealed requirements I might be overlooking? Previously, I encountered a permission issue with an AWS Lambda function producing SQS queue events. It was not compatible with encryption enabled and no good error message.

  • it was problem with my webpack build. aws lib was processed with tree-shaking and some code was auto-removed. when i excluded it from the build, it started to work. Thank you for your time.

Accesso non effettuato. Accedi per postare una risposta.

Una buona risposta soddisfa chiaramente la domanda, fornisce un feedback costruttivo e incoraggia la crescita professionale del richiedente.

Linee guida per rispondere alle domande