# Permissions

Know which rights each part of the installation needs, so that each team of the company gives only its part.

Each step of the installation needs only its own rights, so each team of the company gives only its part. The person who installs Platforma does not need the rights of the whole cloud account. When it runs, the Backend (The server program of Platforma. It keeps the projects, runs the Blocks and starts jobs.) has narrow rights on its storage and in its namespace, and in a cloud it uses 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.) instead of keys. Give this page to the teams that help you.

- [Rights to install](/plan-permissions/#rights-to-install): for each path and step.
- [Rights of the Backend](/plan-permissions-runtime/#rights-of-the-backend): storage and Kubernetes (A system that runs programs on a group of machines (a cluster). Platforma can run in a Kubernetes cluster.).
- [Rights of the jobs and the nodes](/plan-permissions-runtime/#rights-of-the-jobs-and-the-nodes): none, or image pulls.
- [Single Server mode](/plan-permissions/#single-server-mode): one system user.
- [Cloud quotas](/plan-permissions/#cloud-quotas): vCPUs and GPUs.
- [Who usually holds which rights](/plan-permissions/#who-usually-holds-which-rights): the teams of a company.

For the security view, see [Identities in the cluster](/security-access-control/#identities-in-the-cluster).

## Rights to install

Open the tab of your installation path (A set of tools and steps that installs Platforma. There are five installation paths: the AWS installer, the Google Cloud installer, the Terraform modules, the Helm chart and Single Server mode.). Each step lists its rights, then gives a text to copy for the team that grants them. Replace the values in angle brackets. The rights of a step also cover the later steps of the same identity. For example, on AWS the rights of the root `cloud` are enough to apply the roots `cluster` and `services` too, except the cleanup at the destroy of the root `cluster` (step 2). On Google Cloud, the roles of the root `cloud` do not include the cluster admin: add the roles of step 2 for the root `cluster`. For why the installation has separate steps, see [Rights to install](/security-access-control/#rights-to-install) in Security.

#### Variant: AWS installer

The person who creates the CloudFormation stack needs these rights. CloudFormation makes the resources with them; the stack then makes its own roles for the deployers that install the charts.

- **CloudFormation:** the stack `<STACK_NAME>`.

- **Network and cluster:**

  - the VPC and its parts;
  - the EKS cluster `<CLUSTER_NAME>` (the parameter “Cluster name”) with its node groups, add-ons and access entry;
  - the EFS file system;
  - KMS grants through EC2 and EFS for the default encryption.

- **Services:**

  - the ACM certificate and its records in the hosted zone `<HOSTED_ZONE_ID>`;
  - the bucket `platforma-<CLUSTER_NAME>-*`;
  - the image cache `quay-<CLUSTER_NAME>` in ECR;
  - the CodeBuild projects and the Lambda functions `<CLUSTER_NAME>-*`;
  - CloudWatch Logs;
  - read of the generated passwords in SSM Parameter Store, and a change of these passwords and of the master secret;
  - the Secrets Manager secrets `platforma/<CLUSTER_NAME>/*`, where the stack keeps the values of its secret parameters.

- **IAM:** the roles and policies `<CLUSTER_NAME>-*`, the OIDC provider of the cluster, `iam:PassRole` of these roles to EKS, EC2, CodeBuild and Lambda only, and the service-linked roles of EKS, EFS and the ECR cache.

AWS limits a managed policy to 6,144 characters, so the rights are three policies. Attach them as customer-managed policies: as inline policies, they exceed the AWS limit of 10,240 bytes for each role. For an existing bucket (the parameter “S3 bucket name”), add its ARNs to the statement `PrimaryBucket`. The statements `LeftLogGroups`, `KeptVolumes`, `KeptVolumesRead` and `KeptMasterSecret` let you delete the log groups, the volumes and the master secret that stay after the stack is deleted: see [Uninstall an installer installation](/maintain-uninstalling-cloud-installer/). The statement `ChangePassword` lets you change the administrator password, the password of the generated list of users and the master secret: see [Update an installer installation](/maintain-updating-cloud-installer/#change-a-secret).

*Policy 1 of 3: stack, network, cluster*

```json
{
  "Version": "2012-10-17",
  "Statement": [
    {
      "Sid": "Stack",
      "Effect": "Allow",
      "Action": [
        "cloudformation:CreateStack", "cloudformation:UpdateStack", "cloudformation:DeleteStack",
        "cloudformation:DescribeStacks", "cloudformation:DescribeStackEvents",
        "cloudformation:DescribeStackResource", "cloudformation:DescribeStackResources",
        "cloudformation:ListStackResources", "cloudformation:GetTemplate",
        "cloudformation:GetStackPolicy", "cloudformation:CreateChangeSet",
        "cloudformation:DescribeChangeSet", "cloudformation:ExecuteChangeSet",
        "cloudformation:DeleteChangeSet", "cloudformation:ListChangeSets"
      ],
      "Resource": "arn:aws:cloudformation:<REGION>:<ACCOUNT_ID>:stack/<STACK_NAME>/*"
    },
    {
      "Sid": "StackRead",
      "Effect": "Allow",
      "Action": [
        "cloudformation:GetTemplateSummary", "cloudformation:ValidateTemplate",
        "cloudformation:ListStacks"
      ],
      "Resource": "*"
    },
    {
      "Sid": "Network",
      "Effect": "Allow",
      "Action": [
        "ec2:CreateVpc", "ec2:DeleteVpc", "ec2:ModifyVpcAttribute", "ec2:ModifyVpcTenancy",
        "ec2:DescribeVpcs", "ec2:DescribeVpcAttribute", "ec2:DescribeVpcEncryptionControls",
        "ec2:CreateVpcEncryptionControl", "ec2:DescribeNetworkAcls", "ec2:CreateSubnet",
        "ec2:DeleteSubnet", "ec2:ModifySubnetAttribute", "ec2:DescribeSubnets",
        "ec2:AssociateSubnetCidrBlock", "ec2:DisassociateSubnetCidrBlock",
        "ec2:CreateInternetGateway", "ec2:DeleteInternetGateway", "ec2:AttachInternetGateway",
        "ec2:DetachInternetGateway", "ec2:DescribeInternetGateways", "ec2:AttachVpnGateway",
        "ec2:DetachVpnGateway", "ec2:DescribeVpnGateways", "ec2:CreateNatGateway",
        "ec2:DeleteNatGateway", "ec2:DescribeNatGateways", "ec2:AssociateNatGatewayAddress",
        "ec2:DisassociateNatGatewayAddress", "ec2:AssignPrivateNatGatewayAddress",
        "ec2:UnassignPrivateNatGatewayAddress", "ec2:AllocateAddress", "ec2:ReleaseAddress",
        "ec2:AssociateAddress", "ec2:DisassociateAddress", "ec2:AcceptAddressTransfer",
        "ec2:DescribeAddresses", "ec2:CreateRouteTable", "ec2:DeleteRouteTable",
        "ec2:DescribeRouteTables", "ec2:CreateRoute", "ec2:DeleteRoute", "ec2:ReplaceRoute",
        "ec2:AssociateRouteTable", "ec2:DisassociateRouteTable",
        "ec2:ReplaceRouteTableAssociation", "ec2:CreateSecurityGroup", "ec2:DeleteSecurityGroup",
        "ec2:AuthorizeSecurityGroupIngress", "ec2:RevokeSecurityGroupIngress",
        "ec2:AuthorizeSecurityGroupEgress", "ec2:RevokeSecurityGroupEgress",
        "ec2:UpdateSecurityGroupRuleDescriptionsIngress",
        "ec2:UpdateSecurityGroupRuleDescriptionsEgress", "ec2:DescribeSecurityGroups",
        "ec2:DescribeSecurityGroupRules", "ec2:CreateLaunchTemplate", "ec2:DeleteLaunchTemplate",
        "ec2:CreateLaunchTemplateVersion", "ec2:DeleteLaunchTemplateVersions",
        "ec2:ModifyLaunchTemplate", "ec2:DescribeLaunchTemplates",
        "ec2:DescribeLaunchTemplateVersions", "ec2:DescribeAvailabilityZones",
        "ec2:DescribeNetworkInterfaces", "ec2:CreateNetworkInterface",
        "ec2:DeleteNetworkInterface", "ec2:ModifyNetworkInterfaceAttribute", "ec2:RunInstances",
        "ec2:CreateTags", "ec2:DeleteTags", "ec2:DescribeTags", "ec2:DescribeInstances",
        "ec2:DescribeInstanceTypes", "ec2:DescribeImages", "ec2:DescribeKeyPairs",
        "ec2:DescribeAccountAttributes", "ec2:DescribeRegions"
      ],
      "Resource": "*"
    },
    {
      "Sid": "ClusterRead",
      "Effect": "Allow",
      "Action": [
        "eks:DescribeAccessEntry", "eks:DescribeAddon", "eks:DescribeCluster",
        "eks:DescribeNodegroup", "eks:DescribeUpdate", "eks:ListAssociatedAccessPolicies",
        "eks:ListUpdates", "eks:DescribeAddonVersions", "eks:DescribeAddonConfiguration"
      ],
      "Resource": "*"
    },
    {
      "Sid": "Cluster",
      "Effect": "Allow",
      "Action": [
        "eks:ActivateCertificateAuthority", "eks:AssociateAccessPolicy", "eks:CreateAccessEntry",
        "eks:CreateAddon", "eks:CreateCluster", "eks:CreateNodegroup",
        "eks:CreatePodIdentityAssociation", "eks:DeleteAccessEntry", "eks:DeleteAddon",
        "eks:DeleteCluster", "eks:DeleteNodegroup", "eks:DeletePodIdentityAssociation",
        "eks:DisassociateAccessPolicy", "eks:TagResource", "eks:UntagResource",
        "eks:UpdateAccessEntry", "eks:UpdateAddon", "eks:UpdateClusterConfig",
        "eks:UpdateClusterVersion", "eks:UpdateNodegroupConfig", "eks:UpdateNodegroupVersion",
        "eks:UpdatePodIdentityAssociation"
      ],
      "Resource": [
        "arn:aws:eks:<REGION>:<ACCOUNT_ID>:cluster/<CLUSTER_NAME>",
        "arn:aws:eks:<REGION>:<ACCOUNT_ID>:nodegroup/<CLUSTER_NAME>/*",
        "arn:aws:eks:<REGION>:<ACCOUNT_ID>:addon/<CLUSTER_NAME>/*",
        "arn:aws:eks:<REGION>:<ACCOUNT_ID>:access-entry/<CLUSTER_NAME>/*",
        "arn:aws:eks:<REGION>:<ACCOUNT_ID>:podidentityassociation/<CLUSTER_NAME>/*"
      ]
    },
    {
      "Sid": "Workspace",
      "Effect": "Allow",
      "Action": [
        "elasticfilesystem:CreateFileSystem", "elasticfilesystem:CreateMountTarget",
        "elasticfilesystem:CreateReplicationConfiguration", "elasticfilesystem:DeleteFileSystem",
        "elasticfilesystem:DeleteFileSystemPolicy", "elasticfilesystem:DeleteMountTarget",
        "elasticfilesystem:DeleteReplicationConfiguration", "elasticfilesystem:DeleteTags",
        "elasticfilesystem:DescribeBackupPolicy", "elasticfilesystem:DescribeFileSystemPolicy",
        "elasticfilesystem:DescribeFileSystems",
        "elasticfilesystem:DescribeLifecycleConfiguration",
        "elasticfilesystem:DescribeMountTargetSecurityGroups",
        "elasticfilesystem:DescribeMountTargets",
        "elasticfilesystem:DescribeReplicationConfigurations",
        "elasticfilesystem:ListTagsForResource",
        "elasticfilesystem:ModifyMountTargetSecurityGroups", "elasticfilesystem:PutBackupPolicy",
        "elasticfilesystem:PutFileSystemPolicy", "elasticfilesystem:PutLifecycleConfiguration",
        "elasticfilesystem:TagResource", "elasticfilesystem:UntagResource",
        "elasticfilesystem:UpdateFileSystem", "elasticfilesystem:UpdateFileSystemProtection"
      ],
      "Resource": "*"
    },
    {
      "Sid": "EncryptionThroughServices",
      "Effect": "Allow",
      "Action": [
        "kms:CreateGrant", "kms:RetireGrant", "kms:GenerateDataKey",
        "kms:GenerateDataKeyWithoutPlaintext", "kms:Encrypt", "kms:Decrypt"
      ],
      "Resource": "*",
      "Condition": {"StringLike": {"kms:ViaService": ["ec2.<REGION>.amazonaws.com", "elasticfilesystem.<REGION>.amazonaws.com"]}}
    },
    {
      "Sid": "KeyRead",
      "Effect": "Allow",
      "Action": ["kms:DescribeKey"],
      "Resource": "*"
    }
  ]
}
```

*Policy 2 of 3: certificate, storage, deployers*

```json
{
  "Version": "2012-10-17",
  "Statement": [
    {
      "Sid": "Certificate",
      "Effect": "Allow",
      "Action": [
        "acm:AddTagsToCertificate", "acm:DeleteCertificate", "acm:DescribeCertificate",
        "acm:ListTagsForCertificate", "acm:RemoveTagsFromCertificate", "acm:RequestCertificate",
        "acm:UpdateCertificateOptions"
      ],
      "Resource": "*"
    },
    {
      "Sid": "DnsRead",
      "Effect": "Allow",
      "Action": [
        "route53:ListHostedZones", "route53:ListHostedZonesByName", "route53:GetHostedZoneCount",
        "route53:GetHostedZone", "route53:ListResourceRecordSets", "route53:ListTagsForResource",
        "route53:GetChange"
      ],
      "Resource": "*"
    },
    {
      "Sid": "CertificateValidationRecords",
      "Effect": "Allow",
      "Action": ["route53:ChangeResourceRecordSets"],
      "Resource": "arn:aws:route53:::hostedzone/<HOSTED_ZONE_ID>"
    },
    {
      "Sid": "InstallerSecrets",
      "Effect": "Allow",
      "Action": [
        "secretsmanager:CreateSecret", "secretsmanager:DeleteSecret",
        "secretsmanager:DescribeSecret", "secretsmanager:GetSecretValue",
        "secretsmanager:PutSecretValue", "secretsmanager:UpdateSecret",
        "secretsmanager:TagResource", "secretsmanager:UntagResource"
      ],
      "Resource": "arn:aws:secretsmanager:<REGION>:<ACCOUNT_ID>:secret:platforma/<CLUSTER_NAME>/*"
    },
    {
      "Sid": "PrimaryBucket",
      "Effect": "Allow",
      "Action": ["s3:*"],
      "Resource": [
        "arn:aws:s3:::platforma-<CLUSTER_NAME>-*", "arn:aws:s3:::platforma-<CLUSTER_NAME>-*/*"
      ]
    },
    {
      "Sid": "ImageCache",
      "Effect": "Allow",
      "Action": [
        "ecr:CreatePullThroughCacheRule", "ecr:DescribePullThroughCacheRules",
        "ecr:DeletePullThroughCacheRule"
      ],
      "Resource": "*"
    },
    {
      "Sid": "ImageCacheRepository",
      "Effect": "Allow",
      "Action": [
        "ecr:BatchGetImage", "ecr:CreateRepository", "ecr:DeleteLifecyclePolicy",
        "ecr:DeleteRepository", "ecr:DeleteRepositoryPolicy", "ecr:DescribeRepositories",
        "ecr:GetDownloadUrlForLayer", "ecr:GetLifecyclePolicy", "ecr:GetRepositoryPolicy",
        "ecr:ListTagsForResource", "ecr:PutImageScanningConfiguration",
        "ecr:PutImageTagMutability", "ecr:PutLifecyclePolicy", "ecr:SetRepositoryPolicy",
        "ecr:TagResource", "ecr:UntagResource"
      ],
      "Resource": "arn:aws:ecr:<REGION>:<ACCOUNT_ID>:repository/quay-<CLUSTER_NAME>/*"
    },
    {
      "Sid": "Deployers",
      "Effect": "Allow",
      "Action": [
        "codebuild:BatchGetBuilds", "codebuild:BatchGetProjects", "codebuild:CreateProject",
        "codebuild:CreateWebhook", "codebuild:DeleteProject", "codebuild:DeleteWebhook",
        "codebuild:ListBuildsForProject", "codebuild:UpdateProject",
        "codebuild:UpdateProjectVisibility", "codebuild:UpdateWebhook"
      ],
      "Resource": [
        "arn:aws:codebuild:<REGION>:<ACCOUNT_ID>:project/<CLUSTER_NAME>-helm-deployer",
        "arn:aws:codebuild:<REGION>:<ACCOUNT_ID>:project/<CLUSTER_NAME>-platforma-deployer"
      ]
    },
    {
      "Sid": "Functions",
      "Effect": "Allow",
      "Action": [
        "lambda:AssociateRuntimeAlias", "lambda:CreateFunction", "lambda:DeleteFunction",
        "lambda:DeleteFunctionCodeSigningConfig", "lambda:DeleteFunctionConcurrency",
        "lambda:GetCodeSigningConfig", "lambda:GetFunction", "lambda:GetFunctionCodeSigningConfig",
        "lambda:GetFunctionConfiguration", "lambda:GetFunctionRecursionConfig",
        "lambda:GetFunctionScalingConfig", "lambda:GetRuntimeManagementConfig",
        "lambda:InvokeFunction", "lambda:PublishVersion", "lambda:PutFunctionCodeSigningConfig",
        "lambda:PutFunctionConcurrency", "lambda:PutFunctionRecursionConfig",
        "lambda:PutFunctionScalingConfig", "lambda:PutRuntimeManagementConfig",
        "lambda:TagResource", "lambda:UntagResource", "lambda:UpdateFunctionCode",
        "lambda:UpdateFunctionConfiguration"
      ],
      "Resource": "arn:aws:lambda:<REGION>:<ACCOUNT_ID>:function:<CLUSTER_NAME>-*"
    },
    {
      "Sid": "LogsAccount",
      "Effect": "Allow",
      "Action": [
        "logs:DescribeLogGroups", "logs:DescribeIndexPolicies", "logs:DescribeResourcePolicies",
        "logs:PutResourcePolicy", "logs:DeleteResourcePolicy", "logs:CreateLogDelivery",
        "logs:PutBearerTokenAuthentication", "ssm:DescribeParameters"
      ],
      "Resource": "*"
    },
    {
      "Sid": "ClusterLogGroup",
      "Effect": "Allow",
      "Action": [
        "logs:AssociateKmsKey", "logs:CreateLogGroup", "logs:DeleteDataProtectionPolicy",
        "logs:DeleteIndexPolicy", "logs:DeleteLogGroup", "logs:DeleteRetentionPolicy",
        "logs:DisassociateKmsKey", "logs:GetDataProtectionPolicy", "logs:ListTagsForResource",
        "logs:PutDataProtectionPolicy", "logs:PutIndexPolicy",
        "logs:PutLogGroupDeletionProtection", "logs:PutRetentionPolicy", "logs:TagResource",
        "logs:UntagResource"
      ],
      "Resource": [
        "arn:aws:logs:<REGION>:<ACCOUNT_ID>:log-group:/aws/eks/<CLUSTER_NAME>/cluster",
        "arn:aws:logs:<REGION>:<ACCOUNT_ID>:log-group:/aws/eks/<CLUSTER_NAME>/cluster:*"
      ]
    },
    {
      "Sid": "DeployLogs",
      "Effect": "Allow",
      "Action": [
        "logs:DescribeLogStreams", "logs:GetLogEvents", "logs:FilterLogEvents", "logs:StartQuery",
        "logs:GetQueryResults"
      ],
      "Resource": [
        "arn:aws:logs:<REGION>:<ACCOUNT_ID>:log-group:/aws/codebuild/<CLUSTER_NAME>-helm-deployer:*",
        "arn:aws:logs:<REGION>:<ACCOUNT_ID>:log-group:/aws/codebuild/<CLUSTER_NAME>-platforma-deployer:*",
        "arn:aws:logs:<REGION>:<ACCOUNT_ID>:log-group:/aws/lambda/<CLUSTER_NAME>-helm-trigger:*"
      ]
    },
    {
      "Sid": "LeftLogGroups",
      "Effect": "Allow",
      "Action": "logs:DeleteLogGroup",
      "Resource": [
        "arn:aws:logs:<REGION>:<ACCOUNT_ID>:log-group:/aws/codebuild/<CLUSTER_NAME>-*",
        "arn:aws:logs:<REGION>:<ACCOUNT_ID>:log-group:/aws/lambda/<CLUSTER_NAME>-*"
      ]
    },
    {
      "Sid": "KeptVolumes",
      "Effect": "Allow",
      "Action": "ec2:DeleteVolume",
      "Resource": "arn:aws:ec2:<REGION>:<ACCOUNT_ID>:volume/*",
      "Condition": {"StringEquals": {"aws:ResourceTag/ebs.csi.aws.com/cluster-name": "<CLUSTER_NAME>"}}
    },
    {
      "Sid": "KeptVolumesRead",
      "Effect": "Allow",
      "Action": "ec2:DescribeVolumes",
      "Resource": "*"
    },
    {
      "Sid": "KeptMasterSecret",
      "Effect": "Allow",
      "Action": "ssm:DeleteParameter",
      "Resource": "arn:aws:ssm:<REGION>:<ACCOUNT_ID>:parameter/<CLUSTER_NAME>/platforma/master-secret"
    },
    {
      "Sid": "GeneratedPassword",
      "Effect": "Allow",
      "Action": ["ssm:GetParameter", "ssm:GetParameters", "ssm:GetParametersByPath"],
      "Resource": "arn:aws:ssm:<REGION>:<ACCOUNT_ID>:parameter/<CLUSTER_NAME>/platforma/*"
    },
    {
      "Sid": "ChangePassword",
      "Effect": "Allow",
      "Action": "ssm:PutParameter",
      "Resource": [
        "arn:aws:ssm:<REGION>:<ACCOUNT_ID>:parameter/<CLUSTER_NAME>/platforma/admin-password",
        "arn:aws:ssm:<REGION>:<ACCOUNT_ID>:parameter/<CLUSTER_NAME>/platforma/users-password",
        "arn:aws:ssm:<REGION>:<ACCOUNT_ID>:parameter/<CLUSTER_NAME>/platforma/master-secret"
      ]
    }
  ]
}
```

*Policy 3 of 3: IAM*

```json
{
  "Version": "2012-10-17",
  "Statement": [
    {
      "Sid": "IamRead",
      "Effect": "Allow",
      "Action": [
        "iam:GetRole", "iam:GetPolicy", "iam:GetPolicyVersion", "iam:GetOpenIDConnectProvider",
        "iam:ListOpenIDConnectProviders", "iam:ListEntitiesForPolicy", "iam:ListPolicies",
        "iam:ListRoles"
      ],
      "Resource": "*"
    },
    {
      "Sid": "Roles",
      "Effect": "Allow",
      "Action": [
        "iam:AttachRolePolicy", "iam:CreatePolicy", "iam:CreatePolicyVersion", "iam:CreateRole",
        "iam:DeletePolicy", "iam:DeletePolicyVersion", "iam:DeleteRole",
        "iam:DeleteRolePermissionsBoundary", "iam:DeleteRolePolicy", "iam:DetachRolePolicy",
        "iam:GetPolicy", "iam:GetPolicyVersion", "iam:GetRole", "iam:GetRolePolicy",
        "iam:ListAttachedRolePolicies", "iam:ListPolicyVersions", "iam:ListRolePolicies",
        "iam:PutRolePermissionsBoundary", "iam:PutRolePolicy", "iam:TagRole", "iam:UntagRole",
        "iam:UpdateAssumeRolePolicy", "iam:UpdateRole", "iam:UpdateRoleDescription"
      ],
      "Resource": [
        "arn:aws:iam::<ACCOUNT_ID>:role/<CLUSTER_NAME>-*",
        "arn:aws:iam::<ACCOUNT_ID>:policy/<CLUSTER_NAME>-*"
      ]
    },
    {
      "Sid": "OidcProvider",
      "Effect": "Allow",
      "Action": [
        "iam:AddClientIDToOpenIDConnectProvider", "iam:CreateOpenIDConnectProvider",
        "iam:DeleteOpenIDConnectProvider", "iam:GetOpenIDConnectProvider",
        "iam:ListOpenIDConnectProviderTags", "iam:RemoveClientIDFromOpenIDConnectProvider",
        "iam:TagOpenIDConnectProvider", "iam:UntagOpenIDConnectProvider",
        "iam:UpdateOpenIDConnectProviderThumbprint"
      ],
      "Resource": "arn:aws:iam::<ACCOUNT_ID>:oidc-provider/oidc.eks.<REGION>.amazonaws.com/id/*"
    },
    {
      "Sid": "PassRoles",
      "Effect": "Allow",
      "Action": ["iam:PassRole"],
      "Resource": "arn:aws:iam::<ACCOUNT_ID>:role/<CLUSTER_NAME>-*",
      "Condition": {"StringEquals": {"iam:PassedToService": ["eks.amazonaws.com", "ec2.amazonaws.com", "codebuild.amazonaws.com", "lambda.amazonaws.com"]}}
    },
    {
      "Sid": "ServiceLinkedRoles",
      "Effect": "Allow",
      "Action": ["iam:CreateServiceLinkedRole"],
      "Resource": "*",
      "Condition": {"StringEquals": {"iam:AWSServiceName": ["eks.amazonaws.com", "eks-nodegroup.amazonaws.com", "pullthroughcache.ecr.amazonaws.com", "elasticfilesystem.amazonaws.com"]}}
    }
  ]
}
```

**Optional permissions.** When a stack create starts, CloudFormation itself reads two account limits as checks before it creates the resources. It calls `servicequotas:GetServiceQuota` (the service quotas of the account) and `lambda:GetAccountSettings` (the Lambda limits of the account). Both actions only read and change nothing, and they cannot be limited to resources. The three policies do not include them. Without them, CloudTrail shows these calls as `AccessDenied` on each stack create, and the installation still completes. To stop these entries, add this statement to one of the policies:

*Optional statement*

```json
{
  "Sid": "OptionalCloudFormationChecks",
  "Effect": "Allow",
  "Action": ["servicequotas:GetServiceQuota", "lambda:GetAccountSettings"],
  "Resource": "*"
}
```

#### Variant: Google Cloud installer

Three identities need rights:

- **The person who runs `install.sh`** in Cloud Shell (or a CI identity). The project must have a billing account. The script enables the APIs `config`, `cloudquotas`, `iam` and `secretmanager`, creates the deployer service account, and stores the secrets in Secret Manager. It starts Infrastructure Manager, and between the two deployments it writes the namespace `platforma` and its Kubernetes Secrets (`roles/container.developer`). Each run of `install.sh` and `teardown.sh` needs `roles/config.admin` (Infrastructure Manager Admin): the installation, each update and the uninstall. `install.sh` checks its permissions (`config.deployments.create`, `update`, `get`, `list`, `delete`, `lock`, `getLock`, `getState`, `updateState`, `unlock`) before it changes anything. When one is missing, it stops and shows the command that grants the role.

- **The deployer service account `platforma-im-deployer`.** Infrastructure Manager makes all resources with it.

- **The person who reads the administrator password**, who can be a different person from the person who ran `install.sh`. This person needs the permission `secretmanager.versions.access` (role `roles/secretmanager.secretAccessor`) in the project. The role `roles/secretmanager.admin` of the person who runs `install.sh` includes it. To give it on this one secret only:

  ```sh
  gcloud secrets add-iam-policy-binding <name>-cluster-admin-password --project=<PROJECT_ID> --member=user:<EMAIL> --role=roles/secretmanager.secretAccessor
  ```

The installer gives its deployer account (`platforma-im-deployer`) the Owner role. To limit it, replace Owner with these 13 roles after the install:

*Roles of the deployer account, in place of Owner*

```sh
PROJECT=<project>
SA=serviceAccount:platforma-im-deployer@$PROJECT.iam.gserviceaccount.com
for role in \
  roles/serviceusage.serviceUsageAdmin \
  roles/compute.networkAdmin \
  roles/container.admin \
  roles/file.editor \
  roles/storage.admin \
  roles/dns.admin \
  roles/certificatemanager.editor \
  roles/secretmanager.admin \
  roles/iam.serviceAccountAdmin \
  roles/iam.serviceAccountTokenCreator \
  roles/resourcemanager.projectIamAdmin \
  roles/cloudquotas.admin \
  roles/artifactregistry.admin
do
  gcloud projects add-iam-policy-binding "$PROJECT" \
    --member="$SA" --role="$role" --condition=None
done
gcloud projects remove-iam-policy-binding "$PROJECT" \
  --member="$SA" --role=roles/owner
```

- A DNS zone in another project: in that project, the deployer account needs `roles/dns.admin` and the person needs `roles/dns.reader`.
- A manual `helm uninstall` needs Owner or `roles/container.admin`.

The roles of the person, on the project. The teardown (see [Uninstall an installer installation](/maintain-uninstalling-cloud-installer/)) also needs:

- the two `container` roles;
- in its default mode, which keeps the data: from `roles/config.admin`, the permissions `config.deployments.lock`, `getLock`, `getState`, `updateState` and `unlock` on the deployment `<name>-infra`, and `compute.disks.setLabels`, in `roles/compute.storageAdmin`. `teardown.sh` checks them before it changes anything and stops with the command that grants the role. The mode that deletes all data does not check them first, and does not need the state permissions or `compute.disks.setLabels`;
- in the mode that deletes all data: `roles/secretmanager.admin`, to delete the secrets of the installation in Secret Manager;
- to delete the data that an earlier teardown kept: `roles/file.editor`, `roles/compute.storageAdmin`, `roles/compute.networkAdmin` and `roles/servicenetworking.networksAdmin`.

*Roles of the person who runs install.sh*

```sh
PROJECT=<project>
MEMBER=user:<email>     # or serviceAccount:<CI account>
for role in \
  roles/billing.viewer \
  roles/serviceusage.serviceUsageAdmin \
  roles/dns.reader \
  roles/cloudquotas.viewer \
  roles/iam.serviceAccountAdmin \
  roles/resourcemanager.projectIamAdmin \
  roles/config.admin \
  roles/secretmanager.admin \
  roles/storage.admin \
  roles/container.clusterViewer \
  roles/container.developer \
  roles/compute.storageAdmin
do
  gcloud projects add-iam-policy-binding "$PROJECT" \
    --member="$MEMBER" --role="$role" --condition=None
done


# actAs on the deployer service account (after the first run of install.sh creates it)
gcloud iam service-accounts add-iam-policy-binding \
  "platforma-im-deployer@$PROJECT.iam.gserviceaccount.com" \
  --member="$MEMBER" --role=roles/iam.serviceAccountUser --project="$PROJECT"
```

#### Variant: Terraform modules

Three Terraform roots apply the modules, one root for each step, and each root can go to a different person or CI identity. Each step gives the next one a hand-off file with names and addresses, without secrets. In a cluster that the company has already, the root `cloud` does not run: choose “Own cluster”.

#### Variant: 1. Root cloud

#### Variant: AWS

Rights in the AWS account, for apply and destroy. The resource ARNs are limited to the name of the installation `<NAME>`:

- **EC2 and VPC:** the network, the security groups, the launch templates of the node groups, the network interfaces of the EFS mount targets. The AWS provider reads each resource after each change, so each statement also has the read actions of its resources. The statement `Read` also covers an existing VPC.
- **EKS:** the cluster, its node groups and access entries.
- **IAM:** the roles and policies `<NAME>-*`, the OIDC provider of the cluster, `iam:PassRole` of the cluster, node and ECR template roles, the service-linked roles. `iam:PutRolePermissionsBoundary` is necessary only with a permissions boundary (`iam_permissions_boundary_arn`).
- **S3, EFS, Auto Scaling:** the primary storage (The bucket (Amazon S3 or Google Cloud Storage) or folder where Platforma keeps all results and uploaded files.) bucket, the workspace (The storage where the Backend and all jobs keep the working files of running jobs. The Backend and the jobs use it at the same time. In Kubernetes, it is a network file system; in Single Server mode, it is a folder on the server.) file system, the tags of the node groups.
- **ECR:** the caches of `registry_mirrors`, `<NAME>-software` and `<NAME>-backend`. The statements `ImageCache` and `ImageCacheRepositories` are for this option. It is on by default: drop them only when you turn off both caches. `ImageCache` has `ecr:CreateRepository` on all resources: AWS requires it to create a repository creation template.
- **GPU pool and data libraries (A folder or bucket with input data of the company. Users select files from it in the Desktop App. Platforma only reads it.):** they do not need more actions. A GPU node group uses the same EKS actions, and the access to a data library is a statement in a policy `<NAME>-*`.
- **At destroy:** to destroy the root `cluster` with the same identity, add the policy of step 2.

AWS limits a managed policy to 6,144 characters, so the default rights are two policies.

*Root cloud, policy 1 of 2: network, cluster, storage*

```json
{
  "Version": "2012-10-17",
  "Statement": [
    {
      "Sid": "Read",
      "Effect": "Allow",
      "Action": [
        "ec2:DescribeVpcs", "ec2:DescribeVpcAttribute", "ec2:DescribeSubnets",
        "ec2:DescribeInternetGateways", "ec2:DescribeAddresses", "ec2:DescribeAddressesAttribute",
        "ec2:DescribeNatGateways", "ec2:DescribeRouteTables", "ec2:DescribeVpcEndpoints",
        "ec2:DescribeSecurityGroups", "ec2:DescribeSecurityGroupRules",
        "ec2:DescribeLaunchTemplates", "ec2:DescribeLaunchTemplateVersions",
        "ec2:DescribeNetworkInterfaces", "ec2:DescribeNetworkAcls",
        "ec2:DescribeAvailabilityZones", "ec2:DescribeInstanceTypes", "ec2:DescribePrefixLists",
        "kms:DescribeKey", "kms:ListAliases"
      ],
      "Resource": "*"
    },
    {
      "Sid": "Network",
      "Effect": "Allow",
      "Action": [
        "ec2:CreateVpc", "ec2:ModifyVpcAttribute", "ec2:DeleteVpc", "ec2:CreateSubnet",
        "ec2:ModifySubnetAttribute", "ec2:DeleteSubnet", "ec2:CreateInternetGateway",
        "ec2:AttachInternetGateway", "ec2:DetachInternetGateway", "ec2:DeleteInternetGateway",
        "ec2:AllocateAddress", "ec2:AssociateAddress", "ec2:DisassociateAddress",
        "ec2:ModifyAddressAttribute", "ec2:ReleaseAddress",
        "ec2:CreateNatGateway", "ec2:DeleteNatGateway", "ec2:CreateRouteTable",
        "ec2:DeleteRouteTable", "ec2:CreateRoute", "ec2:ReplaceRoute", "ec2:DeleteRoute",
        "ec2:AssociateRouteTable", "ec2:DisassociateRouteTable",
        "ec2:ReplaceRouteTableAssociation", "ec2:CreateVpcEndpoint",
        "ec2:ModifyVpcEndpoint", "ec2:DeleteVpcEndpoints", "ec2:CreateSecurityGroup",
        "ec2:DeleteSecurityGroup", "ec2:AuthorizeSecurityGroupIngress",
        "ec2:AuthorizeSecurityGroupEgress", "ec2:RevokeSecurityGroupIngress",
        "ec2:RevokeSecurityGroupEgress", "ec2:ModifySecurityGroupRules",
        "ec2:UpdateSecurityGroupRuleDescriptionsIngress",
        "ec2:UpdateSecurityGroupRuleDescriptionsEgress", "ec2:CreateLaunchTemplate",
        "ec2:CreateLaunchTemplateVersion", "ec2:ModifyLaunchTemplate", "ec2:DeleteLaunchTemplate",
        "ec2:DeleteLaunchTemplateVersions", "ec2:RunInstances", "ec2:CreateTags", "ec2:DeleteTags",
        "ec2:CreateNetworkInterface", "ec2:DeleteNetworkInterface",
        "ec2:ModifyNetworkInterfaceAttribute"
      ],
      "Resource": "*"
    },
    {
      "Sid": "Cluster",
      "Effect": "Allow",
      "Action": [
        "eks:CreateCluster", "eks:UpdateClusterConfig", "eks:UpdateClusterVersion",
        "eks:DeleteCluster", "eks:TagResource", "eks:UntagResource", "eks:CreateAccessEntry",
        "eks:UpdateAccessEntry", "eks:DeleteAccessEntry", "eks:AssociateAccessPolicy",
        "eks:DisassociateAccessPolicy", "eks:CreateNodegroup", "eks:UpdateNodegroupConfig",
        "eks:UpdateNodegroupVersion", "eks:DeleteNodegroup"
      ],
      "Resource": [
        "arn:aws:eks:<REGION>:<ACCOUNT_ID>:cluster/<NAME>",
        "arn:aws:eks:<REGION>:<ACCOUNT_ID>:nodegroup/<NAME>/*",
        "arn:aws:eks:<REGION>:<ACCOUNT_ID>:access-entry/<NAME>/*"
      ]
    },
    {
      "Sid": "ClusterRead",
      "Effect": "Allow",
      "Action": [
        "eks:DescribeCluster", "eks:ListTagsForResource", "eks:DescribeAccessEntry",
        "eks:ListAccessEntries", "eks:ListAssociatedAccessPolicies", "eks:DescribeNodegroup",
        "eks:ListNodegroups"
      ],
      "Resource": "*"
    },
    {
      "Sid": "NodeGroupTags",
      "Effect": "Allow",
      "Action": [
        "autoscaling:CreateOrUpdateTags", "autoscaling:DeleteTags", "autoscaling:DescribeTags",
        "autoscaling:DescribeAutoScalingGroups"
      ],
      "Resource": "*"
    }
  ]
}
```

*Root cloud, policy 2 of 2: IAM, image cache*

```json
{
  "Version": "2012-10-17",
  "Statement": [
    {
      "Sid": "Roles",
      "Effect": "Allow",
      "Action": [
        "iam:CreateRole", "iam:GetRole", "iam:UpdateRole", "iam:UpdateAssumeRolePolicy",
        "iam:PutRolePermissionsBoundary", "iam:DeleteRole", "iam:TagRole", "iam:UntagRole",
        "iam:ListRoleTags", "iam:ListRolePolicies", "iam:ListAttachedRolePolicies",
        "iam:ListInstanceProfilesForRole", "iam:PutRolePolicy", "iam:GetRolePolicy",
        "iam:DeleteRolePolicy", "iam:AttachRolePolicy", "iam:DetachRolePolicy", "iam:CreatePolicy",
        "iam:GetPolicy", "iam:GetPolicyVersion", "iam:ListPolicyVersions",
        "iam:CreatePolicyVersion", "iam:DeletePolicyVersion", "iam:DeletePolicy", "iam:TagPolicy",
        "iam:UntagPolicy", "iam:ListPolicyTags"
      ],
      "Resource": [
        "arn:aws:iam::<ACCOUNT_ID>:role/<NAME>-*", "arn:aws:iam::<ACCOUNT_ID>:policy/<NAME>-*"
      ]
    },
    {
      "Sid": "OidcProvider",
      "Effect": "Allow",
      "Action": [
        "iam:CreateOpenIDConnectProvider", "iam:GetOpenIDConnectProvider",
        "iam:DeleteOpenIDConnectProvider", "iam:TagOpenIDConnectProvider",
        "iam:UntagOpenIDConnectProvider", "iam:UpdateOpenIDConnectProviderThumbprint",
        "iam:AddClientIDToOpenIDConnectProvider", "iam:RemoveClientIDFromOpenIDConnectProvider"
      ],
      "Resource": "arn:aws:iam::<ACCOUNT_ID>:oidc-provider/oidc.eks.<REGION>.amazonaws.com/id/*"
    },
    {
      "Sid": "PassRoles",
      "Effect": "Allow",
      "Action": ["iam:PassRole"],
      "Resource": [
        "arn:aws:iam::<ACCOUNT_ID>:role/<NAME>-cluster",
        "arn:aws:iam::<ACCOUNT_ID>:role/<NAME>-node",
        "arn:aws:iam::<ACCOUNT_ID>:role/<NAME>-ecr-template"
      ]
    },
    {
      "Sid": "ServiceLinkedRoles",
      "Effect": "Allow",
      "Action": ["iam:CreateServiceLinkedRole"],
      "Resource": "*",
      "Condition": {"StringEquals": {"iam:AWSServiceName": ["eks.amazonaws.com", "eks-nodegroup.amazonaws.com", "autoscaling.amazonaws.com", "elasticfilesystem.amazonaws.com"]}}
    },
    {
      "Sid": "NodeGroupServiceRole",
      "Effect": "Allow",
      "Action": ["iam:GetRole"],
      "Resource": "arn:aws:iam::<ACCOUNT_ID>:role/aws-service-role/eks-nodegroup.amazonaws.com/AWSServiceRoleForAmazonEKSNodegroup"
    },
    {
      "Sid": "PrimaryBucket",
      "Effect": "Allow",
      "Action": [
        "s3:CreateBucket", "s3:DeleteBucket", "s3:ListBucket", "s3:GetBucket*",
        "s3:GetLifecycleConfiguration", "s3:GetEncryptionConfiguration",
        "s3:GetAccelerateConfiguration", "s3:GetReplicationConfiguration", "s3:PutBucketTagging",
        "s3:PutBucketPolicy", "s3:DeleteBucketPolicy", "s3:PutBucketOwnershipControls",
        "s3:PutBucketPublicAccessBlock", "s3:PutEncryptionConfiguration",
        "s3:PutLifecycleConfiguration", "s3:TagResource", "s3:UntagResource",
        "s3:ListTagsForResource"
      ],
      "Resource": "arn:aws:s3:::<NAME>-primary-<ACCOUNT_ID>"
    },
    {
      "Sid": "Workspace",
      "Effect": "Allow",
      "Action": [
        "elasticfilesystem:CreateFileSystem", "elasticfilesystem:DescribeFileSystems",
        "elasticfilesystem:UpdateFileSystem", "elasticfilesystem:DeleteFileSystem",
        "elasticfilesystem:DescribeLifecycleConfiguration", "elasticfilesystem:CreateMountTarget",
        "elasticfilesystem:DescribeMountTargets", "elasticfilesystem:DeleteMountTarget",
        "elasticfilesystem:DescribeMountTargetSecurityGroups",
        "elasticfilesystem:ModifyMountTargetSecurityGroups", "elasticfilesystem:TagResource",
        "elasticfilesystem:UntagResource", "elasticfilesystem:ListTagsForResource"
      ],
      "Resource": "*"
    },
    {
      "Sid": "ImageCache",
      "Effect": "Allow",
      "Action": [
        "ecr:CreatePullThroughCacheRule", "ecr:DescribePullThroughCacheRules",
        "ecr:UpdatePullThroughCacheRule", "ecr:DeletePullThroughCacheRule",
        "ecr:CreateRepositoryCreationTemplate", "ecr:DescribeRepositoryCreationTemplates",
        "ecr:UpdateRepositoryCreationTemplate", "ecr:DeleteRepositoryCreationTemplate",
        "ecr:CreateRepository"
      ],
      "Resource": "*"
    },
    {
      "Sid": "ImageCacheRepositories",
      "Effect": "Allow",
      "Action": ["ecr:DescribeRepositories", "ecr:DeleteRepository"],
      "Resource": [
        "arn:aws:ecr:<REGION>:<ACCOUNT_ID>:repository/<NAME>-software/*",
        "arn:aws:ecr:<REGION>:<ACCOUNT_ID>:repository/<NAME>-backend/*"
      ]
    }
  ]
}
```

Add the statements of the options that you set:

- control plane logs (`kubernetes.log_types`);
- a DNS zone that the module makes (`dns.create_zone_name`: `NewDnsZone`) or an existing one (`dns.zone_id`: `ExistingDnsZone`, `ListDnsZones`);
- a certificate that the module makes (`tls.mode = "managed"`, the default: `Certificate`, `CertificateRecords`, with the statements of its zone);
- a kept database volume (`existing_storages.database_volume`: `KeptDatabaseVolume`).

*Root cloud: options*

```json
{
  "Version": "2012-10-17",
  "Statement": [
    {
      "Sid": "ControlPlaneLogs",
      "Effect": "Allow",
      "Action": [
        "logs:CreateLogGroup", "logs:PutRetentionPolicy", "logs:DeleteRetentionPolicy",
        "logs:DeleteLogGroup", "logs:TagResource", "logs:UntagResource",
        "logs:ListTagsForResource"
      ],
      "Resource": [
        "arn:aws:logs:<REGION>:<ACCOUNT_ID>:log-group:/aws/eks/<NAME>/cluster",
        "arn:aws:logs:<REGION>:<ACCOUNT_ID>:log-group:/aws/eks/<NAME>/cluster:*"
      ]
    },
    {
      "Sid": "ReadLogGroups",
      "Effect": "Allow",
      "Action": ["logs:DescribeLogGroups"],
      "Resource": "*"
    },
    {
      "Sid": "NewDnsZone",
      "Effect": "Allow",
      "Action": [
        "route53:CreateHostedZone", "route53:GetHostedZone", "route53:UpdateHostedZoneComment",
        "route53:DeleteHostedZone", "route53:ChangeTagsForResource", "route53:ListTagsForResource",
        "route53:ChangeResourceRecordSets", "route53:ListResourceRecordSets",
        "route53:ListHostedZones", "route53:GetChange"
      ],
      "Resource": "*"
    },
    {
      "Sid": "ExistingDnsZone",
      "Effect": "Allow",
      "Action": [
        "route53:GetHostedZone", "route53:ListTagsForResource", "route53:ListResourceRecordSets"
      ],
      "Resource": "arn:aws:route53:::hostedzone/<ZONE_ID>"
    },
    {
      "Sid": "ListDnsZones",
      "Effect": "Allow",
      "Action": ["route53:ListHostedZones", "route53:GetChange"],
      "Resource": "*"
    },
    {
      "Sid": "CertificateRecords",
      "Effect": "Allow",
      "Action": ["route53:ChangeResourceRecordSets"],
      "Resource": "arn:aws:route53:::hostedzone/<ZONE_ID>"
    },
    {
      "Sid": "Certificate",
      "Effect": "Allow",
      "Action": [
        "acm:RequestCertificate", "acm:DescribeCertificate", "acm:ListTagsForCertificate",
        "acm:AddTagsToCertificate", "acm:RemoveTagsFromCertificate", "acm:DeleteCertificate"
      ],
      "Resource": "*"
    },
    {
      "Sid": "KeptDatabaseVolume",
      "Effect": "Allow",
      "Action": ["ec2:DescribeVolumes"],
      "Resource": "*"
    }
  ]
}
```

The modules encrypt with the AWS managed keys. With a customer managed key, also give `kms:CreateGrant` on that key, and let the key policy allow you and the AWS service.

#### Variant: Google Cloud

Predefined roles on the project (the project owner has all of them). The project must have a billing account. With the default settings, the module enables the APIs that it uses, grants the node service account its project role, and makes the caches of `registry_mirrors`: drop `roles/serviceusage.serviceUsageAdmin`, `roles/resourcemanager.projectIamAdmin` or `roles/artifactregistry.admin` only when you turn off that setting. Add `roles/certificatemanager.editor` when the module makes the certificate, and `roles/dns.admin` in the project of the zone when it writes DNS records. For a data library bucket in another project, you also need the right to change the IAM policy of that bucket. These roles do not include the cluster admin: to apply the root `cluster` with the same identity, add its roles. These roles are enough for the apply and for `terraform destroy`. The destroy keeps the disk of the database; only to delete all data, also this disk, add `roles/compute.storageAdmin`.

With `enable_apis = false`, enable these APIs (`<api>.googleapis.com`) before the apply: `compute`, `container`, `file`, `storage`, `iam`, `iamcredentials` and `artifactregistry`; also `certificatemanager` with `tls.mode = "managed"` (the default), and `dns` with `dns.managed_zone`. The APIs stay on after a destroy.

The node service account needs the role `roles/container.defaultNodeServiceAccount` on the project for the node logs and metrics. With `node_service_account.grant_project_roles = false`, or with an existing node service account, the module does not grant it: a project admin grants it by hand.

*Root cloud: roles*

```sh
PROJECT=<project>
MEMBER=user:<email>     # or serviceAccount:<CI account>
for role in \
  roles/compute.networkAdmin \
  roles/compute.securityAdmin \
  roles/container.clusterAdmin \
  roles/iam.serviceAccountUser \
  roles/iam.serviceAccountAdmin \
  roles/storage.admin \
  roles/file.editor \
  roles/serviceusage.serviceUsageAdmin \
  roles/resourcemanager.projectIamAdmin \
  roles/artifactregistry.admin
do
  gcloud projects add-iam-policy-binding "$PROJECT" \
    --member="$MEMBER" --role="$role" --condition=None
done
```

#### Variant: Own cluster

The root `cloud` does not run. The cloud team makes the identity of the Backend and its rights on the storage: see [Rights of the Backend](/plan-permissions-runtime/#rights-of-the-backend).

#### Variant: 2. Root cluster

#### Variant: AWS

- **Cluster admin in Kubernetes:** an EKS access entry with `AmazonEKSClusterAdminPolicy`. The identity that made the cluster has it; name another identity as a cluster admin in the root `cloud`.
- **At destroy only:** a cleanup script removes the target groups and security groups that the load balancer controller leaves, and waits for the DNS records to go.

*Root cluster: destroy*

```json
{
  "Version": "2012-10-17",
  "Statement": [
    {
      "Sid": "FindLeftovers",
      "Effect": "Allow",
      "Action": ["tag:GetResources", "ec2:DescribeSecurityGroups"],
      "Resource": "*"
    },
    {
      "Sid": "DeleteLeftovers",
      "Effect": "Allow",
      "Action": ["elasticloadbalancing:DeleteTargetGroup", "ec2:DeleteSecurityGroup"],
      "Resource": "*",
      "Condition": {"StringEquals": {"aws:ResourceTag/elbv2.k8s.aws/cluster": "<NAME>"}}
    },
    {
      "Sid": "WaitForDnsRecords",
      "Effect": "Allow",
      "Action": ["route53:ListResourceRecordSets"],
      "Resource": "arn:aws:route53:::hostedzone/<ZONE_ID>"
    }
  ]
}
```

Without a DNS zone, drop the statement `WaitForDnsRecords`.

#### Variant: Google Cloud

- **Apply:** only `roles/container.admin` (cluster admin in Kubernetes), or `roles/container.clusterViewer` and a Kubernetes binding to the ClusterRole `cluster-admin`.
- **At destroy only:** also `roles/compute.loadBalancerAdmin` (network endpoint groups) and `roles/compute.securityAdmin` (firewall rules): a cleanup removes the objects that the load balancer leaves. The roles of the root `cloud` (`roles/compute.networkAdmin`) give the rights to find these objects; for the delete, add the two roles also to an identity that has the roles of the root `cloud`.

*Root cluster: roles*

```sh
PROJECT=<project>
MEMBER=user:<email>     # or serviceAccount:<CI account>
for role in roles/container.admin roles/compute.loadBalancerAdmin roles/compute.securityAdmin; do
  gcloud projects add-iam-policy-binding "$PROJECT" \
    --member="$MEMBER" --role="$role" --condition=None
done
```

#### Variant: Own cluster

The root `cluster` applies only `platforma-tf-services-cluster`, with a kubeconfig that has cluster admin rights. It installs Kueue (A Kubernetes add-on that holds jobs in a queue until the cluster has free CPU, memory and GPU for them.) and AppWrapper (A Kubernetes add-on that wraps the pods of one job into a single unit, so that Kueue admits and starts them together.), creates the namespace, the job (One run of a tool on data. The Backend starts jobs on the server where it runs, or in a Kubernetes cluster.) queues and the roles of the tab “Helm chart”, and adds the rights on the custom resources to the role `admin`.

*Root cluster: cluster admin*

```sh
kubectl create clusterrolebinding platforma-installer \
  --clusterrole=cluster-admin --user=<user>     # or --group=<group>
```

#### Variant: 3. Root services

The role `admin` in the namespace of Platforma. The root `cluster` has already added to `admin` the rights on the custom resources that the chart needs (see the tab “Helm chart”), so nothing else is necessary. The Secrets with the keys and the passwords exist before the apply: see [Secrets](/infrastructure-contract-identity/#secrets).

*Root services: admin in the namespace*

```sh
kubectl create rolebinding platforma-installer --namespace=<namespace> \
  --clusterrole=admin --user=<user>     # or --group=<group>
```

On EKS, give the IAM identity an access entry with a Kubernetes group, and bind that group. On GKE, give the identity `roles/container.clusterViewer` on the project, so that it can reach the cluster, and bind its email (`--user=<email>`, also for a service account). Outside the namespace, Kubernetes refuses all actions of this identity.

*Root services: reach the GKE cluster*

```sh
MEMBER=user:<email>     # or serviceAccount:<CI account>
gcloud projects add-iam-policy-binding <project> \
  --member="$MEMBER" --role=roles/container.clusterViewer --condition=None
```

#### Variant: Helm chart

Three roles share the work:

- **The cluster admin** prepares what the [Kubernetes contract](/infrastructure-contract/) asks for (Kueue, AppWrapper, the job queues, the entry point (The way in to the Backend from outside the cluster, a load balancer or an Ingress with a DNS name. It usually ends TLS and sends the traffic to the Backend pod.), the storage classes), then applies the roles of this tab once for the cluster.
- **The namespace admin** installs the chart: the role `admin` in a namespace that exists. The role `edit` is not enough, because the chart makes a Role and a RoleBinding.
- **The cloud team** makes the identity of the Backend: see [Rights of the Backend](/plan-permissions-runtime/#rights-of-the-backend). The Secrets exist before the install: see [Secrets](/infrastructure-contract-identity/#secrets).

The role `admin` does not have rights on custom resources, and Kubernetes does not let a user give a right that they do not have. The first ClusterRole adds these rights to `admin` (aggregation), so a binding to `admin` gives them in one namespace only. Put in it the route kinds of the Gateway implementation:

| Implementation                           | Route kinds (API group)                                                                                          |
| ---------------------------------------- | ---------------------------------------------------------------------------------------------------------------- |
| AWS Load Balancer Controller             | `httproutes` (`gateway.networking.k8s.io`), `targetgroupconfigurations` (`gateway.k8s.aws`)                      |
| GKE Gateway                              | `httproutes` (`gateway.networking.k8s.io`), `healthcheckpolicies` and `gcpbackendpolicies` (`networking.gke.io`) |
| Azure Application Gateway for Containers | `grpcroutes` (`gateway.networking.k8s.io`), `healthcheckpolicies` (`alb.networking.azure.io`)                    |
| Any other Gateway                        | `httproutes` (`gateway.networking.k8s.io`)                                                                       |

Without this ClusterRole, the install with `admin` stops with the error `LocalQueue … is forbidden`. The chart makes the LocalQueues, the routes and the policies of the Gateway. The Role of the Backend in the chart also gives rights on AppWrappers and on Kueue Workloads, and the installer can give only the rights that it has. The Terraform module `platforma-tf-services-cluster` makes the same ClusterRole.

The second ClusterRole is optional: it lets the Backend read its two ClusterQueues, so the Desktop App shows the load of the queues. Without it, turn off the queue statistics (see [Jobs and resources](/configuration-jobs-and-resources/#queues)).

*Cluster admin: rights on the custom resources*

```yaml
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRole
metadata:
  name: platforma-namespace-admin
  labels:
    rbac.authorization.k8s.io/aggregate-to-admin: "true"
rules:
  - apiGroups: ["kueue.x-k8s.io"]
    resources: ["localqueues"]
    verbs: ["get", "list", "watch", "create", "update", "patch", "delete", "deletecollection"]
  - apiGroups: ["workload.codeflare.dev"]
    resources: ["appwrappers"]
    verbs: ["get", "list", "watch", "create", "update", "patch", "delete", "deletecollection"]
  - apiGroups: ["gateway.networking.k8s.io"]   # the route kinds of the Gateway implementation
    resources: ["httproutes"]
    verbs: ["get", "list", "watch", "create", "update", "patch", "delete", "deletecollection"]
  - apiGroups: ["kueue.x-k8s.io"]
    resources: ["workloads"]
    verbs: ["get", "list", "watch"]
---
# Optional: the Backend reads its two ClusterQueues (queue statistics)
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRole
metadata:
  name: platforma-queue-reader
rules:
  - apiGroups: ["kueue.x-k8s.io"]
    resources: ["clusterqueues"]
    resourceNames: ["<ui ClusterQueue>", "<batch ClusterQueue>"]
    verbs: ["get", "list", "watch"]
---
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRoleBinding
metadata:
  name: platforma-queue-reader-<namespace>
roleRef:
  apiGroup: rbac.authorization.k8s.io
  kind: ClusterRole
  name: platforma-queue-reader
subjects:
  - kind: ServiceAccount
    name: <backend service account>
    namespace: <namespace>
```

*Namespace admin: admin in the namespace*

```sh
kubectl create rolebinding platforma-installer --namespace=<namespace> \
  --clusterrole=admin --user=<user>     # or --group=<group>
```

At the install, the chart checks that each Secret exists and has its key. For this check, it reads the Namespace object of its own namespace. The role `admin` in the namespace is enough: it can read the Secrets, and it can read the Namespace object of that namespace.

A custom Role in place of `admin` needs the rights on all objects of the chart, and each right of the Role of the Backend. It also needs one of these two settings, or the install stops with the error `namespaces "<namespace>" is forbidden … cannot get resource "namespaces"`:

- add `get` on `namespaces` to the Role. A Role in the namespace gives this right on the Namespace object of the same name only:

  *Custom Role: rule for the Secret check*

  ```yaml
  - apiGroups: [""]
    resources: ["namespaces"]
    verbs: ["get"]
  ```

- or set `validation.checkSecrets: false` in the values. The chart then does not check the Secrets, and a missing Secret shows only when the Backend pod starts.

#### Variant: Single Server

Single Server mode (The mode in which the Backend and all its jobs run on one Linux machine, the server, with no Kubernetes cluster.) does not need rights in a cloud account or in a cluster, only one system user on the server: see [Single Server mode](/plan-permissions/#single-server-mode).

## Single Server mode

The rights of one system user on the server are the limit for the Backend and its jobs. The Backend runs as the user that starts it, and the jobs run as the same user (see [Single Server mode](/security-overview/#single-server-mode) in Security). Use a dedicated user that is not `root`. The user needs:

- **Read and write** on the main folder of the Backend (by default `.platforma/backend` in its home folder; see [Backend options](/reference-backend-options/)) and on a folder used as primary storage.
- **Read** on each folder that is a data library.
- **Access to the Docker daemon**, only to run the jobs in Docker. Each container runs with the UID and the GID of the user and sees only the working folder of its job.

For a bucket as primary storage or data library, the credentials need the same rights as in a cluster: see [Storage rights of the Backend](/plan-permissions-runtime/#storage). For ports, open files and the operating system, see [Requirements of Single Server mode](/plan-single-server-requirements/).

> **Caution:**
>
> Access to the Docker daemon gives root rights on the server: a user who can start containers can mount any folder into a container. Give it only on a server that runs only Platforma, and protect the user as you protect `root`.

## Cloud quotas

The vCPU quota of the region must have room for the nodes at their maximum size, and GPU machines have a separate quota. Ask the cloud team to check both before the installation: see [How to limit the cost](/plan-sizing-and-cost/#how-to-limit-the-cost).

## Who usually holds which rights

| Part of the installation                                                       | Usual holder                                           |
| ------------------------------------------------------------------------------ | ------------------------------------------------------ |
| Root `cloud`: network, cluster, storage, identities                            | The cloud team                                         |
| Root `cluster`: Kueue, AppWrapper, queues, entry point, storage classes, roles | The cluster admin or the platform team                 |
| Root `services` or the Helm chart: admin in one namespace                      | The person who installs Platforma                      |
| Keys and passwords in Secrets                                                  | The person who holds the keys, often the security team |
| Data library buckets in other accounts or projects                             | The owner of each bucket                               |
| Single Server mode: a system user, its files, Docker                           | The administrator of the server                        |

In a small company, one person can hold all of these rights.

## Next

- [Permissions at run time](/plan-permissions-runtime/)
- [Prerequisites checklist](/plan-prerequisites-checklist/)
- [Identity, Secrets and outbound access](/infrastructure-contract-identity/)
- [Install in cloud with Terraform](/install-cloud-terraform/)
- [Install in custom infrastructure](/install-custom-infrastructure/)
- [Install in Single Server mode](/install-single-server/)

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