> ## Documentation Index
> Fetch the complete documentation index at: https://docs.formal.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# Deploy a Connector

> Infrastructure and network requirements for deploying Connectors

The Connector is available as a statically linked binary in a multi-architecture distroless Docker image.

### Container Image Registries

You can pull Connector images from either of these registries:

* AWS ECR: `654654333078.dkr.ecr.<region>.amazonaws.com/formalco-prod-connector:<tag>`
  Available regions: `us-east-1`, `us-east-2`, `us-west-1`, `us-west-2`, `ap-southeast-1`, and `eu-west-1`.
* GCP Artifact Registry: `us-docker.pkg.dev/formal-public-assets/formalco-prod-connector/formalco-prod-connector:<tag>`

> [!NOTE]
>
> On AKS, use the GAR image with
> [`azure-gar-cred`](https://github.com/formalco/helm-charts/tree/main/charts/azure-gar-cred).
> Set `pullWithCredentials: true` in the Connector Helm values.

### Amazon ECR Pull-Through Cache

You can cache Formal images in your own Amazon ECR registry with an ECR pull-through cache rule.
Your clusters then pull from your registry, so they need no Formal image pull secret.

Formal must first allowlist your AWS account ID or organization ID for ECR pulls.
Contact Formal support to request access.

1. **Create an IAM role for the cache**

   Amazon ECR assumes this role to pull from Formal's registry. Save this trust policy as `ptc-trust.json`:

   ```json theme={"languages":{"custom":["/languages/cel.json","/languages/rego.json"]}}
   {
     "Version": "2012-10-17",
     "Statement": [
       {
         "Effect": "Allow",
         "Principal": { "Service": "pullthroughcache.ecr.amazonaws.com" },
         "Action": "sts:AssumeRole"
       }
     ]
   }
   ```

   Save this permissions policy as `ptc-permissions.json`:

   ```json theme={"languages":{"custom":["/languages/cel.json","/languages/rego.json"]}}
   {
     "Version": "2012-10-17",
     "Statement": [
       {
         "Effect": "Allow",
         "Action": [
           "ecr:GetAuthorizationToken",
           "ecr:BatchGetImage",
           "ecr:GetDownloadUrlForLayer",
           "ecr:BatchImportUpstreamImage",
           "ecr:GetImageCopyStatus",
           "ecr:InitiateLayerUpload",
           "ecr:UploadLayerPart",
           "ecr:CompleteLayerUpload",
           "ecr:PutImage"
         ],
         "Resource": "*"
       }
     ]
   }
   ```

   Create the role:

   ```bash theme={"languages":{"custom":["/languages/cel.json","/languages/rego.json"]}}
   aws iam create-role \
     --role-name formal-ecr-pull-through-cache \
     --assume-role-policy-document file://ptc-trust.json
   aws iam put-role-policy \
     --role-name formal-ecr-pull-through-cache \
     --policy-name formal-ecr-pull-through-cache \
     --policy-document file://ptc-permissions.json
   ```

2. **Create the pull-through cache rule**

   Run this in the AWS account and region of your registry.
   Set `--upstream-registry-url` to a Formal ECR region listed above.

   ```bash theme={"languages":{"custom":["/languages/cel.json","/languages/rego.json"]}}
   aws ecr create-pull-through-cache-rule \
     --ecr-repository-prefix formal \
     --upstream-registry ecr \
     --upstream-registry-url 654654333078.dkr.ecr.us-east-1.amazonaws.com \
     --custom-role-arn arn:aws:iam::<YOUR_ACCOUNT_ID>:role/formal-ecr-pull-through-cache
   ```

3. **Pull through your registry**

   Prefix Formal repository names with `formal/` and use your registry host:

   ```text theme={"languages":{"custom":["/languages/cel.json","/languages/rego.json"]}}
   <YOUR_ACCOUNT_ID>.dkr.ecr.<YOUR_REGION>.amazonaws.com/formal/formalco-prod-connector:<tag>
   ```

   In the Connector Helm chart, set `image.repository` to this value and keep `pullWithCredentials: false`.

**Verify:**

```bash theme={"languages":{"custom":["/languages/cel.json","/languages/rego.json"]}}
aws ecr get-login-password --region <YOUR_REGION> | docker login \
  --username AWS --password-stdin <YOUR_ACCOUNT_ID>.dkr.ecr.<YOUR_REGION>.amazonaws.com
docker pull <YOUR_ACCOUNT_ID>.dkr.ecr.<YOUR_REGION>.amazonaws.com/formal/formalco-prod-connector:latest
aws ecr describe-images --region <YOUR_REGION> --repository-name formal/formalco-prod-connector
# Expected: the cached image appears in your registry
```

> [!NOTE]
>
> Amazon ECR checks Formal's registry for tag updates at most once every 24 hours.
> Pin versioned tags instead of `latest`.
> Keep cached repositories tag-mutable, or cached tags stop updating.

### Infrastructure Requirements

* **Operating System**: Linux environment
* **Architecture**: AMD64 or ARM64
* **Container Runtime**: Docker or compatible container runtime

### Network Requirements

The Connector requires:

* **Network access** to `api.joinformal.com` (Formal Control Plane)
* **Outbound access** to your protected resources
* **Inbound access** from clients on configured listener ports

#### AWS VPC Private Link Connectivity

On AWS, the Connector can reach the Control Plane over AWS PrivateLink instead of the public internet.
See [Reach the Control Plane over AWS PrivateLink](https://docs.formal.ai/docs/guides/control-plane/private-link.md).

### Resource Requirements

The Connector requires adequate resources to apply policies with minimal latency and maintain all necessary context in RAM (Control Plane data, queries metadata, responses data, log buffer, etc.).

| Spec | Minimum | Recommended |
| - | - | - |
| **CPU** | 1 core | 2 cores per node (2 nodes) |
| **RAM** | 2 GB | 4 GB per node (2 nodes) |
| **Disk** | 0 GB | 10 GB |

> [!WARNING]
>
> **CPU Throttling Warning**: If you don't allocate entire CPU cores to the Connector and rely on CPU throttling (e.g., CFS quotas on Linux, CPU limits in Kubernetes), you will most likely experience increased latency and timeouts during peak loads.

### Production Recommendations

For production deployments, we recommend:

* **High Availability**: Run at least 2 nodes behind a load balancer
* **Resource Allocation**: 2 CPU cores and 4 GB RAM per node
* **Load Distribution**: Distribute traffic across multiple Connector instances
* **Persistent Storage**: Mount a persistent volume to `/formal/logs` for the [log spool](https://docs.formal.ai/docs/guides/core-concepts/connectors/operations.md#log-spool)

CPU, RAM and disk requirements vary based on usage patterns, query types, traffic volume, and enforced policies. Monitor your Connector with a [telemetry collector](https://docs.formal.ai/docs/guides/core-concepts/connectors/health.md#metrics) and scale resources as needed. To size Connectors for your workload, see [Sizing and Load Testing](https://docs.formal.ai/docs/guides/core-concepts/connectors/sizing.md).

The Connector buffers up to 400 MB of logs in memory before [spooling to disk](https://docs.formal.ai/docs/guides/core-concepts/connectors/operations.md#log-spool). A typical log entry is around 1 KB – at 100 requests per second, 10 GB of disk provides more than a day of outage buffer. The Connector works without disk (spooling is disabled), but logs may be lost during disruptions.

> [!NOTE]
>
> When deploying multiple instances, Connectors attempt automatically to form a cluster with shared state. It enables Connectors to coordinate rate limiting across all instances. See the [Clustering](https://docs.formal.ai/docs/guides/core-concepts/connectors/clustering.md) page for details.

### Recommended Deployment Options

> [card] AWS ECS Fargate
>
> Deploy as a Fargate service behind a Network Load Balancer with multi-AZ
> availability

> [card] Kubernetes
>
> Deploy using [Formal Helm charts](https://github.com/formalco/helm-charts) on any Kubernetes cluster (EKS, GKE, AKS, on-premises).

> [card] Docker
>
> Run as a standalone container (development/testing only)

## Environment Variables

The Connector receives most of its configuration from the Control Plane. Set these environment variables on the Connector itself:

| Variable | Type | Required | Description |
| - | - | - | - |
| `FORMAL_CONTROL_PLANE_API_KEY` | String | `true` | API token to authenticate with the Control Plane. You get it when you create the Connector |
| `FORMAL_CONTROL_PLANE_API_HOST` | String | Depends | API URL of the Control Plane. Required with a [self-hosted Control Plane](https://docs.formal.ai/docs/guides/control-plane/overview.md#hosting). Otherwise optional: defaults to `https://api.joinformal.com` |
| `LOG_LEVEL` | String | `false` | Log level: `trace`, `debug`, `info`, `warn`, `error`, `fatal`, `panic` or `disabled`. When unset, the log level configured for the Connector in the Control Plane applies. Defaults to `info` |
| `HEALTH_CHECK_PORT` | Number | `false` | Port that serves the `/health` and `/ready` endpoints. Defaults to `8080` |

### Variables read from the platform

The Connector also reads variables that your platform sets. You do not set them yourself in a standard deployment.

| Variable | Set by | How the Connector uses it |
| - | - | - |
| `ECS_CONTAINER_METADATA_URI_V4` | Amazon ECS | Detects that it runs on ECS. Reads the task ARN and IP address to find the other Connector instances |
| `ECS_CLUSTER` | Amazon ECS | Reports to the Control Plane that the instance runs on ECS |
| `KUBERNETES_SERVICE_HOST` | Kubernetes | Detects that it runs on Kubernetes. Lists the Pods in its namespace to find the other Connector instances |
| `AWS_REGION` | Amazon ECS, or you | Default AWS Region for the AWS SDK calls the Connector makes |
| `KUBECONFIG` | You | Path to the kubeconfig file, used when a Kubernetes native user has the `kubeconfig` authentication type |
| `HOME` | The container | When `KUBECONFIG` is unset, the Connector reads `$HOME/.kube/config` |

The Connector checks `ECS_CONTAINER_METADATA_URI_V4` first, then `KUBERNETES_SERVICE_HOST`. See [Clustering](https://docs.formal.ai/docs/guides/core-concepts/connectors/clustering.md) for how instances find each other.


## Related topics

- [Spaces](https://docs.formal.ai/docs/guides/core-concepts/spaces.md)
- [Keep Credentials Away from Agents](https://docs.formal.ai/docs/guides/use-cases/keep-credentials-from-agents.md)
- [Protect Sensitive Data](https://docs.formal.ai/docs/guides/use-cases/protect-sensitive-data.md)
- [Quickstarts](https://docs.formal.ai/docs/guides/getting-started/quickstarts.md)
- [Listeners and Rules](https://docs.formal.ai/docs/guides/core-concepts/connectors/listeners.md)


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.