/terraform-openvpn

You can have your pay as you go personal VPN in minutes! And you can destroy your environment whenever you want!

Primary LanguageHCLGNU General Public License v3.0GPL-3.0

Terraform OpenVPN

Terraform declarations for Single node OpenVPN infrastructure. You can have your pay as you go personal VPN in minutes! And you can destroy your environment whenever you want!

asciicast

Prerequisites

Terraform v0.11.3

Check your version.

$ terraform -v

Installing

Install Terraform, you can use brew if you're on Mac OS X.

$ brew install terraform

Usage

Make sure you provided AWS credentials to your environment.

You can simply export:

export AWS_ACCESS_KEY_ID=(your access key id)
export AWS_SECRET_ACCESS_KEY=(your secret access key)

Or, you can use something like awsudo if you are using multiple accounts in your system:

$ awsudo -u personal env | grep AWS
AWS_ACCESS_KEY_ID='<jadajada>'
AWS_SECRET_ACCESS_KEY='<blablabla>'

To provision remote machine, Terraform needs to access that machine, for that you have to add your SSH key to your local ssh-agent, so Terraform can find:

$ ssd-add # Adds default ssh key
$ ssd-add ~/.ssh/my-jada-jada-key # Adds a specific ssh key

Then plan your changes:

$ terraform plan

If everything is ok, you should see something like:

after_plan

If everything looks good, you can apply your plan, it will take couple of minutes:

$ terraform apply

If everything is ok, you should see something like:

after_apply

Booom! You did it!

Client Setup

Use generated file with an OpenVPN client. In OS X, you can install one with brew.

$ brew install openvpn

Then,

$ sudo openvpn --config awesome-personal-vpn.ovpn
$ sudo openvpn --config awesome-personal-vpn.ovpn --deaemon # as daemon
$ sudo -b openvpn --config awesome-personal-vpn.ovpn # run in background

If you want a GUI client, you can use Tunnelblick for Mac OS X, with Tunnelblick is installed, just go to your console:

$ open awesome-personal-vpn.ovpn

Available Parameters

If you want to configure your VPN, you can pass following parameters.

$ terraform apply \
   -var "aws_region=JADA" \
   -var "ssh_remote_user=JADA"
   -var "ssh_public_key_path=JADA" \
   -var "vpn_data=JADA" \
   -var "vpn_port=1234" \
   -var "vpn_client_name=JADA"

Your VPN is ready! Have fun!

Built With

Special thanks to @kylemanna for docker-openvpn

Contributing

  1. Fork it!
  2. Create your feature branch: git checkout -b my-new-feature
  3. Commit your changes: git commit -am 'Add some feature'
  4. Push to the branch: git push origin my-new-feature
  5. Submit a pull request

Versioning

We use SemVer for versioning. For the versions available, see the tags on this repository.

Authors

  • Kemal Akkoyun - Initial work - kakkoyun

See also the list of contributors who participated in this project.

License

This project is licensed under the GNU General Public License v3.0 - see the LICENCE file for details