This guide walks through the process of setting up a Virtual Private Server (VPS) with OpenVPN on Google Cloud Platform (GCP) using Terraform. The provided Terraform script will automate the provisioning of a Google Compute Engine instance, and the installation of OpenVPN server on it. Upon successful execution, a client.ovpn
configuration file will be generated in the user directory, which can be used to connect to the VPN server from a client machine.
- Ensure you have Terraform installed on your machine.
- A Google Cloud Platform (GCP) account with necessary permissions to create resources.
- Git (Optional, for cloning the repository)
Clone the repository containing the Terraform scripts.
git clone https://github.com/kwisser/create-cloud-compute-engine-ovpn-server
cd create-cloud-compute-engine-ovpn-server/infrastructure
Select a suitable zone for deploying the VM instance. The choice of zone can affect the latency and speed of your VPN. You can find a list of available regions and zones on GCP here. For example
europe-west1-b
Navigate to the infrastructure directory and initialize Terraform. This will download the necessary provider plugins.
cd infrastructure
terraform init
Now, plan and apply the Terraform configuration. This will show the resources that will be created and apply the changes, respectively. You will have to enter the following variables
project_id = "your-gcp-project-id"
name = "name-of-your-vm-instance"
machine_type = "f1-micro" # or any other machine type
zone = "us-central1-a" # or any other zone
vm_username = "your-username"
terraform plan
terraform apply
Upon successful execution, a client.ovpn file will be generated in the user directory. This file can be used to connect to the VPN server from a client machine.
The OpenVPN installation script is sourced from angristan/openvpn-install.
For issues, or contributions, feel free to open a pull request or create an issue in the repository.
This setup allows you to have a personal VPN server hosted on GCP with minimal setup. Enjoy secure and private browsing!