By using AWS re:Post, you agree to the AWS re:Post Terms of Use

How do I troubleshoot output location errors when I save Athena query results in an S3 bucket?

3 minute read
0

My Amazon Athena query fails to save results in the specified Amazon Simple Storage Service (Amazon S3) bucket.

Short description

Amazon Athena automatically stores query results and metadata information for each query to a query result location that you specify in Amazon S3. However, you get an output location related error when one or more of the following conditions is true:

  • 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 write query results.

Resolution

To resolve these errors, choose one or more of the following solutions:

Specify the query result location

You must specify the Amazon S3 query result location before you run your queries. Or, you must use a workgroup that has specified a bucket and that has configurations that override the client settings.

Complete the following steps to verify that you specified the query result location in S3:

  1. Open the Athena console.
  2. Choose Settings from the navigation bar.
  3. Verify that Query result location is pointing to the query result S3 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. It's a best practice to include a trailing slash (/) at the end of the S3 path, for example: s3://doc_example_bucket/doc_example_folder/.

Verify that the S3 location is in the same Region

Verify that the S3 location where the query results are saved is in the same Region where you run the queries.

Verify that the IAM user has permissions to write the query result files

Verify that the IAM user or role has the required permissions to write query output files. The IAM user or role needs the following permissions:

{
  "Effect": "Allow",
  "Action": [
    "s3:GetBucketLocation",
    "s3:GetObject",
    "s3:ListBucket",
    "s3:ListBucketMultipartUploads",
    "s3:AbortMultipartUpload",
    "s3:PutObject",
    "s3:ListMultipartUploadParts"
  ],
  "Resource": [
    "arn:aws:s3:::my-athena-result-bucket",
    "arn:aws:s3:::my-athena-result-bucket/*"
  ]
}

Note: If S3 bucket encryption is set to AWS Key Management Service (AWS KMS), then additional permissions with AWS KMS might be required. For more information, see Permissions to encrypted data in Amazon S3.

Related information

Working with query results, recent queries, and output files

How do I troubleshoot 403 Access Denied errors from Amazon S3?

How do I resolve "Access Denied" permission errors when I run a query in Amazon Athena?

AWS OFFICIAL
AWS OFFICIALUpdated 4 months ago