Skip to content

Access denied when writing output to url: . Please ensure you are allowed to access the S3 bucket

0

Access denied when writing output to url: s3://aws-athena-query-results-prod-khatabook/Unsaved/2025/09/22/b7869080-3df0-4cc9-bc31-614298c7455e.csv . Please ensure you are allowed to access the S3 bucket. If specifying an expected bucket owner, confirm the bucket is owned by the expected account. If you are encrypting query results with KMS key, please ensure you are allowed to access your KMS key

asked a year ago298 views

1 Answer
0

Hello.

Judging from the error message, it seems that access to the S3 bucket "aws-athena-query-results-prod-khatabook" has been denied.
As described in the following document, please check whether the IAM user's IAM policy is set to allow access to the S3 bucket.
Please change the S3 bucket name in the IAM policy below to your own S3 bucket name.
https://repost.aws/knowledge-center/access-denied-athena

{  
  "Version": "2012-10-17",
  "Statement": [  
    {  
      "Effect": "Allow",  
      "Action": [  
        "s3:ListBucket"  
      ],  
      "Resource": [  
        "arn:aws:s3:::my-athena-source-bucket"  
      ]  
    },  
    {  
      "Effect": "Allow",  
      "Action": [  
        "s3:GetObject"  
      ],  
      "Resource": [  
        "arn:aws:s3:::my-athena-source-bucket/data/*"  
      ]  
    },  
    {  
      "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/*"  
      ]  
    }  
  ]  
}
EXPERT

answered a year ago

EXPERT

reviewed a year ago

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.