ghdna / athena-express

Athena-Express can simplify executing SQL queries in Amazon Athena AND fetching cleaned-up JSON results in the same synchronous or asynchronous request - well suited for web applications.
https://www.npmjs.com/package/athena-express
MIT License
181 stars 70 forks source link

"InvalidRequestException: Bucket name should not contain uppercase characters" when used on aws lambda #90

Open cm-rwakatsuki opened 1 year ago

cm-rwakatsuki commented 1 year ago

I created aws lambda handler using athena-express.

import { AthenaExpress } from 'athena-express';
import * as AWS from 'aws-sdk';

const ATHENA_WORK_GROUP_NAME = process.env.ATHENA_WORK_GROUP_NAME || '';
const GLUE_DATABASE_NAME = process.env.GLUE_DATABASE_NAME || '';
const SOURCE_GLUE_TABLE = process.env.SOURCE_GLUE_TABLE || '';

AWS.config.update({ region: 'ap-northeast-1' });

const athenaExpress = new AthenaExpress({
  aws: AWS,
  workgroup: ATHENA_WORK_GROUP_NAME,
});

export const handler = async (): Promise<void> => {
  const sqlQuery = `SELECT * FROM ${GLUE_DATABASE_NAME}.${SOURCE_GLUE_TABLE}`;

  const results = await athenaExpress.query(sqlQuery);

  console.log(results);
};

But, execution of this lambda ends with below error.

{
  "errorType": "Error",
  "errorMessage": "InvalidRequestException: Bucket name should not contain uppercase characters",
  "trace": [
    "Error: InvalidRequestException: Bucket name should not contain uppercase characters",
    "    at AthenaExpress.query (/var/task/index.js:8023:17)",
    "    at processTicksAndRejections (internal/process/task_queues.js:95:5)",
    "    at async Runtime.handler (/var/task/index.js:8058:19)"
  ]
}

version info:

$  npm ls aws-sdk athena-express
aws-cdk-app@0.1.0 /Users/wakatsuki.ryuta/projects/cm-rwakatsuki/aws-cdk-app
├── athena-express@7.1.5
└── aws-sdk@2.1238.0
ghdna commented 1 year ago

Were you able to resolve this? This reads like an AWS error and not much to do with this library.