Skip to content

Set up serverless

Serverless is on by default for every workspace, and Polars Nanook runs its compute in its own AWS account. The only setup is access to your data. The settings are under Integrations > Infrastructure in the portal sidebar: select Serverless.

Regions

A serverless cluster runs in one AWS region. The Serverless page lists the available regions and sets the workspace's default region, which a ComputeContext uses when it passes no region. Run the cluster in the region of your data. The workers reach S3 in their own region only, and nothing outside AWS, so HTTP URLs, Google Cloud Storage and Azure Blob Storage don't work.

Data access

Serverless clusters run under an IAM role of Polars Nanook, and each carries the principal tag kubernetes-service-account with the workspace ID as its value. A bucket policy that names the role and requires the tag gives the clusters of one workspace access to the bucket. The Serverless page shows the role ARN and this policy, filled in for the workspace:

{
  "Version": "2012-10-17",
  "Statement": [
    {
      "Sid": "AllowPolarsServerlessAccess",
      "Effect": "Allow",
      "Principal": { "AWS": "<ROLE_ARN>" },
      "Action": ["s3:GetObject", "s3:PutObject", "s3:ListBucket"],
      "Resource": ["arn:aws:s3:::<BUCKET>", "arn:aws:s3:::<BUCKET>/*"],
      "Condition": {
        "StringEquals": {
          "aws:PrincipalTag/kubernetes-service-account": "<WORKSPACE_ID>"
        }
      }
    }
  ]
}

Add it to the bucket under Permissions > Bucket policy in the S3 console. Keep the condition: without it, the serverless clusters of every workspace can use the bucket. Remove s3:PutObject for read-only access, or add other S3 actions the queries need.

For a bucket encrypted with your own KMS key, also allow kms:Decrypt and kms:GenerateDataKey for the role in the key policy, with the same condition.

Queries then read and write the bucket as described in Read and write cloud storage.