Tutorial: Deploy Access Server on AWS with Terraform⁠

Overview⁠

This tutorial shows you how to deploy OpenVPN Access Server on AWS with the official OpenVPN/openvpn-as-aws-terraform-deploy Terraform configuration.

The Terraform configuration launches an Amazon EC2 instance in an existing VPC and subnet and uses cloud-init during first boot to install and configure Access Server. You provide the AWS networking resources, EC2 key pair, and Access Server administrative credentials.

The default EC2 instance type is t3.small. You can change the instance size with the aws_instance_type Terraform variable.

By default, the deployment also:

  • Allocates a static Elastic IP by setting use_static_public_ip to true.

  • Requests a trusted Let’s Encrypt TLS certificate by setting enable_lets_encrypt to true.

  • Creates the security group required for Access Server.

  • Returns the Admin Web UI and Client Web UI URLs after deployment.

For other AWS deployment and licensing options, refer to Deploy Access Server on AWS — Choose Your Licensing Model.

Use cases⁠

Audience

Use case

Developers

Create repeatable Access Server test environments and tear them down on demand with terraform destroy.

IT administrators and DevOps engineers

Provision Access Server and its supporting AWS infrastructure consistently across environments.

Organizations

Manage Access Server infrastructure as version-controlled, reviewable code.

Where you can run Terraform⁠

You can run this Terraform configuration from:

  • Your workstation: Run Terraform CLI on Windows, macOS, or Linux.

  • On-premises infrastructure: Run Terraform from your own servers, CI/CD pipelines, or virtualization infrastructure.

  • Cloud automation: Run the configuration from HCP Terraform or another CI/CD pipeline with access to your AWS account.

Refer to the Access Server system requirements when selecting an EC2 instance type for your expected workload.

Prerequisites⁠

Before you begin, ensure you have:

  • An AWS account with permissions to create and manage EC2 instances, security groups, and Elastic IP addresses, and permissions to read existing VPC, subnet, and EC2 key pair information.

  • AWS CLI credentials, such as an access key ID and secret access key, or another supported authentication method.

  • Terraform installed on your workstation.

  • The AWS CLI installed.

  • Git installed.

  • An existing VPC and public subnet. The subnet needs a route to an internet gateway so the instance can reach the internet and VPN clients can reach Access Server.

  • An EC2 key pair in the AWS Region where you plan to deploy Access Server.

What the Terraform configuration creates⁠

Resource

Details

EC2 instance

Amazon EC2 instance for Access Server. The default instance type is t3.small.

Access Server

Access Server installed during first boot through cloud-init. The configuration runs apt-mark hold openvpn-as, so normal package upgrades don't automatically update Access Server. Upgrade Access Server separately when you want to move to a newer version.

Security group

AccessServerSecurityGroup, attached to the instance with the required inbound rules.

Elastic IP

Static public IP address when use_static_public_ip is true, which is the default.

Web SSL certificate

Let’s Encrypt certificate requested during first boot when enable_lets_encrypt is true, which is the default.

Network ports⁠

The Terraform security group allows the following inbound traffic. All outbound traffic is allowed.

Port

Protocol

Purpose

943

TCP

Admin Web UI and Client Web UI

443

TCP

Web interfaces and OpenVPN TCP connections

1194

UDP

OpenVPN UDP connections

22

TCP

SSH administration