0

I've been trying to query information frin Athena using the next bit of code:

import boto3 
import awswrangler as wr

sessAWS_Test = boto3.session.Session(
    aws_access_key_id = 'id',
    aws_secret_access_key = 'key',
    region_name = 'region used'
)

strQuery = """select *
from raw_data
where year like '2023' and month like '03'
limit 100
"""
wr.athena.read_sql_query(strQuery, database = 'raw_data', boto3_session = sessAWS_Test, 
                         ctas_approach=False)

I get the next error when running the last line of code: WaiterError: Waiter BucketExists failed: Max attempts exceeded. Previously accepted state: Matched expected HTTP status code: 404

The user that I use has the following permits:

{
    "Version": "2012-10-17",
    "Statement": [
        {
            "Sid": "VisualEditor0",
            "Effect": "Allow",
            "Action": [
                "s3:PutObject*",
                "s3:Get*",
                "athena:StartQueryExecution",
                "athena:StopQueryExecution",
                "athena:GetQueryExecution",
                "athena:GetQueryResults"
            ],
            "Resource": [
                "arn:aws:s3:::bucket_to_write_results",
                "arn:aws:s3:::bucket_to_write_results/*",
                "arn:aws:athena:region:id:workgroup/workgroup_name"
            ]
        }
    ]
}

I did review this post which addresses the same error. However, this case doesn't seem to apply or solve the problem since I use a Session object with a region as shown in the code above.

All other cases with similar errors seem to mention other services rather than S3, which doesn't seem to address the main issue with the error above.

  • Can you try running this script from terminal after setting below config to make sure that this is happening due to region problem > aws configure AWS Access Key ID [********************]: AWS Secret Access Key [********************]: Default region name [None]: us-east-1 Default output format [json]: – Prabhakar Reddy May 03 '23 at 01:36
  • Did you figure this out? same exact issue – Jeremy Fisher Jul 28 '23 at 22:27

0 Answers0