October 14, 2020 By Frederic Lavigne 3 min read

Virtual Private Cloud (VPC) comes with an additional layer of security because your workload can be completely hidden from the public Internet.

There are times, however, when you will want to get into this private network. A common practice is to use a bastion host to jump into your VPC from your local machine, for example. Another option is to install a VPN software inside your VPC to extend the secure VPC network to your local network.

OpenVPN is a popular VPN software solution that can be easily installed on a server, providing a simple way to reach all the servers in your VPC from your local machine.

Source code and instructions on how to deploy a fully functional example of this architecture can be found in GitHub. In this post, I will provide a high-level description of the steps.

Step 1: Deploy the infrastructure with Terraform

We use Terraform to create all the resources depicted above. We provision a VPC, a subnet, and one virtual server instance (the instance is not reachable from the public Internet). Then, we add the bastion. It is another virtual server instance, but it is accessible from the public Internet through a floating IP address. Finally we install OpenVPN on the bastion and connect to our VPN using OpenVPN client.

The set of Terraform files is built around four submodules:

  • vpc: Creates a VPC, a subnet, and rules in the default security group.
  • instance: Creates one (or more) instances in the specified VPC, distributing instances in the subnets.
  • bastion: Creates one host in a specific subnet.
  • ansible: Generates Ansible configuration files.

Step 2: Install software with Ansible

The second step — once the infrastructure is deployed — is to use Ansible to install OpenVPN. With Terraform, we generated the Ansible inventory together with the playbook to install OpenVPN on the bastion host. The rest is about running the right Ansible commands. After running the OpenVPN playbook, we find OpenVPN installed on the bastion and a generated client certificate to connect to the VPN.

Step 3: Connect with the OpenVPN client

Once OpenVPN Connect client is installed, point it to the OpenVPN configuration file generated under the ansible/client-config directory and connect to the VPN. The VPN will push the IBM Cloud private DNS configuration to your local machine, together with the right routes to access all VSIs within the VPC and the cloud service endpoints.

From there, you can connect to virtual server instances and to cloud service endpoints that are usually accessible only from within the IBM Cloud network directly from your local machine.

Feedback, questions, and suggestions

Go ahead and try the sample on your own from the GitHub source. Although the project creates its own VPC, it can be used as a starting point to deploy OpenVPN in your existing VPCs.

If you have feedback, suggestions, or questions about this post, please reach out to me on Twitter (@L2FProd).

Was this article helpful?
YesNo

More from Cloud

The power of embracing distributed hybrid infrastructure

2 min read - Data is the greatest asset to help organizations improve decision-making, fuel growth and boost competitiveness in the marketplace. But today’s organizations face the challenge of managing vast amounts of data across multiple environments. This is why understanding the uniqueness of your IT processes, workloads and applications demands a workload placement strategy based on key factors such as the type of data, necessary compute capacity and performance needed and meeting your regulatory security and compliance requirements. While hybrid cloud has become…

Serverless vs. microservices: Which architecture is best for your business?

7 min read - When enterprises need to build an application, one of the most important decisions their leaders must make is what kind of software development to use. While there are many software architectures to choose from, serverless and microservices architectures are increasingly popular due to their scalability, flexibility and performance. Also, with spending on cloud services expected to double in the next four years, both serverless and microservices instances should grow rapidly since they are widely used in cloud computing environments. While…

Seamless cloud migration and modernization: overcoming common challenges with generative AI assets and innovative commercial models

3 min read - As organizations continue to adopt cloud-based services, it’s more pressing to migrate and modernize infrastructure, applications and data to the cloud to stay competitive. Traditional migration and modernization approach often involve manual processes, leading to increased costs, delayed time-to-value and increased risk. Cloud migration and modernization can be complex and time-consuming processes that come with unique challenges; meanwhile there are many benefits to gen AI assets and assistants and innovative commercial models. Cloud Migration and Modernization Factory from IBM Consulting®…

IBM Newsletters

Get our newsletters and topic updates that deliver the latest thought leadership and insights on emerging trends.
Subscribe now More newsletters