This repository contains Infrastructure as Code (Terraform) to spin up a personal, on-demand WireGuard VPN server on AWS. Deploy your own private VPN in minutes and pay only when you use it.
To create a "dispose-on-demand" VPN solution. We use Terraform to automate the creation and destruction of infrastructure, ensuring you only pay for resources while they are in use.
Before deploying, understand what this VPN is (and isn't) good for:
| The Good (Capabilities) | The Bad (Limitations) |
|---|---|
| Public Wi-Fi Security: Encrypts all traffic. Perfect for airports, hotels, and coffee shops. | Streaming Blocks: Netflix, Hulu, and Disney+ usually block AWS IP addresses. This is not good for watching region-locked movies. |
| Total Privacy: You own the server. No third-party VPN provider logging your data. | Data Costs: AWS charges for outgoing data (~$0.09/GB). Heavy 4K streaming will get expensive quickly. |
| Dispose-on-Demand: Spin it up for a trip, destroy it when home. No monthly subscriptions. | Not "Anonymous": While your ISP can't see your traffic, AWS has your billing details. Not for illegal activities. |
| WireGuard Speed: Uses modern, lightweight protocols for fast connections. | Technical Setup: Requires basic terminal knowledge; not a "one-click" app store experience. |
Important: Do NOT use root user access keys.
- Log into AWS Console and search for IAM.
- Click Users -> Create user.
- Set username:
terraform-deployer. - Select Attach policies directly.
- Search and check: AdministratorAccess.
- Click Next -> Create user.
- Click your new user (
terraform-deployer). - Go to Security credentials -> Access keys -> Create access key.
- Select Command Line Interface (CLI).
- Check the confirmation box and click Next.
- Click Create access key.
- Download the CSV or copy the Access Key ID and Secret Access Key.
Copy the example template and fill in your values:
cp terraform.tfvars.example terraform.tfvarsThen open terraform.tfvars and replace the placeholder values with your credentials and desired settings.
All VPN traffic runs on lightweight instances - no GPU needed.
| Instance Type | vCPUs | RAM | Cost/Hour | Est. Cost/Month (24/7) | Best For |
|---|---|---|---|---|---|
t3.micro (Default) |
2 | 1GB | ~$0.01 | ~$7.20 | Personal use, 1-2 devices |
t3.small |
2 | 2GB | ~$0.02 | ~$14.40 | Family use, 3-5 devices |
t3.medium |
2 | 4GB | ~$0.04 | ~$28.80 | Heavy usage, 6-10 devices |
Default Configuration: t3.micro is perfect for most personal VPN needs.
Choose a region close to you for best performance, or far from you for geo-spoofing. The default is N. Virginia (us-east-1).
Before deploying, ensure you have WireGuard installed on your local machine:
# Install WireGuard
sudo apt update
sudo apt install wireguard wireguard-tools
# Verify installation
wg --versionterraform initAll settings are read from terraform.tfvars - no extra flags needed:
terraform apply -auto-approveAfter deployment, Terraform will generate configuration files for all your devices in the ./vpn-configs/ directory.
The VPN server is configured to support up to 10 devices simultaneously (or whatever max_clients is set to in your terraform.tfvars). Each device gets its own unique configuration file for security.
Use the provided connection script for quick, terminal-based access:
# Connect to VPN (runs in foreground)
sudo ./connect-vpn.sh
# Press Ctrl+C to disconnectWhat the script does:
- Automatically loads the correct WireGuard configuration
- Establishes the VPN tunnel
- Shows connection status
- Disconnects cleanly when you press Ctrl+C
Transfer the configuration file to your Android device:
- Install WireGuard from the Play Store
- Transfer
vpn-configs/client2.confto your phone (via email, cloud, USB) - In the WireGuard app: + -> Import from file or archive
- Select the config file
- Toggle the VPN on
Security Note: Do NOT share config files between devices. Each device should use its own unique configuration.
Available configs after deployment:
vpn-configs/client1.conf- Desktop/laptop primaryvpn-configs/client2.conf- Phonevpn-configs/client3.conf- Tabletvpn-configs/client4.confthroughclient10.conf- Additional devices
Crucial: When finished, destroy resources to stop costs. Settings are read from terraform.tfvars automatically:
terraform destroy -auto-approve- Never share config files - Each device should have its own
- Keep
vpn-configs/directory private - Treat like SSH keys