A streamlined command-line tool to deploy and manage WireGuard VPN servers on AWS using CloudFormation.
- 🌍 Global Deployment: Deploy VPN servers in any AWS region automatically
- ☁️ CloudFormation-Based: Reliable Infrastructure as Code management
- 🔐 WireGuard Protocol: Fast, secure, modern VPN technology
- 🔑 Secure Key Exchange: Uses AWS SSM Parameter Store
- 🧹 Automatic Cleanup: Built-in resource management and error recovery
- 🛡️ Security First: Minimal permissions and secure defaults
- 💰 Cost Effective: Uses t3.micro instances (~$0.0104/hour)
- 🔄 Multi-Region: Automatically uses latest Ubuntu AMI for each region
-
AWS Account: You'll need an AWS account with appropriate permissions
-
AWS CLI configured:
aws configure
Configure with credentials that have CloudFormation, EC2, IAM, and SSM permissions
-
WireGuard installed locally (for automatic connection):
# macOS brew install wireguard-tools # Ubuntu/Debian sudo apt install wireguard # Other systems: https://www.wireguard.com/install/
-
Node.js 18+:
node --version # Should be 18.0.0 or higher -
jq (for JSON parsing in setup scripts):
# macOS brew install jq # Ubuntu/Debian sudo apt install jq
-
Install dependencies:
npm install
-
Test the installation:
npm test -
Validate CloudFormation template:
npm run validate # Test multiple regions npm run validate us-west-2 # Test specific region
-
Make CLI available globally (optional):
npm link
Start the VPN manager:
npm start
# or if linked globally:
vpn- 🚀 Deploy VPN Server: Choose a region and deploy a new VPN server
- 📋 Check Status: View current VPN server and connection status
- 🛑 Disconnect & Cleanup: Terminate the VPN server and clean up resources
- ❌ Exit: Exit the program
- Select an AWS region from the list
- Generate WireGuard encryption keys
- Deploy CloudFormation stack with EC2 instance
- Wait for server setup to complete (2-3 minutes)
- Retrieve server configuration from SSM
- Connect to the VPN automatically (optional)
- Graceful Shutdown: Pressing Ctrl+C disconnects VPN and preserves server
- Error Recovery: Automatic cleanup of failed deployments
- Resource Management: Prevents resource leaks with proper cleanup
- Secure Credentials: No credentials stored on VPN servers
- CloudFormation Deployment: Uses Infrastructure as Code for reliable deployment
- Key Generation: Creates WireGuard key pairs for secure communication
- Stack Creation: Deploys complete infrastructure (EC2, Security Groups, IAM roles)
- SSM Integration: Secure key exchange via AWS Systems Manager Parameter Store
- Auto-Configuration: Server configures itself and signals completion to CloudFormation
- Client Connection: Retrieves server config from SSM and connects automatically
Your AWS credentials need these permissions:
- CloudFormation:
cloudformation:*(for stack management) - EC2:
ec2:*(for instances, security groups, key pairs) - SSM:
ssm:GetParameter,ssm:PutParameter,ssm:DeleteParameter - IAM:
iam:CreateRole,iam:AttachRolePolicy,iam:PassRole
Alternatively, use the PowerUserAccess managed policy for full functionality.
Configuration is stored in .config/config.json and includes:
- Recent regions list
- Auto-termination timeout (default: 1 hour)
- Maximum recent regions to remember (default: 5)
Run aws configure and enter your AWS access key and secret key.
Install WireGuard tools for your operating system. The server will still be created, but automatic connection won't work.
This usually means AMI or region issues:
- Ensure you're using the latest version with dynamic AMI resolution
- Try a different region (some regions may have temporary capacity issues)
- Check AWS service status for your region
Check that your AWS credentials have the required permissions and that the selected region is available.
Wait a few minutes for the server to fully initialize. The user-data script needs time to install and configure WireGuard.
The VPN manager now automatically selects the correct Ubuntu 22.04 LTS AMI for each region using AWS Systems Manager Parameter Store. No manual AMI ID updates needed!
- Instance cost: ~$0.005/hour (t3.nano)
- Data transfer: Standard AWS rates apply
- Auto-termination: Prevents forgotten instances from running indefinitely
- Typical session: Less than $0.01 for a 1-hour VPN session
- Uses WireGuard with modern cryptography (Curve25519, ChaCha20, Poly1305)
- Temporary key pairs generated for each session
- Security groups restrict access to VPN port only
- No persistent credentials stored on servers
- Automatic cleanup prevents resource leaks
If automatic connection fails, you can connect manually:
# The client config is saved to /tmp/vpn-client.conf
sudo wg-quick up /tmp/vpn-client.conf
# To disconnect:
sudo wg-quick down /tmp/vpn-client.confTo remove the AWS IAM user and policy when you're done:
./scripts/cleanup-aws-user.shThis will delete:
- The
vpn-manager-userIAM user - The
VPNManagerPolicypolicy - All associated access keys
./scripts/setup-aws-user.sh- Create IAM user and configure AWS CLI./scripts/verify-aws-setup.sh- Verify all prerequisites are installed./scripts/cleanup-aws-user.sh- Remove IAM user and policynpm test- Test VPN Manager componentsnpm start- Start the VPN Manager CLI
MIT License - see LICENSE file for details.