Set up a VPN server on an AWS EC2 Instance via a single, self contained, Cloud Formation template.
See aws-ec2-vpn.json for raw template.
Follow the AWS Cloud Formation Guide to create a new Cloud Formation Stack from the aws-ec2-vpn.json template.
You must have the aws-cli as well as jq installed and available in your path.
Additionally, you must set your default AWS credentials to a user with permissions to setup a VPC and launch EC2 instances.
Clone down this repo and execute the setup.sh script with the following input.
$ bash setup.sh YOUR_VPN_PRE_SHARED_KEY YOUR_VPN_USERNAME YOUR_VPN_PASSWORD
Once the setup is complete, the script will return the persistent EIP of the Instance. For example:
$ bash setup.sh MySuperSecretPreSharedKey vpnuser TheVPNUserPassword
VPN Setup in progress.
VPN Setup complete. IP address is '35.164.187.145'.
Under Sytem Preference / Network hit the + button to add a new connection.
Change the Interface to VPN.
Change the VPN Type to L2TP over IPSEC.
Ggive the VPN a name in Service Name.
Click Create.
Add the IP address, which was output from the setup.sh script above, as the Server Address.
The user you specified, as YOUR_VPN_USERNAME in the script above, as the Account Name.
Click on Authentication Settings.
Add the password you specified, as YOUR_PASSWORD in the script above, as the Password.
Add the pre shared key you specified, as YOUR_VPN_PRE_SHARED_KEY in the script above, as the Shared Secret.
Click OK.
Click on Advanced Settings ensure that Send all traffic over VPN connection is checked.
Click OK.
Click on Connect to connect to the VPN.
Ensure your traffic coming from the VPN IP via What Is My IP.
The only charge will be for the EC2 instance hours, currently set to t2.nano, and network bandwidth.
At the time of this writing the instance hours cost under $5.00 USD per month in us-west-2 if the VPN is ran continuously.
See AWS On Demand Pricing for current pricing.