- Newest
- Most votes
- Most comments
The access denied error you're encountering when trying to query your Athena table is likely due to insufficient permissions. There are a few potential issues to consider:
-
S3 Bucket Policy: Your current bucket policy only allows the ListBucket action on the access point. For Athena to read the data, you'll need to grant additional permissions such as s3:GetObject.
-
Access Point Policy: You mentioned that the access point doesn't have any policy attached. It's recommended to add a policy to the access point that explicitly allows the necessary actions for Athena.
-
IAM Permissions: Ensure that the IAM user or role you're using to execute the Athena query has the necessary permissions to both Athena and the S3 bucket/access point.
-
Region Consistency: Make sure that the S3 bucket, access point, and Athena are all in the same AWS region.
To resolve this issue:
-
Update your S3 bucket policy to include additional necessary permissions, such as s3:GetObject.
-
Add a policy to your S3 access point that allows the required actions for Athena.
-
Review and update the IAM permissions for the user or role executing the Athena query.
-
Double-check that all resources are in the same region.
-
Ensure that the S3 gateway endpoint in your VPC is correctly configured to allow access to S3.
If the issue persists after making these changes, you may need to review CloudTrail logs for more detailed error information or consult AWS Support for further assistance.
Sources
Access Denied for ATHENA | AWS re:Post
S3 Tables - Unable to query using Athena | AWS re:Post
Unable to access the S3 bucket after the IAM user was recreated | AWS re:Post
You already have a bucket policy. Both bucket policy and access point policy must allow the request. Here's an example.
Access Point Policy
{
"Version":"2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Principal": {
"AWS": "arn:aws:iam::987654321012:role/AthenaRole"
},
"Action": ["s3:GetObject", "s3:PutObject"],
"Resource": "arn:aws:s3:us-east-1:987654321012:accesspoint/my-access-point/object/Athena/*"
}]
}
Bucket Policy
{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Principal": {
"AWS": "arn:aws:iam::987654321012:role/AthenaRole"
},
"Action": ["s3:GetObject", "s3:PutObject"],
"Resource": "arn:aws:s3:::my-bucket/Athena/*"
}]
}
Refer: https://docs.aws.amazon.com/AmazonS3/latest/userguide/access-points-policies.html
Relevant content
asked a year ago
asked 2 years ago
- AWS OFFICIALUpdated 5 months ago
