- Newest
- Most votes
- Most comments
- IAM Role Policy: First, ensure that the IAM role used by Athena has the necessary permissions to access S3. You should attach a policy to the IAM role that includes the following permissions:
{ "Version": "2012-10-17", "Statement": [ { "Effect": "Allow", "Action": [ "s3:GetBucketLocation", "s3:GetObject", "s3:ListBucket", "s3:PutObject", "s3:DeleteObject" ], "Resource": [ "arn:aws:s3:::pics-repository", "arn:aws:s3:::pics-repository/*" ] } ] }
This policy grants the necessary S3 permissions for Athena to read from and write to your S3 bucket.
- S3 Bucket Policy: The S3 bucket policy you provided is close, but it needs some adjustments. Here's an improved version:
{ "Version": "2012-10-17", "Statement": [ { "Effect": "Allow", "Principal": { "Service": "athena.amazonaws.com" }, "Action": [ "s3:GetBucketLocation", "s3:GetObject", "s3:ListBucket", "s3:PutObject", "s3:DeleteObject" ], "Resource": [ "arn:aws:s3:::pics-repository", "arn:aws:s3:::pics-repository/*" ] } ] }
This policy explicitly allows Athena to perform the necessary actions on your S3 bucket.
- Additional Considerations:
- Ensure that the IAM role Athena is using has the necessary permissions to create and manage Iceberg tables.
- If you're using AWS Glue Data Catalog, make sure the IAM role has permissions to access and modify Glue databases and tables.
- If your S3 bucket uses AWS KMS for encryption, you'll need to grant the IAM role permissions to use the KMS key.
By implementing these permissions, you should be able to resolve the S3 access error and successfully create your Iceberg table using Athena. Remember to replace "pics-repository" with your actual S3 bucket name in both policies.
Sources
Control access to Amazon S3 from Athena - Amazon Athena
Allow access to Athena UDFs: Example policies - Amazon Athena
AWS managed policies for Amazon Athena - Amazon Athena
answered 2 years ago
Thank you for your answer, I've added that on 'General purpose bucket' permission (Table bucket does not have the option), but I still have the error.
Relevant content
asked a year ago

Looking at the documentation, I believe you cannot run
CREATE TABLEfrom Athena, operations likeSELECT,INSERT,UPDATE,DELETE, andMERGEare supported.Thank you for your answer, I've used CLI to add the table, using the command below: aws athena start-query-execution --query-string "<above query>" --work-group "primary" --query-execution-context Database="default" --result-configuration OutputLocation="<athena-query-results bucket>"
I've got no error ("QueryExecutionId": "7f605e73-39ed-4e4d-b4a2-e845df2b6ade"), but I do not see the table in Athena, default database.