This is a Terraform project that creates an EC2 instance running a WireGuard VPN server on AWS. The ./wg-server start
script can be used to start the VPN, while ./wg-server stop
can be used to stop the server.
To start the VPN, run the following command:
./wg-server start
This will create the EC2 instance using Terraform, configure the WireGuard VPN server, and generate a client configuration file. The client configuration file will be saved locally at /etc/wireguard/wg0.conf
. After that the script automatically connects with the VPN. U can change this behavior in start.sh
To stop the VPN, run the following command:
./wg-server stop
This will destroy the EC2 instance created by Terraform.
Create a symbolic link to your PATH.
ln -s "$(pwd)/wg-server" ~/.local/bin/
This command will allow you to execute the wg-server file from anywhere in your terminal, simply by typing wg-server.
Note that running ./wg-server start
will not only create the EC2 instance, but also configure and start the WireGuard client on your local machine using the configuration file generated by the script. If you do not want this behavior or would like to change the location where the configuration file is stored, you can modify the start.sh
and stop.sh
scripts to fit your needs.
- Terraform
- AWS CLI with credentials
- WireGuard client
"Please note that this project uses AWS resources, which may result in charges to your AWS account. It is important to monitor your usage and costs to avoid unexpected charges. For more information on AWS pricing, please refer to the AWS website."