AWS Athena

Source and destination

  1. In Polytomic, go to Connections → Add connection → AWS Athena:
  1. Choose an Authentication method:
    • Access Key and Secret: enter the AWS access ID and AWS secret access key of an IAM user with the permissions below.
    • IAM role: enter the IAM role ARN of a role with the permissions below. See IAM role trust policy. Optionally, add Tags to apply as session tags when Polytomic assumes the role.
  1. Fill in the following fields:
  • AWS region (e.g. us-west-1)
  • AWS S3 output bucket: an existing bucket, optionally with a folder (e.g. s3://polytomic-athena-results/customer-dataset). Athena writes query results here. Polytomic also stores the tables it writes to Athena here.
  1. Click Save.

IAM permissions

Polytomic uses the following IAM actions to read from Athena. Grant them on the catalogs, databases, and tables you want to use with Polytomic. Also grant access to the S3 buckets where your data is stored and to the output bucket:

{
  "Version": "2012-10-17",
  "Statement": [
    {
      "Sid": "PolytomicAthenaRead",
      "Effect": "Allow",
      "Action": [
        "athena:GetDataCatalog",
        "athena:GetNamedQuery",
        "athena:GetPreparedStatement",
        "athena:GetQueryExecution",
        "athena:GetQueryResults",
        "athena:GetQueryResultsStream",
        "athena:GetTableMetadata",
        "athena:GetWorkGroup",
        "athena:ListDataCatalogs",
        "athena:ListDatabases",
        "athena:ListTableMetadata",
        "athena:StartQueryExecution",
        "athena:StopQueryExecution",
        "glue:GetDatabase",
        "glue:GetDatabases",
        "glue:GetTable",
        "glue:GetTables",
        "glue:GetPartition",
        "glue:GetPartitions",
        "glue:SearchTables"
      ],
      "Resource": "*"
    },
    {
      "Sid": "PolytomicSourceData",
      "Effect": "Allow",
      "Action": ["s3:GetObject", "s3:ListBucket", "s3:GetBucketLocation"],
      "Resource": ["arn:aws:s3:::my-data-bucket", "arn:aws:s3:::my-data-bucket/*"]
    },
    {
      "Sid": "PolytomicOutputBucket",
      "Effect": "Allow",
      "Action": [
        "s3:GetObject",
        "s3:PutObject",
        "s3:DeleteObject",
        "s3:ListBucket",
        "s3:GetBucketLocation",
        "s3:AbortMultipartUpload",
        "s3:ListMultipartUploadParts"
      ],
      "Resource": ["arn:aws:s3:::my-output-bucket", "arn:aws:s3:::my-output-bucket/*"]
    }
  ]
}

Replace my-data-bucket with each bucket where your Athena data is stored, and my-output-bucket with your output bucket.

To write to Athena, also grant the following Glue Data Catalog actions. Polytomic uses them to create databases and tables (including Iceberg tables) in the output bucket, add, rename, and drop columns, and repair partitions:

{
  "Sid": "PolytomicAthenaWrite",
  "Effect": "Allow",
  "Action": [
    "glue:CreateDatabase",
    "glue:UpdateDatabase",
    "glue:CreateTable",
    "glue:UpdateTable",
    "glue:DeleteTable",
    "glue:BatchCreatePartition",
    "glue:BatchDeletePartition",
    "glue:CreatePartition",
    "glue:DeletePartition",
    "glue:UpdatePartition"
  ],
  "Resource": "*"
}

IAM role trust policy

When you authenticate with an IAM role, the role's trust policy must allow Polytomic (AWS account 568237466542) to assume it, using the External ID shown in the connection form. The External ID is your Polytomic Organization's ID, so it's the same for every IAM role connection in your Organization.

{
  "Version": "2012-10-17",
  "Statement": [
    {
      "Effect": "Allow",
      "Principal": {
        "AWS": "arn:aws:iam::568237466542:root"
      },
      "Action": ["sts:AssumeRole", "sts:TagSession"],
      "Condition": {
        "StringEquals": {
          "sts:ExternalId": "<your External ID>"
        }
      }
    }
  ]
}

sts:TagSession is only required if you set Tags on the connection.

📘

Authenticating with IAM Roles

See Using AWS IAM roles to access S3 buckets for detailed documentation on configuring Polytomic connections with IAM roles.