---
title: Enabling VPN-only access
slug: hosty/enabling-vpn-only-access
createdAt: 2026-11-08T11:27:49.007Z
---

A new cluster has its Kubernetes API open to the internet, because OpenTofu has to reach it before the VPN exists. Once the cluster works, close the API, so that it's reachable only through the VPN of the cluster. We strongly recommend it.

VPN-only access closes the API of the cluster, not the sites. The sites stay public. The VPN only carries the traffic to the VPC of the cluster, and the rest of the internet traffic of your computer goes as usual. Everyone who runs Hosty CLI, kubectl, Helm or OpenTofu against the cluster needs the VPN: admins, developers and CI.

:::hint{type="info"}
If you can't use the VPN, at least limit the API to IP ranges you trust, such as the ones of your company VPN, with `cluster_endpoint_public_access_cidrs` in the block of the cluster in `main.tf`.
:::

## 1. Connect to the VPN

1. Install [OpenVPN Connect](https://openvpn.net/client/), or another OpenVPN client.
2. In the AWS Console, open **S3** > the bucket `vpn.<hosted zone>`, and download your VPN profile `<username>.<cluster>.ovpn`. Keep it safe: anyone with this file can connect to the VPN.
3. Import the file into the VPN client, for example by dragging it into OpenVPN Connect, and connect.
4. Check that you can reach the cluster:

   ```bash
   kubectl get nodes
   ```

## 2. Close the API

In `terraform/main.tf`, find the block of the cluster, `module "cluster_<cluster>"`, and change the access settings to:

```hcl
module "cluster_<cluster>" {
  # ...
  cluster_endpoint_public_access = false
  #cluster_endpoint_public_access       = true
  #cluster_endpoint_public_access_cidrs = ["0.0.0.0/0"]
  # ...
}
```

Stay connected to the VPN, and apply:

```bash
cd /src/terraform
tofu apply
```

EKS takes a few minutes to apply the change.

## 3. Check it

Disconnect from the VPN: `kubectl get nodes` should now fail with a timeout. Connect again, and it should work.

## Next steps

- Give the developers their VPN profiles, as described in [Adding a new user](https://wiki.systemseed.com/hosty/adding-a-new-user).
- CI pipelines connect to the VPN too, with the profile of their release manager. See [CI/CD configuration](https://wiki.systemseed.com/hosty/cicd-configuration).
- A VPN connection lasts at most 12 hours. After that, the client has to connect again.

To open the API again, for example before deleting the cluster, see [Disabling VPN-only access](https://wiki.systemseed.com/hosty/disabling-vpn-only-access).
