Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Unrecognized client exception when calling the GetTableMetadata operation: The security token included in the request is invalid. #46

Closed
NatalieLow opened this issue May 10, 2024 · 6 comments
Assignees

Comments

@NatalieLow
Copy link

Issue overview

When attempting to use the buildstock-query notebooks, I'm getting a Client / Operational Error.

Current Behavior

Expected Behavior

Steps to Reproduce

from buildstock_query import BuildStockQuery
(works fine)
2.
aws configuration
(enter keys, region, etc.)
Account has:

  • AdministratorAccess
  • AmazonAthenaFullAccess
  • AmazonS3FullAccess

my_run = BuildStockQuery(workgroup='rescore', db_name='euss-final', table_name='euss_res_final_2018_550k_20220901')
This and various other table names and working groups produce Client / Operational errors:
OperationalError: An error occurred (UnrecognizedClientException) when calling the GetTableMetadata operation: The security token included in the request is invalid.
Screenshot 2024-05-10 at 11 54 14 AM
Screenshot 2024-05-10 at 11 55 18 AM
Screenshot 2024-05-10 at 11 56 00 AM

Possible Solution

Details

Environment

Some additional details about your environment for this issue (if relevant):

  • Platform (Operating system, version): MacOS Sonoma 14.4.1, Apple M2
  • Version of OpenStudio (if using an intermediate build, include SHA): OS: 3.7.0, 3.6.1, 3.5.1, 3.4.0
  • Python versions attempted: 3.10.13, 3.12.0

Context

We're able to query and access the Data Lake via AWS Athena interface, but would also like to use the python querying tools to more easily interface with our analysis of residential data.

@rajeee
Copy link
Collaborator

rajeee commented May 15, 2024

Are you sure you have access to that particular database and table in Athena with your user account?

@NatalieLow
Copy link
Author

Hi!

With this user account I am able to use AWS glue and set up a crawler to create tables from the oedi data lake, then run queries in Athena. I'm assuming this means I have access?

@rajeee
Copy link
Collaborator

rajeee commented Jun 26, 2024

You should be able to go to Athena console and see those specific db and table name. If you can't, then you will need to first create those. Please follow the instructions here: https://www.youtube.com/watch?v=qSR1MFpSiro&t=0s

@NatalieLow
Copy link
Author

I still seem to be missing something.

In Athena, everything seems to work well.

I have two tables: one for the metadata and one for the time series data.

I've also tried specifying the db_schema = resstock_oedi as it maps to my table suffixes.

Do you have any other ideas?

Thank you!

Screenshot 2024-07-15 at 3 37 41 PM Screenshot 2024-07-15 at 3 29 19 PM

@rajeee
Copy link
Collaborator

rajeee commented Jul 15, 2024

Thanks for the screenshot. That's very helpful.

It seems like somehow the credentials being pulled is not granting you the required permission.
Could you maybe try by adding this in the beginning.

import os
os.environ['AWS_ACCESS_KEY_ID'] = '<access_key>' 
os.environ['AWS_SECRET_ACCESS_KEY']  = '<secret_key>'

@NatalieLow
Copy link
Author

It worked. Thank you!

I needed a couple of additional steps:

  1. Added my session token in addition to the key ID and access key:
    os.environ['AWS_SESSION_TOKEN'] = '<session token>'

  2. Specified a location for the query results in the workgroup

Screenshot 2024-07-16 at 10 28 14 AM Screenshot 2024-07-16 at 10 31 18 AM

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants