I'll focus this answer on the AWS portion of the setup, as OpenVPN configuration steps are widely available. In your case, you are looking for a Site-to-Site OpenVPN configuration from on-prem to AWS. There's a good tutorial on https://openvpn.net/vpn-server-resources/site-to-site-routing-explained-in-detail/ about the OpenVPN-side of the configuration. Some extra details for OpenVPN configuration on AWS can be found on https://stackoverflow.com/a/19976330/891772 (while a bit outdated and old screenshots, most steps are still valid).
Network
You should place your AWS OpenVPN in a "public subnet" (let's call it ovpn-subnet and give it a 192.168.255.0/24
range) on your VPC (https://docs.aws.amazon.com/vpc/latest/userguide/VPC_Scenario3.html). A public subnet is just a subnet where the Route Table's default destination (0.0.0.0/0
) goes to an Internet Gateway. This will allow your AWS OpenVPN sitting on AWS to go out to the internet, and eventually reach out your on-premises IP.
Besides that subnet, you should also have subnet(s) to place your client servers on AWS. Let's call them client-subnet1 (192.168.0.0/24
) and client-subnet2 (192.168.1.0/24
). Note: they can be collectively represented as 192.168.0.0/23
. Make sure your AWS OpenVPN security group allows only traffic from servers on 192.168.0.0/23
, besides from your on-prem OpenVPN.
I'll also assume you have another EC2 instance deployed to the same VPC/subnet as your OpenVPN server, so it makes easier to start testing -- you can start to spread things out after you are confident with your simple setup.
Configuration
The most important thing that you need on your AWS OpenVPN server is to disable the source/destination check. This is a security feature normally enabled on AWS, that prevents an EC2 server to receive packets not intended for that instance. In your case, since the server is acting like a Firewall/Router/Gateway/NAT Gateway, it needs to receive packets not intended to it. In summary: go to your EC2 Console, find your OpenVPN server, select Actions > Networking, Change Source/Dest. Check., and confirm you want to disable it.
The next thing is to configure a Route Table on your VPC that sends traffic to your OpenVPN server. Details are in the same AWS docs, under the "Updating the main route table" item. Just make sure you have a separate Route Table for these clients subnets from the OpenVPN subnet (since you want the OpenVPN traffic to go through Internet, and clients to go through your VPN). For that, you'll go to your VPC Console, select "Route Table", create a new Route Table and associate with the client subnets 1 and 2. Once on you are on the Route Table page, select the "Routes" tab, click "Edit routes" and select to "Add route". The "Destination" field should be filled with the CIDR block for your on-premises network (maybe 10.8.0.0/16
?), for "Target" you should select Instance and then select your OpenVPN instance ID. If your OpenVPN instance is not shown in the list, make sure you followed the disable source/destination checks.
Checkpoint
At this point, you basically created a rule on your VPC's router that says "any packet going to 10.8.0.0/16
network should not be handled within AWS, rather sent to this EC2 instance". It's your role to configure the OpenVPN instance to actually reach your on-premises network.
Test
At this point, you can try to login to your test EC2 instance and communicate with your on-prem services.