Is it possible to analyze data from external S3 bucket in Athena?
I have used official documentation with bucket policy, which allows access to account in which is AWS Athena, but this does not work. I constantly get access denied errors.
I have also tried the same using role as a Principal, but this also doesn't work. This should work, as I found that Athena uses same principal for S3 access as that executing queries.
I have left one other option, which is to copy S3 contents, but this is not what I want to accomplish. All official documentation says is that cross-account access to S3 bucket via bucket policy is possible, but I do not see that such thing is working. If anybody have experience with this, or can test it, I would appreciate.
PS: I already read similar answers here, and did not find any of these working.
UPDATE: These two policies were used. The account numbers are not same.
This is official AWS policy.
{
"Version": "2012-10-17",
"Id": "MyPolicyID",
"Statement": [
{
"Sid": "MyStatementSid",
"Effect": "Allow",
"Principal": {
"AWS": "arn:aws:iam::123456789123:root"
},
"Action": [
"s3:GetBucketLocation",
"s3:GetObject",
"s3:ListBucket",
"s3:ListBucketMultipartUploads",
"s3:ListMultipartUploadParts",
"s3:AbortMultipartUpload",
"s3:PutObject"
],
"Resource": [
"arn:aws:s3:::my-athena-data-bucket",
"arn:aws:s3:::my-athena-data-bucket/*"
]
}
]
}
Another which I tried is the same, just with wildcards:
{
"Version": "2012-10-17",
"Id": "MyPolicyID",
"Statement": [
{
"Sid": "MyStatementSid",
"Effect": "Allow",
"Principal": {
"AWS": "arn:aws:iam::123456789123:root"
},
"Action": [
"s3:Get*",
"s3:List*"
],
"Resource": [
"arn:aws:s3:::my-athena-data-bucket",
"arn:aws:s3:::my-athena-data-bucket/*"
]
}
]
}