question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Error `AWS object not present or incorrect in the constructor` when using IAM role

See original GitHub issue

When IAM role is used for EC2/Lambda and s3 options is not passed to the config, athena-express is not able to create new buckets on its behalf, failing with error AWS object not present or incorrect in the constructor.

It looks here: https://github.com/ghdna/athena-express/blob/master/lib/athenaExpress.js#L232 that it expects either s3 option to be set or credentials keys to be passed.

I had IAM role set up with full access to S3 and Athena, though I had to specify S3 location manually to override behavior.

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:13 (4 by maintainers)

github_iconTop GitHub Comments

2reactions
KrickyKikicommented, Jul 14, 2020

I had this error when trying to pass AWS ( caps ) instead of aws. To replicate the issue:

const AWS = require("aws-sdk");
const athenaExpressConfig = {
	AWS
};
const athenaExpress = new AthenaExpress(athenaExpressConfig);

However below worked fine:

const AWS = require("aws-sdk");
const athenaExpressConfig = {
	aws: AWS
};
const athenaExpress = new AthenaExpress(athenaExpressConfig);
2reactions
carlosescuracommented, Jul 7, 2020

After a further investigation, I found the issue and why it’s related only with roles:

This line is the cause.

For all of you having this issue, can you specify a custom s3 output directory for your queries? If so, it won’t fail as the exception is thrown because of the lack of both, the s3 value in the constructor, and the lack of a valid AWS access key (because you are using a role/instanceprofile).

const aws = require("aws-sdk");

const athenaExpressConfig = {
	aws,
	s3: "s3://whatever-your-bucket-is"
};
const athenaExpress = new AthenaExpress(athenaExpressConfig);
Read more comments on GitHub >

github_iconTop Results From Across the Web

Resolve the IAM Error "AWS was not able to validate the ...
I assumed an AWS Identity and Access Management (IAM) role and my API call returned an error similar to the following:.
Read more >
Credentials — AWS SDK for PHP documentation
This provides a strategy for managing credentials for your applications to use, similar to the way that Amazon EC2 instance profiles provide credentials...
Read more >
Using IAM Roles to Grant Access to AWS Resources on ...
If the client constructor can't find credentials using the credentials provider chain, it will throw an AmazonClientException. Walkthrough: Using IAM roles for ...
Read more >
Upload an object to an Amazon S3 bucket using an AWS SDK
The following code examples show how to upload an object to an S3 bucket. ... "Error unable to read file " << fileName...
Read more >
Configuration for the AWS SDK for PHP Version 3
Load credentials from an IAM role. Pass false to use null credentials and not sign requests. $s3 = new Aws\S3\S3Client([ 'version' => 'latest', ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found