# Permissions at run time

Know which rights the Backend, the jobs and the nodes have when Platforma runs, so that each team of the company gives only its part.

This page lists the rights that the parts of Platforma have when it runs: the Backend (The server program of Platforma. It keeps the projects, runs the Blocks and starts jobs.), the jobs (One run of a tool on data. The Backend starts jobs on the server where it runs, or in a Kubernetes cluster.) and the nodes. For the rights to install and for the system user in Single Server mode (The mode in which the Backend and all its jobs run on one Linux machine, the server, with no Kubernetes cluster.), see [Permissions](/plan-permissions/).

## Rights of the Backend

#### Variant: Kubernetes cluster

The Backend gets its cloud rights through a cloud identity (The identity that the cloud gives to the Platforma pod (IAM roles for service accounts on AWS, Workload Identity on Google Cloud). With it, Platforma needs no access keys.) bound to its service account, so there are no keys to keep and to rotate:

- **AWS:** an IAM role through IAM roles for service accounts (IRSA), which trusts the OIDC provider of the cluster for the service account of the Backend. Platforma supports IRSA only.
- **Google Cloud:** a Google service account through Workload Identity: the Kubernetes (A system that runs programs on a group of machines (a cluster). Platforma can run in a Kubernetes cluster.) service account has `roles/iam.workloadIdentityUser` on it. A direct Workload Identity principal is not enough, because a signed link names a service account.

