Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

261
Visualizações
Error while calling AWS Athena using javascript code using Cognito UnauthRole with Full S3 and Athena Access

I am trying to query athena by assuming a role by using Cognito_IdedtityPool to get temporary accessKey, secretKey and sessionToken which has full Athena and S3 permission. But when i call it from my .js file it throws error User:

Error : arn:aws:sts::<acc_no>:assumed-role/... is not authorized to perform: athena:StartQueryExecution on resource: arn:aws:athena:us-east-1:... because no session policy allows the athena:StartQueryExecution action

But once I create an IAM User and hardcode the keys with full Athena and S3 permission. then i am able to get data. Can anyone help in this ?

How can i query using assumed role ?

My js code is below :

    AWS.config.credentials = new AWS.CognitoIdentityCredentials({
        IdentityPoolId: 'us-east-1:<pool-id>',
    });

 var config = {
                accessKey: credentials.accessKeyId, // REQUIRED
                secretKey: credentials.secretAccessKey, //REQUIRED
                sessionToken: credentials.sessionToken,// REQUIRED
                region: 'us-east-1',
                apiVersion: '2017-05-18',
            }

            AWS.config.update(config);

            const AthenaExpress = require("athena-express"),

            const athenaExpressConfig = {
                aws: AWS,
                s3: "s3://athena-output-destination/Test",
                getStats: true,
                workgroup: 'primary',
                catalog: ATHENA_CATALOG,
                retry: 4,
                formatJson: true,
            };

            const athenaExpress = new AthenaExpress(athenaExpressConfig);

            (async () => {
                let myQuery = {
                    sql: query_string,
                    db: ATHENA_DB
                };
        
                try {
                    let results = await athenaExpress.query(myQuery);
                    console.log(results);
        
                } catch (error) {
                    console.log(error);
                }
            })();

about 4 years ago · Juan Pablo Isaza
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda