My Amazon Athena query fails to save results on the specified Amazon Simple Storage Service (Amazon S3) bucket.
Amazon Athena automatically stores query results and metadata information for each query to a query result location that you can specify in Amazon S3. However, you get the error “Invalid S3 location” or "Not a valid S3 location" under one or more of the following conditions:
- You didn't specify the Amazon S3 query result location.
- The S3 query result location that you specified is inaccurate.
- The S3 query result location that you specified is in a different Region.
- The AWS Identity and Access Management (IAM) user doesn't have the required permissions to set up or view the query result location.
To resolve these errors, choose one or more of the following solutions:
Specify the query result location
The query result location in Amazon S3 must be specified before you run your queries. Or, you must use a workgroup that has specified a bucket and whose configuration overrides client settings. Verify that you specified the query result location in S3 by doing the following:
- Open the Athena console.
- Choose Settings from the navigation bar.
- Verify that Query result location is pointing to the query result bucket.
If the query result location isn't specified, then you can update it using the Athena console. You can also specify the result location in a workgroup configuration. For more information, see Specifying a query result location using a workgroup.
Verify that the S3 path is accurate
Verify that the query result location specified in the Athena console is pointing to the correct S3 path. Also, be sure to include a trailing slash (/) at the end of the S3 path (example: s3://doc_example_bucket/doc_example_folder/).
Verify that the S3 location is in the same Region
Verify that the S3 location provided for saving the query results is in the same Region where you run the queries.
Verify that the IAM user has sufficient permissions to access the query result files
Verify that the IAM user has the required permissions to access and view the query output files. The IAM user/role needs permissions to the following actions:
Note: IAM principals with permission to the GetObject action for the query results location can retrieve query results from S3. This is true even if permission to the GetQueryResults action is denied for the IAM principals. To restrict user or role access, be sure that the S3 permissions to the Athena query results location are denied.
Working with query results, output files, and query history
How do I troubleshoot 403 Access Denied errors from Amazon S3?
Why do I get the "Access Denied" error when I run a query in Amazon Athena?