Storage without a cloud identity (for example, storage with an S3 interface in the data center) uses access keys in a Secret with the same rights: see [Access keys](/infrastructure-contract-identity/#access-keys). The jobs do not need these rights: the Backend moves the data.

#### Variant: Single Server

The Backend needs cloud rights only when the primary storage (The bucket (Amazon S3 or Google Cloud Storage) or folder where Platforma keeps all results and uploaded files.) or a data library (A folder or bucket with input data of the company. Users select files from it in the Desktop App. Platforma only reads it.) is a bucket: see [Single Server mode](/plan-permissions/#single-server-mode).

### Storage

The Backend reads and writes the primary storage bucket and reads the data library buckets. The cloud-specific Terraform modules (The Terraform modules platforma-tf-cloud-base and platforma-tf-cloud-cluster. There is one pair for each cloud, AWS and Google Cloud. The roots cloud and cluster apply them. They make the network, the Kubernetes cluster, the storage, the cloud identities and the registry caches. They give the hand-off file cluster_config to the cloud-agnostic Terraform modules.) give these rights to the cloud identity of the Backend; give the same rights to a role, an account or keys that you make in another way.

#### Primary storage

#### Variant: Amazon S3

Without a prefix, use `<bucket>/*`.

*Policy of the Backend: primary storage*

```json
{
  "Version": "2012-10-17",
  "Statement": [
    {
      "Sid": "PrimaryStorageBucket",
      "Effect": "Allow",
      "Action": ["s3:ListBucket", "s3:ListBucketMultipartUploads", "s3:GetBucketLocation"],
      "Resource": "arn:aws:s3:::<bucket>"
    },
    {
      "Sid": "PrimaryStorageObjects",
      "Effect": "Allow",
      "Action": [
        "s3:GetObject", "s3:PutObject", "s3:DeleteObject", "s3:AbortMultipartUpload",
        "s3:ListMultipartUploadParts"
      ],
      "Resource": "arn:aws:s3:::<bucket>/<prefix>*"
    }
  ]
}
```

- A bucket encrypted with a customer managed KMS key also needs `kms:Decrypt` and `kms:GenerateDataKey` on that key.
- The links that the Backend signs for the Desktop App (The program that each user installs on their own computer to work with Platforma. It is a client of the Backend.) do not need another action.

#### Variant: Google Cloud Storage

- `roles/storage.objectUser` on the bucket.
- `roles/iam.serviceAccountTokenCreator` on the Backend account itself, for the signed links of the Desktop App (`iam.serviceAccounts.signBlob`). A custom role with only this permission is narrower.

*Roles of the Backend account: primary storage*

```sh
SA=<backend account>@<project>.iam.gserviceaccount.com
gcloud storage buckets add-iam-policy-binding gs://<bucket> \
  --member="serviceAccount:$SA" --role=roles/storage.objectUser
gcloud iam service-accounts add-iam-policy-binding "$SA" \
  --member="serviceAccount:$SA" --role=roles/iam.serviceAccountTokenCreator
```

#### Data libraries

A data library that the Backend reads with [its own identity](/security-data-library-access/#identity-of-the-backend) needs read rights only. Give them for each library. The access modes for each user ([federated user access](/configuration-data-libraries/#federated-user-access) and [Google account of the user](/configuration-data-libraries/#google-account-of-the-user)) do not need library rights for the Backend.

#### Variant: Amazon S3

Without a library prefix, drop the condition.

*Policy of the Backend: data library*

```json
{
  "Version": "2012-10-17",
  "Statement": [
    {
      "Sid": "DataLibraryBucket",
      "Effect": "Allow",
      "Action": ["s3:ListBucket"],
      "Resource": "arn:aws:s3:::<library bucket>",
      "Condition": {"StringLike": {"s3:prefix": ["<library prefix>*"]}}
    },
    {
      "Sid": "DataLibraryBucketLocation",
      "Effect": "Allow",
      "Action": ["s3:GetBucketLocation"],
      "Resource": "arn:aws:s3:::<library bucket>"
    },
    {
      "Sid": "DataLibraryObjects",
      "Effect": "Allow",
      "Action": ["s3:GetObject"],
      "Resource": "arn:aws:s3:::<library bucket>/<library prefix>*"
    }
  ]
}
```

A library bucket in another AWS account also needs a bucket policy of its owner:

*Bucket policy of the library owner*

```json
{
  "Version": "2012-10-17",
  "Statement": [
    {
      "Sid": "PlatformaBackendRead",
      "Effect": "Allow",
      "Principal": {"AWS": "arn:aws:iam::<account>:role/<backend role>"},
      "Action": ["s3:ListBucket", "s3:GetBucketLocation"],
      "Resource": "arn:aws:s3:::<library bucket>"
    },
    {
      "Sid": "PlatformaBackendReadObjects",
      "Effect": "Allow",
      "Principal": {"AWS": "arn:aws:iam::<account>:role/<backend role>"},
      "Action": ["s3:GetObject"],
      "Resource": "arn:aws:s3:::<library bucket>/<library prefix>*"
    }
  ]
}
```

#### Variant: Google Cloud Storage

`roles/storage.objectViewer` on the library bucket. For a library with a prefix, an IAM condition limits the reads to the prefix; the bucket must have uniform bucket-level access.

*Role of the Backend account: data library*

```sh
SA=<backend account>@<project>.iam.gserviceaccount.com
gcloud storage buckets add-iam-policy-binding gs://<library bucket> \
  --member="serviceAccount:$SA" --role=roles/storage.objectViewer \
  --condition='title=platforma-data-library-prefix,expression=resource.type != "storage.googleapis.com/Object" || resource.name.startsWith("projects/_/buckets/<library bucket>/objects/<library prefix>")'
```

Without a library prefix, drop `--condition`.

> **Caution:**
>
> An IAM condition cannot limit the listing: with a library prefix, the Backend can see the names of all objects of the library bucket, but it can read only the objects under the prefix.

For the other access modes of data libraries, see [Data library access modes](/security-data-library-access/).

### Rights in Kubernetes

The chart gives the Backend a Role in its namespace; the CronJob that removes finished AppWrappers uses the same service account:

| Resource (API group)                                         | Rights                                              |
| ------------------------------------------------------------ | --------------------------------------------------- |
| `appwrappers` (`workload.codeflare.dev`), `jobs` (`batch`)   | `create`, `delete`, `get`, `list`, `watch`, `patch` |
| `workloads` (`kueue.x-k8s.io`), `pods`, `pods/log`, `events` | `get`, `list`, `watch`                              |
| `localqueues` (`kueue.x-k8s.io`), `configmaps`               | `get`, `list`                                       |
| `secrets`                                                    | `get`                                               |

Optional: read on its two ClusterQueues, for the queue statistics in the Desktop App (see the tab “Helm chart” in [Rights to install](/plan-permissions/#rights-to-install)). The Backend does not make volumes, Secrets, namespaces or objects outside its namespace: the chart makes them at install time.

> **Caution:**
>
> The Backend can read every Secret of its namespace, so install it in a namespace of its own: see [Identities in the cluster](/security-access-control/#identities-in-the-cluster).

## Rights of the jobs and the nodes

In a cluster, the jobs do not need cloud or Kubernetes rights: the Backend moves their data, so a tool in a job cannot reach the storage with a right of its own. On AWS, the service account of the jobs has an IAM role with no policies. You can add policies to it when a job must reach another AWS service. On Google Cloud, it does not have a Google identity.

The nodes need only the right to pull images:

- **AWS:** `AmazonEC2ContainerRegistryPullOnly`, `AmazonEKSWorkerNodePolicy` and `AmazonEKS_CNI_Policy`. With the caches of `registry_mirrors`, also `ecr:BatchImportUpstreamImage`, `ecr:CreateRepository` and `ecr:TagResource` on the cached repositories.
- **Google Cloud:** `roles/artifactregistry.reader` on each cache of `registry_mirrors`, and `roles/container.defaultNodeServiceAccount` on the project for the node logs and metrics.

The pods cannot use the identity of the node: the instance metadata service allows one network hop (AWS), and the GKE metadata server is on (Google Cloud). The controllers that the modules install on AWS each have their own IAM role; see [Terraform modules](/reference-terraform-modules/).

## Next

- [Prerequisites checklist](/plan-prerequisites-checklist/)
- [Identity, Secrets and outbound access](/infrastructure-contract-identity/)
- [Access control](/security-access-control/)

Source: https://docs.platforma.bio/plan-permissions-runtime/
