Browse the Repo

file-type-icon.circleci
file-type-icon.github
file-type-icon.patcher
file-type-iconexamples
file-type-iconopenvpn-host-duo
file-type-iconopenvpn-host
file-type-iconpacker-duo
file-type-iconpacker
file-type-iconREADME.md
file-type-iconbuild.json
file-type-iconmodules
file-type-icontest
file-type-icon.gitignore
file-type-icon.pre-commit-config.yaml
file-type-iconCODEOWNERS
file-type-iconLICENSE.txt
file-type-iconREADME.md
file-type-iconterraform-cloud-enterprise-private-module-...

Browse the Repo

file-type-icon.circleci
file-type-icon.github
file-type-icon.patcher
file-type-iconexamples
file-type-iconopenvpn-host-duo
file-type-iconopenvpn-host
file-type-iconpacker-duo
file-type-iconpacker
file-type-iconREADME.md
file-type-iconbuild.json
file-type-iconmodules
file-type-icontest
file-type-icon.gitignore
file-type-icon.pre-commit-config.yaml
file-type-iconCODEOWNERS
file-type-iconLICENSE.txt
file-type-iconREADME.md
file-type-iconterraform-cloud-enterprise-private-module-...
OpenVPN

OpenVPN

Deploy an OpenVPN server. Supports auto healing, public key infrastructure (PKI), cert backup, and managing user accounts using IAM groups.

Code Preview

Preview the Code

mobile file icon

README.md

down

Open VPN example AMI

This folder contains an example Packer template for building an AMI (Amazon Machine Image) containing the OpenVPN server.

Pre-requisites:

In order to build this AMI you will need to provide some input variables. There are several variables but the most important ones are:

  • In which AWS region should Packer build your AMI
  • Where should Packer look for a copy of the openvpn-admin binary that you will use to manage your VPN certificates. If you haven't built this before, take a look at it's documentation for steps on how to build it. Remember: When building openvpn-admin for use in this packer template, keep in mind the OS and architecture where this will be deployed and not the OS/architecture of the machine that's building openvpn-admin. E.g., if you're firing up an EC2 Instance that runs Linux, you'll need to build the binary for Linux, even if you happen to be running the build on a Mac.

All variables below:

Variable name Description Default Value
active_git_branch The git branch to use for gruntwork-install. null
aws_region Tells Packer in which AWS region to build your AMI us-east-1
github_oauth_token Your github OAuth token. env.GITHUB_OAUTH_TOKEN
openvpn_admin_binary Where should Packer look for a copy of the openvpn-admin binary that you will use to manage the VPN certificates on your VPN server. See: openvpn-admin for more info. /examples/bin/openvpn-admin
gruntwork_installer_version What version of Gruntwork Installer to use v0.0.20
bash_commons_version What version of bash-commons to use v0.0.6

Building an AMI using the Packer templates

To build the desired Packer template, see the following example command:

aws-vault exec <IAM USER> -- packer build \
        -var active_git_branch=master \
        -var aws_region=eu-west-2 \
        -var openvpn_admin_binary=./openvpn-admin_linux_amd64 \
        -only=ubuntu-20-build \
        ./examples/packer/build.json

Please note a few details about the command above:

  • it requires the openvpn-admin binary being provided
    • ⚠️ Make sure the format of the openvpn-admin binary needs to be executable by the OpenVPN server OS. For example for EC2 Instances running Ubuntu, the format that would be appropriate is openvpn-admin_linux_amd64.
      cd ./../../modules/openvpn-admin/src
      GOOS=linux GOARCH=amd64 go build .
      
    • For production builds, you can use gruntwork-install to install the binary:
    gruntwork-install --binary-name openvpn-admin --repo "$openvpn_repo" --tag "$package_openvpn_version"
    
  • it requires the active_git_branch
  • it uses the only flag that allows you to execute one specific builder with the given name.
    • This parameter can be ommitted if the packer template has only one builder defined in it. Or alternatively, Packer will build all that is specified in the packer/build.json file.

Questions? Ask away.

We're here to talk about our services, answer any questions, give advice, or just to chat.

Ready to hand off the Gruntwork?