# Terraform modules

Look up an input or an output of a Terraform module of Platforma.

Six Terraform modules (The Terraform code that MiLaboratories provides to install Platforma. The cloud-specific Terraform modules make the cluster and its cloud parts in AWS or Google Cloud; the cloud-agnostic Terraform modules install Platforma into the cluster.) install Platforma. 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.) make the cluster and its cloud parts in AWS or Google Cloud: one pair for each cloud. The cloud-agnostic Terraform modules (The Terraform modules platforma-tf-services-cluster and platforma-tf-services. They do not depend on the infrastructure and install Platforma into any cluster that meets the Kubernetes contract, in a cloud or in the company's own infrastructure.) install Platforma into any Kubernetes (A system that runs programs on a group of machines (a cluster). Platforma can run in a Kubernetes cluster.) cluster that meets the [Kubernetes contract](/infrastructure-contract/). For how the modules split the work and which root applies each of them, see [How the modules split the work](/infrastructure-contract-modules/). For the steps, see [Install in cloud with Terraform](/install-cloud-terraform/) and [Install in custom infrastructure](/install-custom-infrastructure/).

- [`platforma-tf-cloud-base` for AWS](#platforma-tf-cloud-base-for-aws): the VPC, the EKS cluster, the node pools, the storage, the identities and 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.)
- [`platforma-tf-cloud-cluster` for AWS](#platforma-tf-cloud-cluster-for-aws): the cloud parts inside the EKS cluster, and `cluster_config`
- [`platforma-tf-cloud-base` for Google Cloud](#platforma-tf-cloud-base-for-google-cloud): the VPC, the GKE cluster, the node pools, the storage, the identities and the entry point
- [`platforma-tf-cloud-cluster` for Google Cloud](#platforma-tf-cloud-cluster-for-google-cloud): the cloud parts inside the GKE cluster, and `cluster_config`
- [`platforma-tf-services-cluster`](#platforma-tf-services-cluster): the namespaces, Kueue (A Kubernetes add-on that holds jobs in a queue until the cluster has free CPU, memory and GPU for them.), AppWrapper (A Kubernetes add-on that wraps the pods of one job into a single unit, so that Kueue admits and starts them together.) and 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 `infrastructure`
- [`platforma-tf-services`](#platforma-tf-services): the Backend (The server program of Platforma. It keeps the projects, runs the Blocks and starts jobs.) in one namespace

The modules are in the public repository [platforma-install](https://github.com/milaboratory/platforma-install), in the folders that the line “Source” of each module gives, with one tag for each release. Use a module as a git source at a release tag, for example `git::https://github.com/milaboratory/platforma-install.git//terraform/aws/platforma-tf-cloud-base?ref=<release tag>`, or clone the repository at the tag: see [Where the modules are](/install-cloud-terraform/#where-the-modules-are).

Each object input is strict: a key that the module does not know (a typo), a missing required key or a value of a wrong type stops the plan, before the module changes anything. A key that is `null` or not set gets its default. The tables show the inputs down to two levels of keys. The row of a deeper object lists its keys and their defaults; the `inputs/variables.tf` file of each module has the full types and checks.

## `platforma-tf-cloud-base` for AWS

Source: `terraform/aws/platforma-tf-cloud-base`. Root: `cloud`.

Makes the cloud resources of one installation in one AWS account:

- the VPC;
- the EKS cluster with its node groups;
- the S3 bucket of the primary storage (The bucket (Amazon S3 or Google Cloud Storage) or folder where Platforma keeps all results and uploaded files.);
- the EFS file system of 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.);
- the IAM roles of the Backend and of the jobs;
- the security group;
- the certificate and the DNS zone of the entry point;
- the ECR caches of the images.

For the node pools and the storage, see [Jobs](/infrastructure-contract-jobs/) and [Storage](/infrastructure-contract-storage/).

### Inputs

| Input                                             | Type            | Default                                                                                                                                                                                                                       | Meaning                                                                                                                                                                                                                                                                                                                                          |
| ------------------------------------------------- | --------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| **`name`**                                        | string          | required                                                                                                                                                                                                                      | The name of the installation: the name of the EKS cluster and the start of the names of most cloud resources. 1 to 18 lowercase letters, digits and `-`; it starts with a letter and ends with a letter or a digit.                                                                                                                              |
| **`tags`**                                        | map of strings  | `{}`                                                                                                                                                                                                                          | Tags to put on all cloud resources that the module creates.                                                                                                                                                                                                                                                                                      |
| **`run_as`**                                      | object          | `{}`                                                                                                                                                                                                                          | User and group of the Backend pod and of all job pods.                                                                                                                                                                                                                                                                                           |
| `run_as.user`                                     | number          | `1010`                                                                                                                                                                                                                        | The user ID. It cannot be 0 (root).                                                                                                                                                                                                                                                                                                              |
| `run_as.group`                                    | number          | `1010`                                                                                                                                                                                                                        | The group ID. It cannot be 0 (root).                                                                                                                                                                                                                                                                                                             |
| **`iam_permissions_boundary_arn`**                | string          | `null`                                                                                                                                                                                                                        | ARN of an IAM policy. The module uses it as the permissions boundary of all IAM roles that it creates.                                                                                                                                                                                                                                           |
| **`namespaces`**                                  | list of strings | `["platforma"]`                                                                                                                                                                                                               | Namespaces of the Platforma instances.                                                                                                                                                                                                                                                                                                           |
| **`service_account_names`**                       | object          | `{}`                                                                                                                                                                                                                          | Names of the Kubernetes ServiceAccounts of the Backend and of the jobs.                                                                                                                                                                                                                                                                          |
| `service_account_names.backend`                   | string          | `"platforma-backend"`                                                                                                                                                                                                         | The ServiceAccount of the Backend.                                                                                                                                                                                                                                                                                                               |
| `service_account_names.jobs`                      | string          | `"platforma-jobs"`                                                                                                                                                                                                            | The ServiceAccount of the jobs.                                                                                                                                                                                                                                                                                                                  |
| **`network`**                                     | object          | `{}`                                                                                                                                                                                                                          | The VPC of the installation.                                                                                                                                                                                                                                                                                                                     |
| `network.vpc_cidr`                                | string          | `null`                                                                                                                                                                                                                        | 0/16).                                                                                                                                                                                                                                                                                                                                           |
| `network.az_count`                                | number          | `null`                                                                                                                                                                                                                        | The number of availability zones, 2 to 4 (default 2).                                                                                                                                                                                                                                                                                            |
| `network.single_nat_gateway`                      | bool            | `null`                                                                                                                                                                                                                        | `true` (default) makes one NAT gateway for all zones.                                                                                                                                                                                                                                                                                            |
| `network.existing_vpc`                            | object          | `null`                                                                                                                                                                                                                        | A VPC that exists. When it is set, the module does not make a VPC, subnets, routes, NAT gateways or an S3 endpoint, and `vpc_cidr`, `az_count` and `single_nat_gateway` must not be set.                                                                                                                                                         |
| `network.existing_vpc.id`                         | string          | required                                                                                                                                                                                                                      | The ID of the VPC.                                                                                                                                                                                                                                                                                                                               |
| `network.existing_vpc.private_subnet_ids`         | list of strings | required                                                                                                                                                                                                                      | One private subnet in each zone of the cluster, 2 or more zones. The subnets need outbound access to the internet, for example through NAT or a proxy.                                                                                                                                                                                           |
| `network.existing_vpc.public_subnet_ids`          | list of strings | `[]`                                                                                                                                                                                                                          | One public subnet in each zone of `private_subnet_ids`, for the external load balancer. Empty with `gateway.scheme` = `internal`.                                                                                                                                                                                                                |
| **`kubernetes`**                                  | object          | `{}`                                                                                                                                                                                                                          | Settings of the EKS cluster and of its control plane.                                                                                                                                                                                                                                                                                            |
| `kubernetes.version`                              | string          | `"1.35"`                                                                                                                                                                                                                      | The Kubernetes version. The Backend needs 1.35 or later.                                                                                                                                                                                                                                                                                         |
| `kubernetes.api_allowed_cidrs`                    | list of strings | `null`                                                                                                                                                                                                                        | Required: there is no default. The networks that can reach the public endpoint of the Kubernetes API: the networks of the computers that run Terraform and `kubectl`. `["0.0.0.0/0"]` opens the API to the whole internet.                                                                                                                       |
| `kubernetes.admin_principal_arns`                 | list of strings | `[]`                                                                                                                                                                                                                          | More IAM principals with cluster admin rights.                                                                                                                                                                                                                                                                                                   |
| `kubernetes.log_types`                            | list of strings | `[]`                                                                                                                                                                                                                          | The control plane log types. Empty means that the module does not make a CloudWatch log group.                                                                                                                                                                                                                                                   |
| `kubernetes.log_retention_days`                   | number          | `30`                                                                                                                                                                                                                          | How long CloudWatch keeps the control plane logs.                                                                                                                                                                                                                                                                                                |
| **`node_pools`**                                  | object          | `{}`                                                                                                                                                                                                                          | The node pools. Each pool is one or more EKS managed node groups.                                                                                                                                                                                                                                                                                |
| `node_pools.system`                               | object          | `{}`                                                                                                                                                                                                                          | The nodes of the cluster controllers, without a label or a taint. This pool is not part of the contract.                                                                                                                                                                                                                                         |
| `node_pools.system.instance_type`                 | string          | `"m7i.large"`                                                                                                                                                                                                                 | The EC2 instance type.                                                                                                                                                                                                                                                                                                                           |
| `node_pools.system.min_size`                      | number          | `2`                                                                                                                                                                                                                           | The minimum number of nodes.                                                                                                                                                                                                                                                                                                                     |
| `node_pools.system.max_size`                      | number          | `3`                                                                                                                                                                                                                           | The maximum number of nodes.                                                                                                                                                                                                                                                                                                                     |
| `node_pools.system.desired_size`                  | number          | `2`                                                                                                                                                                                                                           | The number of nodes at the start.                                                                                                                                                                                                                                                                                                                |
| `node_pools.system.boot_disk_size_gib`            | number          | `50`                                                                                                                                                                                                                          | The size of the boot disk of each node, in GiB.                                                                                                                                                                                                                                                                                                  |
| `node_pools.backend`                              | object          | `{}`                                                                                                                                                                                                                          | One node for the Backend pod. The pod needs at least 7 CPUs (The compute units of a node or of the server, as Kubernetes and the operating system count them. A job asks for a number of CPUs. The cloud quotas call them vCPUs.) and 24 GiB allocatable.                                                                                        |
| `node_pools.backend.zone`                         | string          | `null`                                                                                                                                                                                                                        | The availability zone of the Backend node group, where the database volume is. `null` means the first zone of the VPC. For a database volume that exists already, give its zone.                                                                                                                                                                 |
| `node_pools.backend.instance_type`                | string          | `"m7i.2xlarge"`                                                                                                                                                                                                               | The EC2 instance type.                                                                                                                                                                                                                                                                                                                           |
| `node_pools.backend.min_size`                     | number          | `1`                                                                                                                                                                                                                           | The minimum number of nodes.                                                                                                                                                                                                                                                                                                                     |
| `node_pools.backend.max_size`                     | number          | `1`                                                                                                                                                                                                                           | The maximum number of nodes.                                                                                                                                                                                                                                                                                                                     |
| `node_pools.backend.desired_size`                 | number          | `1`                                                                                                                                                                                                                           | The number of nodes at the start.                                                                                                                                                                                                                                                                                                                |
| `node_pools.backend.boot_disk_size_gib`           | number          | `100`                                                                                                                                                                                                                         | The size of the boot disk of each node, in GiB.                                                                                                                                                                                                                                                                                                  |
| `node_pools.ui`                                   | object          | `{}`                                                                                                                                                                                                                          | The job pool of the UI jobs. It is necessary.                                                                                                                                                                                                                                                                                                    |
| `node_pools.ui.node_groups`                       | list of objects | `[{ name = "ui-2c-8g", instance_type = "m7i.large", max_size = 4 }, { name = "ui-4c-16g", instance_type = "m7i.xlarge", max_size = 4 } ]`                                                                                     | The node groups of the pool, of 2 or more instance types. `min_size` = 0 lets a group scale from zero. Keys: `name`, `instance_type`, `min_size` = `0`, `max_size`, `boot_disk_size_gib` = `100`, `allocatable`.                                                                                                                                 |
| `node_pools.ui.quota`                             | object          | `null`                                                                                                                                                                                                                        | The quota of the queue of the pool. `null` means `max_size` × allocatable of the node groups. Keys: `cpu`, `memory_gib`.                                                                                                                                                                                                                         |
| `node_pools.batch`                                | object          | `{}`                                                                                                                                                                                                                          | The job pool of the batch jobs. It is necessary.                                                                                                                                                                                                                                                                                                 |
| `node_pools.batch.node_groups`                    | list of objects | `[{ name = "batch-4c-16g", instance_type = "m7i.xlarge", max_size = 8 }, { name = "batch-16c-64g", instance_type = "m7i.4xlarge", max_size = 4 }, { name = "batch-32c-256g", instance_type = "r7i.8xlarge", max_size = 8 } ]` | The node groups of the pool, of 2 or more instance types. `min_size` = 0 lets a group scale from zero. Keys: `name`, `instance_type`, `min_size` = `0`, `max_size`, `boot_disk_size_gib` = `200`, `allocatable`.                                                                                                                                 |
| `node_pools.batch.quota`                          | object          | `null`                                                                                                                                                                                                                        | The quota of the queue of the pool. `null` means `max_size` × allocatable of the node groups. Keys: `cpu`, `memory_gib`.                                                                                                                                                                                                                         |
| `node_pools.gpu`                                  | object          | `{}`                                                                                                                                                                                                                          | The job pool of the GPU jobs. It is optional.                                                                                                                                                                                                                                                                                                    |
| `node_pools.gpu.node_groups`                      | list of objects | `[]`                                                                                                                                                                                                                          | The GPU node groups. Empty means that there is no GPU pool. Each group has `gpu` = `{ type, gpus_per_node, gpu_memory_gib }`. Keys: `name`, `instance_type`, `min_size` = `0`, `max_size`, `boot_disk_size_gib` = `200`, `gpu`, `allocatable`.                                                                                                   |
| `node_pools.gpu.quota`                            | object          | `null`                                                                                                                                                                                                                        | The quota of the queue of the pool. `null` means `max_size` × allocatable of the node groups. Keys: `cpu`, `memory_gib`, `gpus`.                                                                                                                                                                                                                 |
| **`allocatable_reserve`**                         | object          | `{}`                                                                                                                                                                                                                          | What the DaemonSets of the cluster use on each job node. The module subtracts it from the allocatable of the node when it calculates what one job can use.                                                                                                                                                                                       |
| `allocatable_reserve.cpu`                         | number          | `0.7`                                                                                                                                                                                                                         | The CPUs of the DaemonSets.                                                                                                                                                                                                                                                                                                                      |
| `allocatable_reserve.memory_gib`                  | number          | `1`                                                                                                                                                                                                                           | The memory of the DaemonSets, in GiB.                                                                                                                                                                                                                                                                                                            |
| **`provisioning_request`**                        | object          | `{ cpu = "best-effort-atomic-scale-up.autoscaling.x-k8s.io", gpu = "best-effort-atomic-scale-up.autoscaling.x-k8s.io" }`                                                                                                      | The ProvisioningRequest classes of the CPU jobs and of the GPU jobs. A ProvisioningRequest asks the cluster autoscaler for all nodes of one job before the job starts.                                                                                                                                                                           |
| `provisioning_request.cpu`                        | string          | `null`                                                                                                                                                                                                                        | The class of the CPU jobs. `null` turns it off, and Kueue admits these jobs by quota only.                                                                                                                                                                                                                                                       |
| `provisioning_request.gpu`                        | string          | `null`                                                                                                                                                                                                                        | The class of the GPU jobs. `null` turns it off. Without a GPU node group, it is always `null`.                                                                                                                                                                                                                                                   |
| **`job_nofile_limit`**                            | number          | `1048576`                                                                                                                                                                                                                     | Open files limit (soft and hard) of all containers on the nodes of the cluster.                                                                                                                                                                                                                                                                  |
| **`existing_storages`**                           | object          | `{}`                                                                                                                                                                                                                          | Kept data of an earlier installation. A key that is set makes the module use that resource, not make a new one.                                                                                                                                                                                                                                  |
| `existing_storages.bucket`                        | string          | `null`                                                                                                                                                                                                                        | The name of a kept S3 bucket of the primary storage, in the region of the provider.                                                                                                                                                                                                                                                              |
| `existing_storages.workspace`                     | object          | `null`                                                                                                                                                                                                                        | A kept EFS file system of the workspace. The module makes its mount targets.                                                                                                                                                                                                                                                                     |
| `existing_storages.workspace.file_system_id`      | string          | required                                                                                                                                                                                                                      | The ID of the EFS file system.                                                                                                                                                                                                                                                                                                                   |
| `existing_storages.database_volume`               | string          | `null`                                                                                                                                                                                                                        | The ID of a kept EBS volume of the database. It must be in the zone of `node_pools.backend.zone`, and `namespaces` must have one namespace.                                                                                                                                                                                                      |
| **`primary_storage`**                             | object          | `{}`                                                                                                                                                                                                                          | The S3 bucket of the primary storage.                                                                                                                                                                                                                                                                                                            |
| `primary_storage.prefix`                          | string          | `""`                                                                                                                                                                                                                          | The key prefix of Platforma in the bucket.                                                                                                                                                                                                                                                                                                       |
| `primary_storage.abort_incomplete_multipart_days` | number          | `7`                                                                                                                                                                                                                           | A new bucket gets a lifecycle rule that deletes an incomplete multipart upload after this number of days.                                                                                                                                                                                                                                        |
| **`workspace`**                                   | object          | `{}`                                                                                                                                                                                                                          | The EFS file system of the workspace.                                                                                                                                                                                                                                                                                                            |
| `workspace.throughput_mode`                       | string          | `"elastic"`                                                                                                                                                                                                                   | The EFS throughput mode of a new file system.                                                                                                                                                                                                                                                                                                    |
| `workspace.base_path`                             | string          | `"/platforma"`                                                                                                                                                                                                                | The directory of the access points on the file system.                                                                                                                                                                                                                                                                                           |
| **`disks`**                                       | object          | `{}`                                                                                                                                                                                                                          | The EBS volumes that the EBS CSI driver makes, through the StorageClasses of `platforma-tf-cloud-cluster`.                                                                                                                                                                                                                                       |
| `disks.database`                                  | object          | `{}`                                                                                                                                                                                                                          | The gp3 volume of the database. It applies only to a new volume.                                                                                                                                                                                                                                                                                 |
| `disks.database.iops`                             | number          | `3000`                                                                                                                                                                                                                        | The IOPS of the volume.                                                                                                                                                                                                                                                                                                                          |
| `disks.database.throughput_mibps`                 | number          | `125`                                                                                                                                                                                                                         | The throughput of the volume, in MiB/s.                                                                                                                                                                                                                                                                                                          |
| `disks.logs`                                      | object          | `{}`                                                                                                                                                                                                                          | The gp3 volume of the logs.                                                                                                                                                                                                                                                                                                                      |
| `disks.logs.iops`                                 | number          | `3000`                                                                                                                                                                                                                        | The IOPS of the volume.                                                                                                                                                                                                                                                                                                                          |
| `disks.logs.throughput_mibps`                     | number          | `125`                                                                                                                                                                                                                         | The throughput of the volume, in MiB/s.                                                                                                                                                                                                                                                                                                          |
| `disks.logs.reclaim_policy`                       | string          | `"Delete"`                                                                                                                                                                                                                    | `Delete` or `Retain`: what happens to the volume when its claim is deleted.                                                                                                                                                                                                                                                                      |
| `disks.scratch`                                   | object          | `{}`                                                                                                                                                                                                                          | The temporary volumes of the jobs.                                                                                                                                                                                                                                                                                                               |
| `disks.scratch.type`                              | string          | `"gp3"`                                                                                                                                                                                                                       | `gp3`, `io1` or `io2`.                                                                                                                                                                                                                                                                                                                           |
| `disks.scratch.iops`                              | number          | `16000`                                                                                                                                                                                                                       | The IOPS of each volume. It also sets the smallest volume, for example 32 GiB for gp3 with 16,000 IOPS.                                                                                                                                                                                                                                          |
| `disks.scratch.throughput_mibps`                  | number          | `1000`                                                                                                                                                                                                                        | The throughput of each volume, in MiB/s. For gp3 only.                                                                                                                                                                                                                                                                                           |
| `disks.scratch.max_size`                          | string          | `"16Ti"`                                                                                                                                                                                                                      | The largest volume, at least 16 TiB. gp3 and io1 allow up to 16 TiB, io2 up to 64 TiB.                                                                                                                                                                                                                                                           |
| `disks.scratch.encrypted`                         | bool            | `true`                                                                                                                                                                                                                        | EBS encryption of the volumes.                                                                                                                                                                                                                                                                                                                   |
| **`data_libraries`**                              | list of objects | `[]`                                                                                                                                                                                                                          | The S3 buckets of the 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.). The Backend identity gets read rights on them. The libraries themselves are values of `backend_service` of `platforma-tf-services`.                                           |
| `data_libraries[].bucket`                         | string          | required                                                                                                                                                                                                                      | The name of the bucket. A bucket in another account must also allow the access in its bucket policy.                                                                                                                                                                                                                                             |
| `data_libraries[].prefix`                         | string          | `""`                                                                                                                                                                                                                          | With a prefix, the Backend can list and read only the keys that start with it. Empty means the whole bucket.                                                                                                                                                                                                                                     |
| **`jobs_policy_arns`**                            | list of strings | `[]`                                                                                                                                                                                                                          | IAM policies for the 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.) of the jobs. The jobs do not need access to the primary storage or to the data libraries.                                      |
| **`hosts`**                                       | list of strings | `[]`                                                                                                                                                                                                                          | The hosts of Platforma, for example `platforma.example.com`. A `*` matches exactly one label. DNS records and the TLS certificate cover the hosts.                                                                                                                                                                                               |
| **`dns`**                                         | object          | `{}`                                                                                                                                                                                                                          | The DNS zone of the hosts. Without a zone, `platforma-tf-cloud-cluster` does not install external-dns.                                                                                                                                                                                                                                           |
| `dns.zone_id`                                     | string          | `null`                                                                                                                                                                                                                        | A Route 53 public zone that exists.                                                                                                                                                                                                                                                                                                              |
| `dns.create_zone_name`                            | string          | `null`                                                                                                                                                                                                                        | The module makes a public zone with this name.                                                                                                                                                                                                                                                                                                   |
| **`tls`**                                         | object          | `{}`                                                                                                                                                                                                                          | The TLS certificate of the hosts, on the one HTTPS listener of the ALB.                                                                                                                                                                                                                                                                          |
| `tls.mode`                                        | string          | `"managed"`                                                                                                                                                                                                                   | `managed`: the module requests one ACM certificate for all hosts and validates it in the DNS zone. `existing`: ACM certificates that exist, in `certificates`. `none`: plain HTTP, for tests only: the Desktop App (The program that each user installs on their own computer to work with Platforma. It is a client of the Backend.) needs TLS. |
| `tls.certificates`                                | list of strings | `[]`                                                                                                                                                                                                                          | The ARNs of ACM certificates that exist, with `mode` = `existing` only. The first one is the default certificate of the listener.                                                                                                                                                                                                                |
| **`gateway`**                                     | object          | `{}`                                                                                                                                                                                                                          | The load balancer of the entry point, an ALB that the AWS Load Balancer Controller makes for the Kubernetes Gateway.                                                                                                                                                                                                                             |
| `gateway.allowed_cidrs`                           | list of strings | `["0.0.0.0/0"]`                                                                                                                                                                                                               | The networks of the users that can reach the ALB: the rules of its security group. The default `["0.0.0.0/0"]` allows all addresses.                                                                                                                                                                                                             |
| `gateway.scheme`                                  | string          | `"external"`                                                                                                                                                                                                                  | `external`: the ALB is in the public subnets and has public addresses. `internal`: the ALB is in the private subnets, and the users reach it through a VPN or another private connection.                                                                                                                                                        |
| `gateway.idle_timeout_seconds`                    | number          | `3600`                                                                                                                                                                                                                        | The idle timeout of the ALB, 300 to 4,000 seconds. A gRPC stream without traffic stays open for this time.                                                                                                                                                                                                                                       |
| **`registries`**                                  | object          | `{}`                                                                                                                                                                                                                          | The registries of the Backend. `platforma-tf-cloud-cluster` copies them to `cluster_config`.                                                                                                                                                                                                                                                     |
| `registries.default_docker_registry`              | string          | `""`                                                                                                                                                                                                                          | The registry path of the software images of the jobs. Empty means the default path, or the path of the ECR cache when `registry_mirrors.software.enabled` is `true`.                                                                                                                                                                             |
| `registries.trusted_docker_registries`            | list of strings | `[]`                                                                                                                                                                                                                          | More registry hosts that the Backend can pull images from.                                                                                                                                                                                                                                                                                       |
| `registries.assets_registry_url`                  | string          | `""`                                                                                                                                                                                                                          | The URL that replaces the default assets registry (A service from which the Backend downloads the assets that Blocks need, for example reference genomes. The default is bin.pl-open.science, the same host as the software registry; a mirror replaces it with its own URL.). Empty means the default.                                          |
| **`registry_mirrors`**                            | object          | `{}`                                                                                                                                                                                                                          | ECR pull-through caches of the images.                                                                                                                                                                                                                                                                                                           |
| `registry_mirrors.software`                       | object          | `{}`                                                                                                                                                                                                                          | The cache of the software images of the jobs.                                                                                                                                                                                                                                                                                                    |
| `registry_mirrors.software.enabled`               | bool            | `true`                                                                                                                                                                                                                        | Make the cache.                                                                                                                                                                                                                                                                                                                                  |
| `registry_mirrors.software.upstream`              | string          | `"https://quay.io"`                                                                                                                                                                                                           | The upstream registry. ECR supports only `https://quay.io`, `https://public.ecr.aws` and `https://registry.k8s.io`.                                                                                                                                                                                                                              |
| `registry_mirrors.backend`                        | object          | `{}`                                                                                                                                                                                                                          | The cache of the Backend image. Its path is in the output `registries.backend_image_repository`.                                                                                                                                                                                                                                                 |
| `registry_mirrors.backend.enabled`                | bool            | `true`                                                                                                                                                                                                                        | Make the cache.                                                                                                                                                                                                                                                                                                                                  |
| `registry_mirrors.backend.upstream`               | string          | `"https://quay.io"`                                                                                                                                                                                                           | The upstream registry. ECR supports only `https://quay.io`, `https://public.ecr.aws` and `https://registry.k8s.io`.                                                                                                                                                                                                                              |

### Outputs

| Output                     | Meaning                                                                                                                                                                                                   |
| -------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `platforma_infrastructure` | All that `platforma-tf-cloud-cluster` for AWS needs, as plain data without credentials. The root `cloud` writes it to `platforma-infrastructure.json`.                                                    |
| `cluster_connection`       | The endpoint, the CA certificate, the cluster name and the region of the cluster, for the providers of the next roots. It does not hold a token. The root `cloud` writes it to `cluster-connection.json`. |
| `dns_name_servers`         | The name servers of the DNS zone. Delegate a new zone to them in its parent zone. `null` without DNS.                                                                                                     |

## `platforma-tf-cloud-cluster` for AWS

Source: `terraform/aws/platforma-tf-cloud-cluster`. Root: `cluster`.

Installs the cloud parts inside the EKS cluster:

- the Gateway API CRDs and the Gateway;
- the AWS Load Balancer Controller;
- the cluster autoscaler;
- the EBS and EFS CSI drivers with the StorageClasses;
- external-dns;
- the GPU components.

It writes `cluster_config` for `platforma-tf-services-cluster`. For the names of the objects, see [Names](/infrastructure-contract-names/).

### Inputs

| Input                                            | Type   | Default                                                                        | Meaning                                                                                                                                                                                             |
| ------------------------------------------------ | ------ | ------------------------------------------------------------------------------ | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| **`platforma_infrastructure`**                   | any    | required                                                                       | The output `platforma_infrastructure` of `platforma-tf-cloud-base` for AWS, from `platforma-infrastructure.json`. The module refuses the object of another cloud or of another release.             |
| **`names`**                                      | object | `{}`                                                                           | Names of the cluster-wide objects that this module creates.                                                                                                                                         |
| `names.storage_classes`                          | object | `{}`                                                                           | The names of the StorageClasses.                                                                                                                                                                    |
| `names.storage_classes.database`                 | string | `"platforma-database"`                                                         | The StorageClass of the database volume.                                                                                                                                                            |
| `names.storage_classes.logs`                     | string | `"platforma-logs"`                                                             | The StorageClass of the logs volume.                                                                                                                                                                |
| `names.storage_classes.workspace`                | string | `"platforma-workspace"`                                                        | The StorageClass of the workspace.                                                                                                                                                                  |
| `names.storage_classes.scratch`                  | string | `"platforma-scratch"`                                                          | The StorageClass of the scratch volumes.                                                                                                                                                            |
| `names.gateway`                                  | object | `{}`                                                                           | The names of the Gateway of the entry point.                                                                                                                                                        |
| `names.gateway.name`                             | string | `"platforma-gateway"`                                                          | The name of the Gateway.                                                                                                                                                                            |
| `names.gateway.namespace`                        | string | `"platforma-gateway"`                                                          | The namespace of the Gateway.                                                                                                                                                                       |
| `names.gateway.section_name`                     | string | `"platforma"`                                                                  | The first part of the names of the listeners.                                                                                                                                                       |
| `names.gateway.class_name`                       | string | `"platforma-alb"`                                                              | The name of the GatewayClass.                                                                                                                                                                       |
| **`components`**                                 | object | `{}`                                                                           | What the module installs, and from where. `install` = `false` means that the cluster has the component already. The module pins the chart versions, and a mirror must hold the same versions.       |
| `components.gateway_api_crds`                    | object | `{}`                                                                           | The CRDs of the Gateway API.                                                                                                                                                                        |
| `components.gateway_api_crds.install`            | bool   | `true`                                                                         | Install the CRDs.                                                                                                                                                                                   |
| `components.load_balancer_controller`            | object | `{}`                                                                           | The AWS Load Balancer Controller.                                                                                                                                                                   |
| `components.load_balancer_controller.install`    | bool   | `true`                                                                         | Install the controller.                                                                                                                                                                             |
| `components.load_balancer_controller.repository` | string | `"https://aws.github.io/eks-charts"`                                           | The chart repository, or a mirror of it.                                                                                                                                                            |
| `components.cluster_autoscaler`                  | object | `{}`                                                                           | The cluster autoscaler. `install` = `false` also turns off the ProvisioningRequest classes.                                                                                                         |
| `components.cluster_autoscaler.install`          | bool   | `true`                                                                         | Install the autoscaler and the ProvisioningRequest CRD.                                                                                                                                             |
| `components.cluster_autoscaler.repository`       | string | `"https://kubernetes.github.io/autoscaler"`                                    | The chart repository, or a mirror of it.                                                                                                                                                            |
| `components.ebs_csi`                             | object | `{}`                                                                           | The EBS CSI driver.                                                                                                                                                                                 |
| `components.ebs_csi.install`                     | bool   | `true`                                                                         | Install the driver.                                                                                                                                                                                 |
| `components.ebs_csi.repository`                  | string | `"https://kubernetes-sigs.github.io/aws-ebs-csi-driver"`                       | The chart repository, or a mirror of it.                                                                                                                                                            |
| `components.efs_csi`                             | object | `{}`                                                                           | The EFS CSI driver.                                                                                                                                                                                 |
| `components.efs_csi.install`                     | bool   | `true`                                                                         | Install the driver.                                                                                                                                                                                 |
| `components.efs_csi.repository`                  | string | `"https://kubernetes-sigs.github.io/aws-efs-csi-driver"`                       | The chart repository, or a mirror of it.                                                                                                                                                            |
| `components.external_dns`                        | object | `{}`                                                                           | external-dns, which writes the DNS records of the hosts.                                                                                                                                            |
| `components.external_dns.install`                | bool   | `true`                                                                         | Install external-dns.                                                                                                                                                                               |
| `components.external_dns.repository`             | string | `"https://kubernetes-sigs.github.io/external-dns"`                             | The chart repository, or a mirror of it.                                                                                                                                                            |
| `components.nvidia_device_plugin`                | object | `{}`                                                                           | The NVIDIA device plugin of the GPU nodes.                                                                                                                                                          |
| `components.nvidia_device_plugin.install`        | bool   | `true`                                                                         | Install the plugin.                                                                                                                                                                                 |
| `components.nvidia_device_plugin.repository`     | string | `"https://nvidia.github.io/k8s-device-plugin"`                                 | The chart repository, or a mirror of it.                                                                                                                                                            |
| `components.gpu_node_ready`                      | object | `{}`                                                                           | A component that removes the startup taint of a new GPU node when the node reports its GPUs.                                                                                                        |
| `components.gpu_node_ready.install`              | bool   | `true`                                                                         | Install the component.                                                                                                                                                                              |
| `components.gpu_node_ready.image`                | string | `"containers.pl-open.science/milaboratories/pl-containers:alpine.k8s.1.35.10"` | The image of the component.                                                                                                                                                                         |
| **`destroy_cleanup`**                            | object | `{}`                                                                           | At destroy, wait until the AWS Load Balancer Controller and external-dns delete the cloud resources that they made, and delete what they leave. It runs the AWS CLI on the computer of the destroy. |
| `destroy_cleanup.enabled`                        | bool   | `true`                                                                         | Run the cleanup.                                                                                                                                                                                    |
| `destroy_cleanup.aws_profile`                    | string | `null`                                                                         | The AWS profile of the cleanup. `null` means the AWS credentials of the environment.                                                                                                                |
| `destroy_cleanup.timeout_seconds`                | number | `600`                                                                          | The maximum time of the cleanup, in seconds.                                                                                                                                                        |

### Outputs

| Output           | Meaning                                                                            |
| ---------------- | ---------------------------------------------------------------------------------- |
| `cluster_config` | The input `cluster_config` of `platforma-tf-services-cluster`, contract version 1. |

## `platforma-tf-cloud-base` for Google Cloud

Source: `terraform/gcp/platforma-tf-cloud-base`. Root: `cloud`.

Makes the cloud resources of one installation in one Google Cloud project:

- the VPC with Cloud NAT;
- the zonal GKE cluster with its node pools;
- the Cloud Storage bucket of the primary storage;
- the Filestore instance of the workspace;
- the service accounts of the Backend and of the jobs;
- the address, the certificate and the DNS records of the entry point;
- the Artifact Registry caches of the images.

For the node pools and the storage, see [Jobs](/infrastructure-contract-jobs/) and [Storage](/infrastructure-contract-storage/).

### Inputs

| Input                                             | Type            | Default                                                                                                                                                                                                                            | Meaning                                                                                                                                                                                                                                                                                                                                             |
| ------------------------------------------------- | --------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| **`project_id`**                                  | string          | required                                                                                                                                                                                                                           | The ID of the Google Cloud project for all resources of the installation.                                                                                                                                                                                                                                                                           |
| **`region`**                                      | string          | required                                                                                                                                                                                                                           | The region of the network, the bucket, the registry mirrors and the NAT.                                                                                                                                                                                                                                                                            |
| **`zone`**                                        | string          | required                                                                                                                                                                                                                           | The zone of the zonal GKE cluster, of its system and Backend node pools, and of the zonal Filestore instance.                                                                                                                                                                                                                                       |
| **`name`**                                        | string          | required                                                                                                                                                                                                                           | The name of the installation: the name of the GKE cluster and the start of the names of most cloud resources. 1 to 18 lowercase letters, digits and `-`; it starts with a letter and ends with a letter or a digit.                                                                                                                                 |
| **`labels`**                                      | map of strings  | `{}`                                                                                                                                                                                                                               | Labels for each cloud resource that supports labels: the cluster, the node VMs, the disks that the CSI driver creates, the bucket, the Filestore instance, the registry mirrors and the addresses.                                                                                                                                                  |
| **`enable_apis`**                                 | bool            | `true`                                                                                                                                                                                                                             | Enable the Google APIs that the module needs.                                                                                                                                                                                                                                                                                                       |
| **`namespaces`**                                  | list of strings | `["platforma"]`                                                                                                                                                                                                                    | The namespaces of the Platforma instances: one instance in each namespace.                                                                                                                                                                                                                                                                          |
| **`service_account_names`**                       | object          | `{}`                                                                                                                                                                                                                               | The names of the Kubernetes ServiceAccounts of the Backend and of the jobs.                                                                                                                                                                                                                                                                         |
| `service_account_names.backend`                   | string          | `"platforma-backend"`                                                                                                                                                                                                              | The ServiceAccount of the Backend.                                                                                                                                                                                                                                                                                                                  |
| `service_account_names.jobs`                      | string          | `"platforma-jobs"`                                                                                                                                                                                                                 | The ServiceAccount of the jobs.                                                                                                                                                                                                                                                                                                                     |
| **`run_as`**                                      | object          | `{}`                                                                                                                                                                                                                               | The user and the group of the Backend pod and of the job pods (default 1010:1010).                                                                                                                                                                                                                                                                  |
| `run_as.user`                                     | number          | `1010`                                                                                                                                                                                                                             | The user ID. It cannot be 0 (root).                                                                                                                                                                                                                                                                                                                 |
| `run_as.group`                                    | number          | `1010`                                                                                                                                                                                                                             | The group ID. It cannot be 0 (root).                                                                                                                                                                                                                                                                                                                |
| **`network`**                                     | object          | `{}`                                                                                                                                                                                                                               | The VPC of the installation, with one subnet, Cloud NAT and a firewall rule for the health checks of the load balancers. The nodes have private IP addresses only.                                                                                                                                                                                  |
| `network.nodes_cidr`                              | string          | `"10.10.0.0/20"`                                                                                                                                                                                                                   | The range of the subnet of the nodes.                                                                                                                                                                                                                                                                                                               |
| `network.pods_cidr`                               | string          | `"10.16.0.0/14"`                                                                                                                                                                                                                   | The secondary range of the pods.                                                                                                                                                                                                                                                                                                                    |
| `network.services_cidr`                           | string          | `"10.20.0.0/20"`                                                                                                                                                                                                                   | The secondary range of the services.                                                                                                                                                                                                                                                                                                                |
| `network.proxy_only_cidr`                         | string          | `"10.24.0.0/23"`                                                                                                                                                                                                                   | The proxy-only subnet of the internal load balancer, with `gateway.scheme` = `internal` only. The mask must be /26 or larger.                                                                                                                                                                                                                       |
| **`kubernetes`**                                  | object          | `{}`                                                                                                                                                                                                                               | The GKE cluster.                                                                                                                                                                                                                                                                                                                                    |
| `kubernetes.release_channel`                      | string          | `"REGULAR"`                                                                                                                                                                                                                        | `REGULAR`, `STABLE`, `RAPID`, `EXTENDED` or `UNSPECIFIED` (no channel).                                                                                                                                                                                                                                                                             |
| `kubernetes.block_node_upgrades`                  | bool            | `true`                                                                                                                                                                                                                             | In a release channel, add a maintenance exclusion that stops the automatic upgrades of the nodes.                                                                                                                                                                                                                                                   |
| `kubernetes.version_prefix`                       | string          | `null`                                                                                                                                                                                                                             | The Kubernetes version of a new cluster, for example `1.36.` for the latest 1.36 patch. `null` means the latest version of the channel.                                                                                                                                                                                                             |
| `kubernetes.min_version`                          | string          | `"1.36"`                                                                                                                                                                                                                           | The lowest Kubernetes version that the module accepts.                                                                                                                                                                                                                                                                                              |
| `kubernetes.api_allowed_cidrs`                    | list of strings | `null`                                                                                                                                                                                                                             | Required: there is no default. The networks that can reach the public endpoint of the Kubernetes API (the master authorized networks of GKE): the networks of the computers that run Terraform and `kubectl`. `["0.0.0.0/0"]` opens the API to the whole internet.                                                                                  |
| `kubernetes.deletion_protection`                  | bool            | `true`                                                                                                                                                                                                                             | Terraform cannot delete the cluster.                                                                                                                                                                                                                                                                                                                |
| `kubernetes.maintenance_window`                   | string          | `"02:00"`                                                                                                                                                                                                                          | The start of a daily maintenance window, `HH:MM` in UTC.                                                                                                                                                                                                                                                                                            |
| `kubernetes.maintenance_exclusions`               | list of objects | `[]`                                                                                                                                                                                                                               | More time windows without upgrades. Without a release channel, GKE accepts at most 30 days.                                                                                                                                                                                                                                                         |
| `kubernetes.maintenance_exclusions[].name`        | string          | required                                                                                                                                                                                                                           | The name of the window.                                                                                                                                                                                                                                                                                                                             |
| `kubernetes.maintenance_exclusions[].start_time`  | string          | required                                                                                                                                                                                                                           | The start of the window.                                                                                                                                                                                                                                                                                                                            |
| `kubernetes.maintenance_exclusions[].end_time`    | string          | required                                                                                                                                                                                                                           | The end of the window.                                                                                                                                                                                                                                                                                                                              |
| **`node_pools`**                                  | object          | `{}`                                                                                                                                                                                                                               | The node pools. One node group is one GKE node pool with the name of the group.                                                                                                                                                                                                                                                                     |
| `node_pools.system`                               | object          | `{}`                                                                                                                                                                                                                               | The nodes of the cluster components, without a label or a taint, in `zone`.                                                                                                                                                                                                                                                                         |
| `node_pools.system.machine_type`                  | string          | `"e2-standard-4"`                                                                                                                                                                                                                  | The machine type.                                                                                                                                                                                                                                                                                                                                   |
| `node_pools.system.min_size`                      | number          | `1`                                                                                                                                                                                                                                | The minimum number of nodes.                                                                                                                                                                                                                                                                                                                        |
| `node_pools.system.max_size`                      | number          | `3`                                                                                                                                                                                                                                | The maximum number of nodes.                                                                                                                                                                                                                                                                                                                        |
| `node_pools.system.spot`                          | bool            | `false`                                                                                                                                                                                                                            | Use Spot VMs. Only the system pool can use them.                                                                                                                                                                                                                                                                                                    |
| `node_pools.system.boot_disk_type`                | string          | `null`                                                                                                                                                                                                                             | The type of the boot disk. `null` means `hyperdisk-balanced` for the machine series that support only Hyperdisk, else `pd-balanced`.                                                                                                                                                                                                                |
| `node_pools.system.boot_disk_size_gib`            | number          | `100`                                                                                                                                                                                                                              | The size of the boot disk of each node, in GiB.                                                                                                                                                                                                                                                                                                     |
| `node_pools.backend`                              | object          | `{}`                                                                                                                                                                                                                               | One node for the Backend pod, in `zone`, where the database volume is.                                                                                                                                                                                                                                                                              |
| `node_pools.backend.machine_type`                 | string          | `"n4-standard-8"`                                                                                                                                                                                                                  | The machine type.                                                                                                                                                                                                                                                                                                                                   |
| `node_pools.backend.min_size`                     | number          | `1`                                                                                                                                                                                                                                | The minimum number of nodes.                                                                                                                                                                                                                                                                                                                        |
| `node_pools.backend.max_size`                     | number          | `1`                                                                                                                                                                                                                                | The maximum number of nodes.                                                                                                                                                                                                                                                                                                                        |
| `node_pools.backend.boot_disk_type`               | string          | `null`                                                                                                                                                                                                                             | The type of the boot disk. `null` means `hyperdisk-balanced` for the machine series that support only Hyperdisk, else `pd-balanced`.                                                                                                                                                                                                                |
| `node_pools.backend.boot_disk_size_gib`           | number          | `100`                                                                                                                                                                                                                              | The size of the boot disk of each node, in GiB.                                                                                                                                                                                                                                                                                                     |
| `node_pools.backend.allocatable`                  | object          | `null`                                                                                                                                                                                                                             | The CPU and the memory that the Backend pod can use on its node. `null` means that the module calculates it from the machine type. Keys: `cpu`, `memory_gib`.                                                                                                                                                                                       |
| `node_pools.ui`                                   | object          | `{}`                                                                                                                                                                                                                               | The job pool of the UI jobs. It is necessary.                                                                                                                                                                                                                                                                                                       |
| `node_pools.ui.node_groups`                       | list of objects | `[{ name = "ui-2c-8g", machine_type = "n4-standard-2", max_size = 4 }, { name = "ui-4c-16g", machine_type = "n4-standard-4", max_size = 4 } ]`                                                                                     | The node groups of the pool, of 2 or more machine types. `min_size` = 0 lets a group scale from zero. Keys: `name`, `machine_type`, `min_size` = `0`, `max_size`, `zones`, `boot_disk_type`, `boot_disk_size_gib` = `100`, `allocatable`.                                                                                                           |
| `node_pools.ui.quota`                             | object          | `null`                                                                                                                                                                                                                             | The quota of the queue of the pool. `null` means `max_size` × allocatable of the node groups. Keys: `cpu`, `memory_gib`.                                                                                                                                                                                                                            |
| `node_pools.batch`                                | object          | `{}`                                                                                                                                                                                                                               | The job pool of the batch jobs. It is necessary.                                                                                                                                                                                                                                                                                                    |
| `node_pools.batch.node_groups`                    | list of objects | `[{ name = "batch-4c-16g", machine_type = "n4-standard-4", max_size = 8 }, { name = "batch-16c-64g", machine_type = "n4-standard-16", max_size = 4 }, { name = "batch-32c-256g", machine_type = "n4-highmem-32", max_size = 8 } ]` | The node groups of the pool, of 2 or more machine types. `min_size` = 0 lets a group scale from zero. Keys: `name`, `machine_type`, `min_size` = `0`, `max_size`, `zones`, `boot_disk_type`, `boot_disk_size_gib` = `200`, `allocatable`.                                                                                                           |
| `node_pools.batch.quota`                          | object          | `null`                                                                                                                                                                                                                             | The quota of the queue of the pool. `null` means `max_size` × allocatable of the node groups. Keys: `cpu`, `memory_gib`.                                                                                                                                                                                                                            |
| `node_pools.gpu`                                  | object          | `{}`                                                                                                                                                                                                                               | The job pool of the GPU jobs. It is optional.                                                                                                                                                                                                                                                                                                       |
| `node_pools.gpu.node_groups`                      | list of objects | `[]`                                                                                                                                                                                                                               | The GPU node groups. Empty means that there is no GPU pool. Each group has `gpu` = `{ type, gpus_per_node, gpu_memory_gib }`, and `zones` when the GPU type is not in all zones. Keys: `name`, `machine_type`, `min_size` = `0`, `max_size`, `zones`, `boot_disk_type`, `boot_disk_size_gib` = `200`, `allocatable`, `gpu`.                         |
| `node_pools.gpu.quota`                            | object          | `null`                                                                                                                                                                                                                             | The quota of the queue of the pool. `null` means `max_size` × allocatable of the node groups. Keys: `cpu`, `memory_gib`, `gpus`.                                                                                                                                                                                                                    |
| **`job_zones`**                                   | list of strings | `[]`                                                                                                                                                                                                                               | The zones of the node groups of the job pools, in `region`.                                                                                                                                                                                                                                                                                         |
| **`allocatable_reserve`**                         | object          | `{}`                                                                                                                                                                                                                               | What the module subtracts from the GKE allocatable of a node to get what one job can use.                                                                                                                                                                                                                                                           |
| `allocatable_reserve.cpu`                         | number          | `0.7`                                                                                                                                                                                                                              | The CPUs of the DaemonSets.                                                                                                                                                                                                                                                                                                                         |
| `allocatable_reserve.memory_gib`                  | number          | `1.0`                                                                                                                                                                                                                              | The memory of the DaemonSets, in GiB.                                                                                                                                                                                                                                                                                                               |
| `allocatable_reserve.memory_fraction`             | number          | `0.03`                                                                                                                                                                                                                             | The part of the memory of the machine type that the node does not show as capacity.                                                                                                                                                                                                                                                                 |
| **`provisioning_request`**                        | object          | `{ cpu = "best-effort-atomic-scale-up.autoscaling.x-k8s.io", gpu = "best-effort-atomic-scale-up.autoscaling.x-k8s.io" }`                                                                                                           | The ProvisioningRequest classes of the CPU jobs and of the GPU jobs. A ProvisioningRequest asks the cluster autoscaler for all nodes of one job before the job starts.                                                                                                                                                                              |
| `provisioning_request.cpu`                        | string          | `null`                                                                                                                                                                                                                             | The class of the CPU jobs. `null` turns it off, and Kueue admits these jobs by quota only.                                                                                                                                                                                                                                                          |
| `provisioning_request.gpu`                        | string          | `null`                                                                                                                                                                                                                             | The class of the GPU jobs. `null` turns it off.                                                                                                                                                                                                                                                                                                     |
| **`node_service_account`**                        | object          | `{}`                                                                                                                                                                                                                               | The Google service account of the nodes.                                                                                                                                                                                                                                                                                                            |
| `node_service_account.email`                      | string          | `null`                                                                                                                                                                                                                             | A service account that exists. `null` means that the module makes one.                                                                                                                                                                                                                                                                              |
| `node_service_account.grant_project_roles`        | bool            | `true`                                                                                                                                                                                                                             | Give the new account the role `roles/container.defaultNodeServiceAccount` on the project.                                                                                                                                                                                                                                                           |
| **`existing_storages`**                           | object          | `{}`                                                                                                                                                                                                                               | Kept data of an earlier installation. A key that is set makes the module use that resource, not make a new one.                                                                                                                                                                                                                                     |
| `existing_storages.bucket`                        | string          | `null`                                                                                                                                                                                                                             | The name of a kept Cloud Storage bucket of the primary storage.                                                                                                                                                                                                                                                                                     |
| `existing_storages.workspace`                     | object          | `null`                                                                                                                                                                                                                             | A kept Filestore instance of the workspace.                                                                                                                                                                                                                                                                                                         |
| `existing_storages.workspace.ip_address`          | string          | required                                                                                                                                                                                                                           | The IP address of the NFS share.                                                                                                                                                                                                                                                                                                                    |
| `existing_storages.workspace.share_name`          | string          | required                                                                                                                                                                                                                           | The name of the file share.                                                                                                                                                                                                                                                                                                                         |
| `existing_storages.workspace.capacity_gib`        | number          | required                                                                                                                                                                                                                           | The size of the share, in GiB.                                                                                                                                                                                                                                                                                                                      |
| `existing_storages.database_volume`               | string          | `null`                                                                                                                                                                                                                             | The name of a kept disk of the database, in `zone`.                                                                                                                                                                                                                                                                                                 |
| **`primary_storage`**                             | object          | `{}`                                                                                                                                                                                                                               | The Cloud Storage bucket of the primary storage.                                                                                                                                                                                                                                                                                                    |
| `primary_storage.prefix`                          | string          | `""`                                                                                                                                                                                                                               | The prefix of the objects of the Backend in the bucket.                                                                                                                                                                                                                                                                                             |
| `primary_storage.abort_incomplete_multipart_days` | number          | `7`                                                                                                                                                                                                                                | A new bucket gets a lifecycle rule that deletes an incomplete multipart upload after this number of days. 0 means no rule.                                                                                                                                                                                                                          |
| **`data_libraries`**                              | list of objects | `[]`                                                                                                                                                                                                                               | The Cloud Storage buckets of the data libraries. The Backend identity gets read rights on them. The libraries themselves are values of `backend_service` of `platforma-tf-services`.                                                                                                                                                                |
| `data_libraries[].bucket`                         | string          | required                                                                                                                                                                                                                           | The name of the bucket.                                                                                                                                                                                                                                                                                                                             |
| `data_libraries[].prefix`                         | string          | `""`                                                                                                                                                                                                                               | With a prefix, the Backend can list and read only the objects that start with it. Empty means the whole bucket.                                                                                                                                                                                                                                     |
| **`workspace`**                                   | object          | `{}`                                                                                                                                                                                                                               | The Filestore instance of the workspace, mounted over NFSv3.                                                                                                                                                                                                                                                                                        |
| `workspace.tier`                                  | string          | `"ZONAL"`                                                                                                                                                                                                                          | `BASIC_HDD`, `BASIC_SSD`, `ZONAL` or `REGIONAL`. The smallest share is 1,024 GiB, and 2,560 GiB for `BASIC_SSD`.                                                                                                                                                                                                                                    |
| `workspace.capacity_gib`                          | number          | `1024`                                                                                                                                                                                                                             | The size of the share, in GiB.                                                                                                                                                                                                                                                                                                                      |
| `workspace.share_name`                            | string          | `"workspace"`                                                                                                                                                                                                                      | The name of the file share.                                                                                                                                                                                                                                                                                                                         |
| `workspace.deletion_protection`                   | bool            | `true`                                                                                                                                                                                                                             | Terraform cannot delete the instance. For the `ZONAL` and `REGIONAL` tiers only.                                                                                                                                                                                                                                                                    |
| **`disks`**                                       | object          | `{}`                                                                                                                                                                                                                               | The disks that the Compute Engine persistent disk CSI driver makes, through the StorageClasses of `platforma-tf-cloud-cluster`.                                                                                                                                                                                                                     |
| `disks.database`                                  | object          | `{}`                                                                                                                                                                                                                               | The disk of the database.                                                                                                                                                                                                                                                                                                                           |
| `disks.database.type`                             | string          | `"hyperdisk-balanced"`                                                                                                                                                                                                             | `hyperdisk-balanced`, where the IOPS and the throughput do not depend on the size, or `pd-ssd` or `pd-balanced`, where they grow with the size.                                                                                                                                                                                                     |
| `disks.database.iops`                             | number          | `3000`                                                                                                                                                                                                                             | The IOPS of the disk, for Hyperdisk only.                                                                                                                                                                                                                                                                                                           |
| `disks.database.throughput_mibps`                 | number          | `140`                                                                                                                                                                                                                              | The throughput of the disk in MiB/s, for Hyperdisk only.                                                                                                                                                                                                                                                                                            |
| `disks.logs`                                      | object          | `{}`                                                                                                                                                                                                                               | The disk of the logs.                                                                                                                                                                                                                                                                                                                               |
| `disks.logs.type`                                 | string          | `"hyperdisk-balanced"`                                                                                                                                                                                                             | `hyperdisk-balanced`, `pd-ssd` or `pd-balanced`.                                                                                                                                                                                                                                                                                                    |
| `disks.logs.iops`                                 | number          | `3000`                                                                                                                                                                                                                             | The IOPS of the disk, for Hyperdisk only.                                                                                                                                                                                                                                                                                                           |
| `disks.logs.throughput_mibps`                     | number          | `140`                                                                                                                                                                                                                              | The throughput of the disk in MiB/s, for Hyperdisk only.                                                                                                                                                                                                                                                                                            |
| `disks.logs.reclaim_policy`                       | string          | `"Delete"`                                                                                                                                                                                                                         | `Delete` or `Retain`: what happens to the disk when its claim is deleted.                                                                                                                                                                                                                                                                           |
| `disks.scratch`                                   | object          | `{}`                                                                                                                                                                                                                               | The temporary volumes of the jobs.                                                                                                                                                                                                                                                                                                                  |
| `disks.scratch.enabled`                           | bool            | `true`                                                                                                                                                                                                                             | Make the StorageClass of the scratch volumes.                                                                                                                                                                                                                                                                                                       |
| `disks.scratch.type`                              | string          | `"hyperdisk-balanced"`                                                                                                                                                                                                             | `hyperdisk-balanced`, `pd-ssd` or `pd-balanced`.                                                                                                                                                                                                                                                                                                    |
| `disks.scratch.iops`                              | number          | `16000`                                                                                                                                                                                                                            | The IOPS of each volume, for Hyperdisk only.                                                                                                                                                                                                                                                                                                        |
| `disks.scratch.throughput_mibps`                  | number          | `1000`                                                                                                                                                                                                                             | The throughput of each volume in MiB/s, for Hyperdisk only.                                                                                                                                                                                                                                                                                         |
| **`gateway`**                                     | object          | `{}`                                                                                                                                                                                                                               | The type of the load balancer of the entry point, and the networks that can reach it. The names of the Gateway are in `names.gateway` of `platforma-tf-cloud-cluster`.                                                                                                                                                                              |
| `gateway.scheme`                                  | string          | `"external"`                                                                                                                                                                                                                       | `external`: a global external Application Load Balancer with a public address. `internal`: a regional internal Application Load Balancer without a public address, which the users reach through a VPN or another private connection.                                                                                                               |
| `gateway.allowed_cidrs`                           | list of strings | `["0.0.0.0/0"]`                                                                                                                                                                                                                    | The networks of the users that can reach the entry point. The default `["0.0.0.0/0"]` allows all addresses, and the module does not make a Cloud Armor policy. A list without `0.0.0.0/0` makes a Cloud Armor security policy (global for `external`, regional for `internal`) that refuses all other addresses with HTTP 403. A policy has a cost. |
| **`hosts`**                                       | list of strings | `[]`                                                                                                                                                                                                                               | The hosts of Platforma, for example `platforma.example.com`. A `*` matches exactly one label.                                                                                                                                                                                                                                                       |
| **`tls`**                                         | object          | `{}`                                                                                                                                                                                                                               | The TLS certificate of the Gateway listeners.                                                                                                                                                                                                                                                                                                       |
| `tls.mode`                                        | string          | `"managed"`                                                                                                                                                                                                                        | `managed`: a Google-managed certificate of Certificate Manager, with DNS authorization in a public `dns.managed_zone`. `existing`: Compute Engine SSL certificates that exist, in `certificates`. `none`: plain HTTP, for tests only: the Desktop App needs TLS.                                                                                    |
| `tls.certificates`                                | list of strings | `[]`                                                                                                                                                                                                                               | The names of the SSL certificates, with `mode` = `existing` only.                                                                                                                                                                                                                                                                                   |
| **`dns`**                                         | object          | `{}`                                                                                                                                                                                                                               | The Cloud DNS zone of the hosts.                                                                                                                                                                                                                                                                                                                    |
| `dns.managed_zone`                                | string          | `null`                                                                                                                                                                                                                             | The name of the zone. `null` means that the module does not make DNS records.                                                                                                                                                                                                                                                                       |
| `dns.project_id`                                  | string          | `null`                                                                                                                                                                                                                             | The project of the zone. `null` means `project_id`.                                                                                                                                                                                                                                                                                                 |
| **`registry_mirrors`**                            | object          | `{}`                                                                                                                                                                                                                               | Artifact Registry remote repositories that cache the images.                                                                                                                                                                                                                                                                                        |
| `registry_mirrors.software`                       | object          | `{}`                                                                                                                                                                                                                               | The cache of the software images of the jobs.                                                                                                                                                                                                                                                                                                       |
| `registry_mirrors.software.enabled`               | bool            | `true`                                                                                                                                                                                                                             | Make the cache.                                                                                                                                                                                                                                                                                                                                     |
| `registry_mirrors.software.upstream`              | string          | `"https://containers.pl-open.science"`                                                                                                                                                                                             | The upstream registry.                                                                                                                                                                                                                                                                                                                              |
| `registry_mirrors.backend`                        | object          | `{}`                                                                                                                                                                                                                               | The cache of the Backend image.                                                                                                                                                                                                                                                                                                                     |
| `registry_mirrors.backend.enabled`                | bool            | `true`                                                                                                                                                                                                                             | Make the cache.                                                                                                                                                                                                                                                                                                                                     |
| `registry_mirrors.backend.upstream`               | string          | `"https://quay.io"`                                                                                                                                                                                                                | The upstream registry.                                                                                                                                                                                                                                                                                                                              |
| `registry_mirrors.grant_node_access`              | bool            | `true`                                                                                                                                                                                                                             | Give the node service account the role `roles/artifactregistry.reader` on the caches.                                                                                                                                                                                                                                                               |
| **`registries`**                                  | object          | `{}`                                                                                                                                                                                                                               | The registries of the Backend. `platforma-tf-cloud-cluster` copies them to `cluster_config`.                                                                                                                                                                                                                                                        |
| `registries.default_docker_registry`              | string          | `""`                                                                                                                                                                                                                               | A registry, cache or mirror of the software images of the public Blocks (A small application for one step of an analysis, for example the import of reads or clustering. It can combine several tools.). Empty means the default path, or the path of the cache when `registry_mirrors.software.enabled` is `true`.                                 |
| `registries.trusted_docker_registries`            | list of strings | `[]`                                                                                                                                                                                                                               | More registry hosts for the software of custom Blocks.                                                                                                                                                                                                                                                                                              |
| `registries.assets_registry_url`                  | string          | `""`                                                                                                                                                                                                                               | The URL that replaces the default assets registry. Empty means the default.                                                                                                                                                                                                                                                                         |

### Outputs

| Output                     | Meaning                                                                                                                                                                     |
| -------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `platforma_infrastructure` | All that `platforma-tf-cloud-cluster` for Google Cloud needs, as plain data without credentials. The root `cloud` writes it to `platforma-infrastructure.json`.             |
| `cluster_connection`       | The endpoint and the CA certificate of the cluster, for the providers of the next roots. It does not hold a token. The root `cloud` writes it to `cluster-connection.json`. |

## `platforma-tf-cloud-cluster` for Google Cloud

Source: `terraform/gcp/platforma-tf-cloud-cluster`. Root: `cluster`.

Installs the cloud parts inside the GKE cluster: the StorageClasses, the static volumes of the workspace, the Gateway, and the Job that makes the workspace directories. It writes `cluster_config` for `platforma-tf-services-cluster`. For the names of the objects, see [Names](/infrastructure-contract-names/).

### Inputs

| Input                               | Type   | Default                 | Meaning                                                                                                                                                                                                              |
| ----------------------------------- | ------ | ----------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| **`platforma_infrastructure`**      | any    | required                | The output `platforma_infrastructure` of `platforma-tf-cloud-base` for Google Cloud, from `platforma-infrastructure.json`. The module refuses the object of another cloud or of another release.                     |
| **`names`**                         | object | `{}`                    | Names of the cluster-wide objects that the module makes.                                                                                                                                                             |
| `names.storage_classes`             | object | `{}`                    | The names of the StorageClasses.                                                                                                                                                                                     |
| `names.storage_classes.database`    | string | `"platforma-database"`  | The StorageClass of the database volume.                                                                                                                                                                             |
| `names.storage_classes.logs`        | string | `"platforma-logs"`      | The StorageClass of the logs volume.                                                                                                                                                                                 |
| `names.storage_classes.workspace`   | string | `"platforma-workspace"` | The StorageClass of the workspace.                                                                                                                                                                                   |
| `names.storage_classes.scratch`     | string | `"platforma-scratch"`   | The StorageClass of the scratch volumes.                                                                                                                                                                             |
| `names.gateway`                     | object | `{}`                    | The names of the Gateway of the entry point. The type of the load balancer is `gateway.scheme` of `platforma-tf-cloud-base`.                                                                                         |
| `names.gateway.name`                | string | `"platforma-gateway"`   | The name of the Gateway.                                                                                                                                                                                             |
| `names.gateway.namespace`           | string | `"platforma-gateway"`   | The namespace of the Gateway.                                                                                                                                                                                        |
| `names.gateway.section_name`        | string | `"platforma"`           | The first part of the names of the listeners.                                                                                                                                                                        |
| **`components`**                    | object | `{}`                    | What the module installs in the cluster.                                                                                                                                                                             |
| `components.workspace_init`         | object | `{}`                    | A Job that makes one workspace directory for each namespace, owned by `run_as`.                                                                                                                                      |
| `components.workspace_init.install` | bool   | `true`                  | Run the Job. `false` means that the directories exist already.                                                                                                                                                       |
| `components.workspace_init.image`   | string | `null`                  | The image of the Job, with `sh`, `mkdir`, `chown` and `chmod`. `null` means `containers.pl-open.science/milaboratories/pl-containers:busybox.1.37.0`.                                                                |
| **`destroy_cleanup`**               | object | `{}`                    | At destroy, wait until the GKE controllers delete the load balancer of the Gateway, and delete the network endpoint groups and the firewall rules that they leave. It needs `gcloud` on the computer of the destroy. |
| `destroy_cleanup.enabled`           | bool   | `true`                  | Run the cleanup.                                                                                                                                                                                                     |
| `destroy_cleanup.timeout_seconds`   | number | `900`                   | The maximum time of the cleanup, in seconds.                                                                                                                                                                         |

### Outputs

| Output              | Meaning                                                                            |
| ------------------- | ---------------------------------------------------------------------------------- |
| `cluster_config`    | The input `cluster_config` of `platforma-tf-services-cluster`, contract version 1. |
| `workspace_volumes` | The static NFS PersistentVolumes of the workspace, for each namespace.             |

## `platforma-tf-services-cluster`

Source: `terraform/cloud-agnostic/platforma-tf-services-cluster`. Root: `cluster`.

Prepares any Kubernetes cluster for Platforma with cluster admin rights: the namespaces, Kueue and AppWrapper, the job queues with their quotas and priorities, and the roles. It writes `infrastructure` for `platforma-tf-services`. For the queues and the quotas, see [Jobs](/infrastructure-contract-jobs/).

### Inputs

| Input                                             | Type            | Default                                          | Meaning                                                                                                                                                                                                                                                                                                                                            |
| ------------------------------------------------- | --------------- | ------------------------------------------------ | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| **`cluster_config`**                              | object          | required                                         | The description of the cluster. It comes from the output of `platforma-tf-cloud-cluster`, or the operator (The person who installs and runs Platforma in your company, for example an IT engineer or a bioinformatician.) writes it by hand as JSON. The module copies `cloud_values` unchanged to the output `infrastructure`.                    |
| `cluster_config.contract_version`                 | number          | required                                         | The contract version. The current version is 1.                                                                                                                                                                                                                                                                                                    |
| `cluster_config.namespaces`                       | list of strings | required                                         | The namespaces of the Platforma instances.                                                                                                                                                                                                                                                                                                         |
| `cluster_config.node_pools`                       | object          | required                                         | The node pools. `node_selector` and `tolerations` use the field names of Kubernetes.                                                                                                                                                                                                                                                               |
| `cluster_config.node_pools.backend`               | object          | `null`                                           | The pool of the Backend pod. Not set means the default pool of the chart (label `platforma.bio/pool=backend`). An empty `node_selector` and empty `tolerations` put the pod on shared nodes. Keys: `node_selector`, `tolerations`.                                                                                                                 |
| `cluster_config.node_pools.ui`                    | object          | required                                         | The job pool of the UI jobs. Keys: `node_selector`, `tolerations`, `node_groups`, `quota`.                                                                                                                                                                                                                                                         |
| `cluster_config.node_pools.batch`                 | object          | required                                         | The job pool of the batch jobs. Keys: `node_selector`, `tolerations`, `node_groups`, `quota`.                                                                                                                                                                                                                                                      |
| `cluster_config.node_pools.gpu`                   | object          | `null`                                           | The job pool of the GPU jobs. It is optional. Keys: `node_selector`, `tolerations`, `node_groups`, `quota`.                                                                                                                                                                                                                                        |
| `cluster_config.autoscaling`                      | object          | required                                         | The autoscaling of the job pools. It selects the quota rule.                                                                                                                                                                                                                                                                                       |
| `cluster_config.autoscaling.enabled`              | bool            | required                                         | `true` when a cluster autoscaler adds and removes the nodes of the job pools: the quota is `max_size` × allocatable. With `false`, the quota is the value that you set, or the capacity of the nodes that exist now.                                                                                                                               |
| `cluster_config.autoscaling.provisioning_request` | object          | required                                         | The ProvisioningRequest classes of the CPU jobs (`cpu`) and of the GPU jobs (`gpu`). `null` means that Kueue admits the jobs by quota only. A class needs `enabled` = `true`. Keys: `cpu`, `gpu`.                                                                                                                                                  |
| `cluster_config.cloud_values`                     | object          | required                                         | The values that the module copies to the output `infrastructure` without reading them. A value that is not set gets the default of `platforma-tf-services`.                                                                                                                                                                                        |
| `cluster_config.cloud_values.run_as`              | object          | `null`                                           | The user and the group of the Backend pod and of the job pods. They own the workspace. Keys: `user`, `group`.                                                                                                                                                                                                                                      |
| `cluster_config.cloud_values.jobs`                | object          | required                                         | The ServiceAccount of the jobs. Keys: `service_account`.                                                                                                                                                                                                                                                                                           |
| `cluster_config.cloud_values.registries`          | object          | `null`                                           | The registries of the Backend. Keys: `default_docker_registry`, `trusted_docker_registries`, `assets_registry_url`.                                                                                                                                                                                                                                |
| `cluster_config.cloud_values.backend`             | object          | required                                         | The ServiceAccount of the Backend, and the CPU and the memory that the Backend pod can use on its node. Keys: `service_account`, `allocatable`.                                                                                                                                                                                                    |
| `cluster_config.cloud_values.network`             | object          | `null`                                           | The hosts, and one entry point for each host, with exactly one of `gateway` and `ingress`. An empty list of entry points means no access from outside the cluster. Keys: `hosts`, `entry_points`, `backend_security_policy`.                                                                                                                       |
| `cluster_config.cloud_values.ca_bundle`           | object          | `null`                                           | The CA bundle (One PEM file with the certificate authorities that a program trusts. In Kubernetes, Platforma can give the Backend and all jobs one bundle with the public and the corporate certificate authorities.) for the TLS connections of the Backend. Keys: `config_map`, `file_path`.                                                     |
| `cluster_config.cloud_values.volumes`             | object          | `null`                                           | The StorageClasses and volumes of the database, the logs, the workspace and the scratch volumes. Keys: `database`, `logs`, `workspace`, `scratch`.                                                                                                                                                                                                 |
| `cluster_config.cloud_values.primary_storage`     | object          | required                                         | The primary storage, with exactly one of `s3` and `gcs`. Keys: `s3`, `gcs`.                                                                                                                                                                                                                                                                        |
| **`components`**                                  | object          | `{}`                                             | What the module installs and makes, and where it gets them. A component with `install` = `false` must be in the cluster already: the module checks it at plan.                                                                                                                                                                                     |
| `components.queue_statistics`                     | object          | `{}`                                             | Queue statistics in the Desktop App.                                                                                                                                                                                                                                                                                                               |
| `components.queue_statistics.enabled`             | bool            | `true`                                           | Give the Backend read rights on its two ClusterQueues. With `false`, the Desktop App does not show queue statistics.                                                                                                                                                                                                                               |
| `components.kueue`                                | object          | `{}`                                             | Kueue, the job queue controller. The module pins its version.                                                                                                                                                                                                                                                                                      |
| `components.kueue.cluster_queues`                 | object          | `{}`                                             | The names of the ClusterQueues that the module makes, or, with `create_queues` = `false`, that the cluster has. Keys: `ui` = `"platforma-ui"`, `batch` = `"platforma-batch"`.                                                                                                                                                                      |
| `components.kueue.priority_classes`               | object          | `{}`                                             | The names of the WorkloadPriorityClasses that the module makes, or that the cluster has. Keys: `ui` = `"platforma-ui"`, `low` = `"platforma-low"`, `normal` = `"platforma-normal"`, `high` = `"platforma-high"`.                                                                                                                                   |
| `components.kueue.install`                        | bool            | `true`                                           | Install the Kueue controller, its CRDs and its configuration.                                                                                                                                                                                                                                                                                      |
| `components.kueue.create_queues`                  | bool            | `true`                                           | Make the ResourceFlavors, the ClusterQueues, the WorkloadPriorityClasses and the admission checks.                                                                                                                                                                                                                                                 |
| `components.kueue.ui_borrows_batch_quota`         | bool            | `true`                                           | Put the two ClusterQueues in one cohort, so that the UI queue can use the idle quota of the batch queue.                                                                                                                                                                                                                                           |
| `components.kueue.chart_repository`               | string          | `"oci://registry.k8s.io/kueue/charts"`           | The chart repository, or a mirror of it with the same version.                                                                                                                                                                                                                                                                                     |
| `components.kueue.image`                          | object          | `{}`                                             | The image of the controller, or a mirror of it with the same version. Keys: `repository` = `"registry.k8s.io/kueue/kueue"`, `pull_policy` = `"IfNotPresent"`.                                                                                                                                                                                      |
| `components.appwrapper`                           | object          | `{}`                                             | AppWrapper, the controller that runs a job of several pods as one unit. The module pins its version.                                                                                                                                                                                                                                               |
| `components.appwrapper.install`                   | bool            | `true`                                           | Install the AppWrapper controller and its CRD.                                                                                                                                                                                                                                                                                                     |
| `components.appwrapper.chart_repository`          | string          | `"oci://ghcr.io/milaboratory/platforma-install"` | The repository that holds the chart `appwrapper`. It is an OCI or HTTP(S) repository, or a local directory, for example `helm/charts` of a clone of platforma-install.                                                                                                                                                                             |
| `components.appwrapper.image`                     | object          | `{}`                                             | The image of the controller, or a mirror of it with the same version. Keys: `repository` = `"containers.pl-open.science/milaboratories/pl-containers"`, `pull_policy` = `"IfNotPresent"`.                                                                                                                                                          |
| `components.appwrapper.webhooks_enabled`          | bool            | `false`                                          | Install the admission webhooks of AppWrapper (chart value `webhooks.enabled`). Platforma does not need them: only the Backend creates AppWrappers. Set `true` when other users or tools also create AppWrappers in the cluster: then the validating webhook stops a user who puts objects into an AppWrapper that the user cannot create directly. |
| `components.namespaces`                           | object          | `{}`                                             | The namespaces of Platforma.                                                                                                                                                                                                                                                                                                                       |
| `components.namespaces.create`                    | bool            | `true`                                           | Make the namespaces of `cluster_config.namespaces`.                                                                                                                                                                                                                                                                                                |
| `components.rbac`                                 | object          | `{}`                                             | The ClusterRoles of Platforma. Two installations of the module in one cluster need different names.                                                                                                                                                                                                                                                |
| `components.rbac.namespace_admin_role`            | string          | `"platforma-namespace-admin"`                    | The ClusterRole that adds the rights on the Kueue and AppWrapper objects to the role `admin`.                                                                                                                                                                                                                                                      |
| `components.rbac.queue_reader_role`               | string          | `"platforma-queue-reader"`                       | The ClusterRole that lets the Backend read its two ClusterQueues.                                                                                                                                                                                                                                                                                  |

### Outputs

| Output           | Meaning                                                                                                                                  |
| ---------------- | ---------------------------------------------------------------------------------------------------------------------------------------- |
| `infrastructure` | The input `infrastructure` of `platforma-tf-services`, with the contract version. The root `cluster` writes it to `infrastructure.json`. |
| `quotas`         | The quotas of the ClusterQueues for each job pool, the number of CPUs and the memory in GiB.                                             |
| `versions`       | The versions of Kueue and AppWrapper that this release of the module pins.                                                               |

## `platforma-tf-services`

Source: `terraform/cloud-agnostic/platforma-tf-services`. Root: `services`.

Installs the Backend in one namespace, as one release of the Helm chart `platforma-backend`. The role `admin` in that namespace is enough. Each key of `infrastructure` and `backend_service` has the path of its chart value, in snake_case: for the full meaning of a value, see [Chart values](/reference-chart-values/). For the settings, see the Configuration pages, for example [Authentication](/configuration-authentication/) and [Storage](/configuration-storage/).

### Inputs

| Input                                                 | Type            | Default                                          | Meaning                                                                                                                                                                                                                                                                                                                                                                                                                                       |
| ----------------------------------------------------- | --------------- | ------------------------------------------------ | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| **`namespace`**                                       | string          | `"platforma"`                                    | The namespace of the instance. It must exist and be in `infrastructure.namespaces`.                                                                                                                                                                                                                                                                                                                                                           |
| **`infrastructure`**                                  | object          | required                                         | The values that the infrastructure gives. It is the output `infrastructure` of `platforma-tf-services-cluster` from `infrastructure.json`, or the operator writes it by hand.                                                                                                                                                                                                                                                                 |
| `infrastructure.contract_version`                     | number          | required                                         | The contract version. This release accepts 1.                                                                                                                                                                                                                                                                                                                                                                                                 |
| `infrastructure.namespaces`                           | list of strings | `["platforma"]`                                  | The namespaces of the Platforma instances in the cluster.                                                                                                                                                                                                                                                                                                                                                                                     |
| `infrastructure.run_as`                               | object          | `{}`                                             | The user and the group of the Backend pod and of all job pods. They own the workspace.                                                                                                                                                                                                                                                                                                                                                        |
| `infrastructure.run_as.user`                          | number          | `1010`                                           | The user ID, above 0.                                                                                                                                                                                                                                                                                                                                                                                                                         |
| `infrastructure.run_as.group`                         | number          | `1010`                                           | The group ID, above 0.                                                                                                                                                                                                                                                                                                                                                                                                                        |
| `infrastructure.jobs`                                 | object          | required                                         | The jobs of the Backend.                                                                                                                                                                                                                                                                                                                                                                                                                      |
| `infrastructure.jobs.cluster_queues`                  | object          | `{}`                                             | The names of the ClusterQueues and of the priority classes. Keys: `ui`, `batch`.                                                                                                                                                                                                                                                                                                                                                              |
| `infrastructure.jobs.queue_statistics`                | bool            | `true`                                           | Show the queue statistics in the Desktop App.                                                                                                                                                                                                                                                                                                                                                                                                 |
| `infrastructure.jobs.max_request`                     | object          | required                                         | The largest job, the allocatable of one batch node. `cpu` (whole CPUs) and `memory` (for example `55Gi`) are necessary. `gpu` = `{}` means no GPU jobs. Keys: `cpu`, `memory`, `gpu`.                                                                                                                                                                                                                                                         |
| `infrastructure.jobs.service_account`                 | object          | required                                         | The ServiceAccount of the jobs. `name` is necessary: the infrastructure binds its cloud identity to it. Keys: `create` = `true`, `name`, `annotations` = `{}`.                                                                                                                                                                                                                                                                                |
| `infrastructure.registries`                           | object          | `{}`                                             | The registries of the Backend.                                                                                                                                                                                                                                                                                                                                                                                                                |
| `infrastructure.registries.default_docker_registry`   | string          | `""`                                             | The registry path of the software images of the jobs. Empty means the default.                                                                                                                                                                                                                                                                                                                                                                |
| `infrastructure.registries.trusted_docker_registries` | list of strings | `[]`                                             | More registry hosts that the Backend can pull images from.                                                                                                                                                                                                                                                                                                                                                                                    |
| `infrastructure.registries.assets_registry_url`       | string          | `""`                                             | The URL that replaces the default assets registry. Empty means the default.                                                                                                                                                                                                                                                                                                                                                                   |
| `infrastructure.backend`                              | object          | required                                         | The Backend pod.                                                                                                                                                                                                                                                                                                                                                                                                                              |
| `infrastructure.backend.node_selector`                | map of strings  | `null`                                           | The node selector of the Backend pod. `null` means the pool `backend` of the chart; `{}` means shared nodes.                                                                                                                                                                                                                                                                                                                                  |
| `infrastructure.backend.tolerations`                  | list of objects | `null`                                           | The tolerations of the Backend pod, in the form of Kubernetes. `null` means the pool `backend` of the chart; `[]` means shared nodes. Keys: `key`, `operator`, `value`, `effect`, `tolerationSeconds`.                                                                                                                                                                                                                                        |
| `infrastructure.backend.service_account`              | object          | required                                         | The ServiceAccount of the Backend. `name` is necessary: the infrastructure binds its cloud identity to it. Keys: `create` = `true`, `name`, `annotations` = `{}`.                                                                                                                                                                                                                                                                             |
| `infrastructure.backend.allocatable`                  | object          | `null`                                           | The CPUs and the memory (GiB) that the Backend pod can use on its node. Without `backend_service.backend.resources`, the pod requests this value. Keys: `cpu`, `memory_gib`.                                                                                                                                                                                                                                                                  |
| `infrastructure.network`                              | object          | `{}`                                             | The hosts and the entry points.                                                                                                                                                                                                                                                                                                                                                                                                               |
| `infrastructure.network.hosts`                        | list of strings | `[]`                                             | The hosts that have DNS records and a TLS certificate. A `*` matches exactly one label.                                                                                                                                                                                                                                                                                                                                                       |
| `infrastructure.network.entry_points`                 | list of objects | `[]`                                             | One entry point for each host, with exactly one of `gateway` and `ingress`. `[]` means no access from outside the cluster. Keys: `host`, `gateway`, `ingress`.                                                                                                                                                                                                                                                                                |
| `infrastructure.network.backend_security_policy`      | string          | `""`                                             | A security object of the cloud that the Gateway attaches to the Backend Service, for example an address allow-list. With `gke-gateway`: the name of a Cloud Armor security policy. `""` means no policy. The other Gateway implementations do not accept a value.                                                                                                                                                                             |
| `infrastructure.ca_bundle`                            | object          | `{}`                                             | The CA bundle for the TLS connections of the Backend.                                                                                                                                                                                                                                                                                                                                                                                         |
| `infrastructure.ca_bundle.config_map`                 | object          | `{}`                                             | A ConfigMap with the CA bundle. An empty name means no ConfigMap. Keys: `name` = `""`, `key` = `"ca-certificates.crt"`.                                                                                                                                                                                                                                                                                                                       |
| `infrastructure.ca_bundle.file_path`                  | string          | `"/etc/ssl/certs/ca-certificates.crt"`           | The path of the CA bundle in the Backend pod.                                                                                                                                                                                                                                                                                                                                                                                                 |
| `infrastructure.volumes`                              | object          | `{}`                                             | The StorageClasses and the volumes.                                                                                                                                                                                                                                                                                                                                                                                                           |
| `infrastructure.volumes.database`                     | object          | `{}`                                             | The volume of the database. Keys: `storage_class` = `"platforma-database"`, `volume_name` = `""`.                                                                                                                                                                                                                                                                                                                                             |
| `infrastructure.volumes.logs`                         | object          | `{}`                                             | The volume of the logs. Keys: `storage_class` = `"platforma-logs"`, `volume_name` = `""`.                                                                                                                                                                                                                                                                                                                                                     |
| `infrastructure.volumes.workspace`                    | object          | `{}`                                             | The volume of the workspace. Keys: `storage_class` = `"platforma-workspace"`, `volume_name` = `""`.                                                                                                                                                                                                                                                                                                                                           |
| `infrastructure.volumes.scratch`                      | object          | `{}`                                             | The scratch volumes of the jobs. Keys: `enabled` = `false`, `storage_class` = `"platforma-scratch"`, `min_size` = `""`, `max_size` = `"16Ti"`.                                                                                                                                                                                                                                                                                                |
| `infrastructure.primary_storage`                      | object          | required                                         | The primary storage. Set exactly one of `s3` and `gcs`.                                                                                                                                                                                                                                                                                                                                                                                       |
| `infrastructure.primary_storage.s3`                   | object          | `null`                                           | Amazon S3 or a compatible storage. Empty Secret names mean that the Backend uses its cloud identity. Keys: `bucket` = `""`, `region` = `""`, `prefix` = `""`, `endpoint` = `""`, `external_endpoint` = `""`, `data_integrity_checks` = `true`, `secret`.                                                                                                                                                                                      |
| `infrastructure.primary_storage.gcs`                  | object          | `null`                                           | Google Cloud Storage. Keys: `bucket` = `""`, `project_id` = `""`, `prefix` = `""`, `service_account` = `""`.                                                                                                                                                                                                                                                                                                                                  |
| **`backend_service`**                                 | object          | `{}`                                             | The values that the operator sets. Exactly one sign-in (To show the Backend who you are, with a sign-in provider or a single-user token. The verb is "sign in"; the noun and the adjective are "sign-in".) mode is necessary, `auth.single_user.enabled` or `auth.providers`.                                                                                                                                                                 |
| `backend_service.release_name`                        | string          | `"platforma"`                                    | The name of the Helm release. The chart names the objects of the instance after it. Use a different name for each instance in one namespace.                                                                                                                                                                                                                                                                                                  |
| `backend_service.chart_repository`                    | string          | `"oci://ghcr.io/milaboratory/platforma-install"` | The repository of the chart `platforma-backend`. It is an OCI or HTTP(S) repository, or a local directory, for example `helm/charts` of a clone of platforma-install. The module pins the chart version.                                                                                                                                                                                                                                      |
| `backend_service.debug`                               | bool            | `false`                                          | The debug mode of the Backend.                                                                                                                                                                                                                                                                                                                                                                                                                |
| `backend_service.jobs`                                | object          | `{}`                                             | The settings of the jobs.                                                                                                                                                                                                                                                                                                                                                                                                                     |
| `backend_service.jobs.image_pull_max_retries`         | number          | `2`                                              | More attempts for a job that fails because its node pulled the software image too slowly. `0`: no more attempts.                                                                                                                                                                                                                                                                                                                              |
| `backend_service.jobs.image`                          | object          | `{}`                                             | The pull Secrets of the job images. Keys: `pull_secrets`.                                                                                                                                                                                                                                                                                                                                                                                     |
| `backend_service.jobs.pod_annotations`                | map of strings  | `{}`                                             | Annotations of the job pods.                                                                                                                                                                                                                                                                                                                                                                                                                  |
| `backend_service.jobs.scheduling`                     | object          | `{}`                                             | The runs and the time limits of a job. `max_attempts` includes the first run. Time limits are Go durations, and `gpu_timeout` must be lower than `warmup_timeout`. Keys: `max_attempts` = `3`, `warmup_timeout` = `"30m"`, `gpu_timeout` = `"10m"`.                                                                                                                                                                                           |
| `backend_service.jobs.secrets`                        | object          | `{}`                                             | The Secret with the values that a job can ask for, for example the license key. An empty name means the license Secret. Keys: `name` = `""`.                                                                                                                                                                                                                                                                                                  |
| `backend_service.network`                             | object          | `{}`                                             | The Service and the TLS of the Backend pod.                                                                                                                                                                                                                                                                                                                                                                                                   |
| `backend_service.network.service`                     | object          | `{}`                                             | The Service of the Backend. `app_protocol` = `null` lets the chart select the protocol. Keys: `annotations` = `{}`, `app_protocol`.                                                                                                                                                                                                                                                                                                           |
| `backend_service.network.tls`                         | object          | `{}`                                             | TLS on the Backend pod, with a Secret of the certificate. Keys: `enabled` = `false`, `secret`.                                                                                                                                                                                                                                                                                                                                                |
| `backend_service.secrets`                             | object          | `{}`                                             | The references to the Secrets of the Backend.                                                                                                                                                                                                                                                                                                                                                                                                 |
| `backend_service.secrets.license`                     | object          | `{}`                                             | The Secret and the key of the license. Keys: `name` = `"platforma-license"`, `key` = `"MI_LICENSE"`.                                                                                                                                                                                                                                                                                                                                          |
| `backend_service.secrets.master_secret`               | object          | `{}`                                             | The Secret and the key of the master secret. Keys: `name` = `"platforma-master-secret"`, `key` = `"master-secret"`.                                                                                                                                                                                                                                                                                                                           |
| `backend_service.volumes`                             | object          | `{}`                                             | The sizes of the volumes.                                                                                                                                                                                                                                                                                                                                                                                                                     |
| `backend_service.volumes.database`                    | object          | `{}`                                             | The size of the database volume. Keys: `size` = `"50Gi"`.                                                                                                                                                                                                                                                                                                                                                                                     |
| `backend_service.volumes.logs`                        | object          | `{}`                                             | The logs volume. With `enabled` = `false`, the logs go to stderr only. Keys: `enabled` = `true`, `size` = `"30Gi"`.                                                                                                                                                                                                                                                                                                                           |
| `backend_service.volumes.workspace`                   | object          | `{}`                                             | The size of the workspace, or a volume claim that exists, with a sub-path. Keys: `size` = `"1Ti"`, `existing_claim` = `""`, `sub_path` = `""`.                                                                                                                                                                                                                                                                                                |
| `backend_service.data_libraries`                      | list of objects | `[]`                                             | The data libraries. Each library has an `id` and exactly one of `s3`, `gcs` and `pvc`.                                                                                                                                                                                                                                                                                                                                                        |
| `backend_service.data_libraries[].id`                 | string          | required                                         | The ID of the library. Do not change it after the first install.                                                                                                                                                                                                                                                                                                                                                                              |
| `backend_service.data_libraries[].name`               | string          | `""`                                             | The name that users see. Empty means the ID.                                                                                                                                                                                                                                                                                                                                                                                                  |
| `backend_service.data_libraries[].s3`                 | object          | `null`                                           | A bucket of Amazon S3 or a compatible storage. Without `secret`, the Backend uses its cloud identity. Keys: `bucket`, `region` = `""`, `prefix` = `""`, `endpoint` = `""`, `external_endpoint` = `""`, `data_integrity_checks` = `true`, `secret`.                                                                                                                                                                                            |
| `backend_service.data_libraries[].gcs`                | object          | `null`                                           | A bucket of Google Cloud Storage. Keys: `bucket`, `prefix` = `""`, `project_id` = `""`, `service_account` = `""`.                                                                                                                                                                                                                                                                                                                             |
| `backend_service.data_libraries[].pvc`                | object          | `null`                                           | A volume claim that exists, with a sub-path. Keys: `existing_claim`, `sub_path` = `""`.                                                                                                                                                                                                                                                                                                                                                       |
| `backend_service.backend`                             | object          | `{}`                                             | The Backend pod.                                                                                                                                                                                                                                                                                                                                                                                                                              |
| `backend_service.backend.image`                       | object          | `{}`                                             | The image of the Backend. An empty tag means the version of the chart. Keys: `repository` = `"quay.io/milaboratories/platforma"`, `tag` = `""`, `pull_policy` = `"IfNotPresent"`, `pull_secrets`.                                                                                                                                                                                                                                             |
| `backend_service.backend.pod_annotations`             | map of strings  | `{}`                                             | Annotations of the Backend pod.                                                                                                                                                                                                                                                                                                                                                                                                               |
| `backend_service.backend.pod_labels`                  | map of strings  | `{}`                                             | Labels of the Backend pod.                                                                                                                                                                                                                                                                                                                                                                                                                    |
| `backend_service.backend.affinity`                    | any             | `{}`                                             | The affinity of the Backend pod, in the form of Kubernetes.                                                                                                                                                                                                                                                                                                                                                                                   |
| `backend_service.backend.resources`                   | object          | `null`                                           | The requests and limits of the Backend pod. Not set means `infrastructure.backend.allocatable`, or 8 CPUs and 32 GiB without it. Keys: `requests`, `limits`.                                                                                                                                                                                                                                                                                  |
| `backend_service.auth`                                | object          | `{}`                                             | The sign-in.                                                                                                                                                                                                                                                                                                                                                                                                                                  |
| `backend_service.auth.show_user_list_to`              | string          | `"users"`                                        | Who can get the list of users: `users` (all users), `admins` (only administrators) or `nobody`.                                                                                                                                                                                                                                                                                                                                               |
| `backend_service.auth.single_user`                    | object          | `{}`                                             | The single-user mode, with a token in a Secret. It is the other sign-in mode to `providers`. Keys: `enabled` = `false`, `token`.                                                                                                                                                                                                                                                                                                              |
| `backend_service.auth.providers`                      | list of objects | `[]`                                             | The sign-in providers (A configured way for users to sign in to the Backend: single sign-on (SSO), LDAP or a static list of users. One Backend can have more than one.). Each provider has a unique `name` and exactly one of `sso`, `ldap` and `htpasswd`. Keys: `name`, `title`, `description`, `sso`, `google`, `ldap`, `htpasswd`, `map`, `map_fields`, `look_up_attr`, `trust_unverified_email`, `create_users`, `admin_users`, `roles`. |
| `backend_service.auth.extension_fields`               | list of strings | `[]`                                             | Custom user fields of the instance. The providers fill them with `map_fields`.                                                                                                                                                                                                                                                                                                                                                                |
| `backend_service.extra_args`                          | list of strings | `[]`                                             | More command-line options of the Backend.                                                                                                                                                                                                                                                                                                                                                                                                     |
| `backend_service.env`                                 | object          | `{}`                                             | Environment variables of the Backend.                                                                                                                                                                                                                                                                                                                                                                                                         |
| `backend_service.env.variables`                       | map of strings  | `{}`                                             | Variables with their values.                                                                                                                                                                                                                                                                                                                                                                                                                  |
| `backend_service.env.secret_variables`                | list of objects | `[]`                                             | Variables from keys of Secrets. Keys: `name`, `secret`.                                                                                                                                                                                                                                                                                                                                                                                       |
| `backend_service.env.config_map_variables`            | list of objects | `[]`                                             | Variables from keys of ConfigMaps. Keys: `name`, `config_map`.                                                                                                                                                                                                                                                                                                                                                                                |
| `backend_service.logging`                             | object          | `{}`                                             | The logs of the Backend.                                                                                                                                                                                                                                                                                                                                                                                                                      |
| `backend_service.logging.rotation`                    | object          | `{}`                                             | The size of one log file and the number of files that the Backend keeps. Keys: `size` = `"1Gi"`, `count` = `10`.                                                                                                                                                                                                                                                                                                                              |
| `backend_service.logging.tree_changelog`              | object          | `{}`                                             | The tree changelog: the change summaries of each transaction, in a file with its own rotation. Keys: `enabled` = `true`, `max_size` = `"1Gi"`, `max_backups` = `200`.                                                                                                                                                                                                                                                                         |
| `backend_service.cleanup`                             | object          | `{}`                                             | The cleanup of old objects.                                                                                                                                                                                                                                                                                                                                                                                                                   |
| `backend_service.cleanup.app_wrappers`                | object          | `{}`                                             | A CronJob that removes the finished AppWrappers of the release that are older than `max_age`. Its image needs `kubectl` and `jq`. Keys: `enabled` = `true`, `schedule` = `"0 3 * * *"`, `max_age` = `"120h"`, `image`.                                                                                                                                                                                                                        |

### Outputs

| Output         | Meaning                                                                                                                                  |
| -------------- | ---------------------------------------------------------------------------------------------------------------------------------------- |
| `release`      | The Helm release of the Backend, with its name, namespace, chart, chart version and app version.                                         |
| `entry_points` | The entry points of the Backend, with the host that the Desktop App connects to and the Gateway or IngressClass.                         |
| `chart_values` | The values that the module gives to the chart `platforma-backend`, as YAML, for debugging. They hold references to Secrets, not secrets. |
| `versions`     | The contract version and the chart version that this release of the module pins.                                                         |

## Hand-off files

The roots give the outputs to the next root as JSON files, written with `terraform output -json <output> > <file>`. Each file is plain data without credentials.

| File                            | Output                                                                 | Input of                                                                                                   |
| ------------------------------- | ---------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------- |
| `platforma-infrastructure.json` | `platforma_infrastructure` of `platforma-tf-cloud-base` (root `cloud`) | `platforma_infrastructure` of `platforma-tf-cloud-cluster` (root `cluster`), of the same cloud and release |
| `cluster-connection.json`       | `cluster_connection` of `platforma-tf-cloud-base` (root `cloud`)       | The providers of the roots `cluster` and `services`                                                        |
| `infrastructure.json`           | `infrastructure` of `platforma-tf-services-cluster` (root `cluster`)   | `infrastructure` of `platforma-tf-services` (root `services`)                                              |

The output `cluster_config` of `platforma-tf-cloud-cluster` goes to the input `cluster_config` of `platforma-tf-services-cluster` in the same root `cluster`, without a file. For a cluster that exists already, the operator writes `cluster_config` by hand. For what the contract guarantees about `cluster_config` and `infrastructure`, see [The hand-off file](/infrastructure-contract-modules/#the-hand-off-file) and [The contract version](/infrastructure-contract-modules/#the-contract-version).

## Next

- [Install in cloud with Terraform](/install-cloud-terraform/)
- [Chart values](/reference-chart-values/)

Source: https://docs.platforma.bio/reference-terraform-modules/
