Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save alecbw/1075fb840926da9422fe53c02b87d220 to your computer and use it in GitHub Desktop.
Save alecbw/1075fb840926da9422fe53c02b87d220 to your computer and use it in GitHub Desktop.
A policy you can attach to a role to enable the caller to read from Athena tables. s3:PutObject is required to put the query results CSV in the query result bucket.
{
"Statement": [
{
"Action": [
"s3:ListBucket",
"s3:GetBucketLocation"
],
"Effect": "Allow",
"Resource": [
"arn:aws:s3:::bucket-your-data-is-in",
"arn:aws:s3:::bucket-specified-for-athena-query-results",
],
"Sid": "FindAndScanStagingBuckets"
},
{
"Action": [
"s3:GetObject",
"s3:PutObject"
],
"Effect": "Allow",
"Resource": [
"arn:aws:s3:::bucket-your-data-is-in/some-subfolder/*",
"arn:aws:s3:::bucket-specified-for-athena-query-results/*",
],
"Sid": "GetAndPutAthenaAndPublicResults3Objects"
},
{
"Action": [
"glue:GetTable",
"glue:GetTables",
"glue:SearchTables",
"glue:GetTable",
"glue:GetDatabase",
"glue:GetPartitions"
],
"Effect": "Allow",
"Resource": [
"arn:aws:glue:us-west-1:YOURAWSACCOUNTID:*"
],
"Sid": "AccessGlueParts"
},
{
"Action": [
"athena:StartQueryExecution",
"athena:CancelQueryExecution",
"athena:StopQueryExecution",
"athena:GetQueryExecution",
"athena:GetQueryResults",
"athena:GetWorkGroup"
],
"Effect": "Allow",
"Resource": [
"arn:aws:athena:us-west-1:YOURAWSACCOUNTID:*"
],
"Sid": "EnableAthenaQueries"
}
],
"Version": "2012-10-17"
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment