> ## Documentation Index
> Fetch the complete documentation index at: https://docs.aviatrix.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Using Aviatrix Site2Cloud Tunnels to Access VPC Endpoints in Different Regions

> VPC Endpoints in AWS allow you to expose services to customers and partners over AWS PrivateLink. In situations where allowing resources to be accessed directly from the Internet is undesirable, VPC Endpoints can enable internal VPC connectivity to resources in other accounts.

[VPC Endpoints](https://docs.aws.amazon.com/vpc/latest/userguide/vpce-interface.html)
in AWS allow you to expose services to customers and partners over AWS
PrivateLink. In situations where allowing resources to be accessed directly from
the Internet is undesirable, VPC Endpoints can enable internal VPC connectivity
to resources in other accounts.

One limitation of Endpoints is that it is a regional construct, meaning you
can't use it to provide connectivity to resources across regions. In some cases
it's not possible to move these workloads.

This is where Aviatrix can help overcome that limitation.

The end design will look similar to the diagram below.

<img src="https://mintcdn.com/aviatrix-14b37c43/Y73dDPMr0NB7yfrH/images/guides/connectivity/vpn/vpc-endpoints-diagram.png?fit=max&auto=format&n=Y73dDPMr0NB7yfrH&q=85&s=3596579ca4e9b5a764355d6ad11dd484" alt="VPC Endpoints Diagram" width="1409" height="503" data-path="images/guides/connectivity/vpn/vpc-endpoints-diagram.png" />

## Environment Requirements

In this example there are:

* Two VPCs in US-East-1. One customer/partner VPC (10.10.10.0/24) with an
  Endpoint, and our VPC (10.10.11.0/24) with an Endpoint Service tied to an
  internal Load Balancer.
* One VPC (10.10.12.0/24) in US-East-2 that hosts our workload.
* A set of Aviatrix Gateways: two in Aviatrix VPC in US-East-1, and two in the
  workload VPC in US-East-2. Deploying a set of HA Gateways is documented <a href={"/docs/enterprise/" + "10.1" +
  "/guides/gateways/gateway-ha-about"}>here</a>.

Once deployed, a set of Site2Cloud tunnels will be built. Documentation for
building a tunnel between Aviatrix Gateways is <a href={"/docs/enterprise/" +
"10.1" +
"/guides/connectivity/vpn/s2c-aviatrixgw-to-aviatrixgw"}>here</a>.

They should be built in an active-passive manner to avoid asymmetric routing in
AWS.

## Deploy an Internal Load Balancer in AWS

<Note>
  Before beginning, make sure you have private subnets in your Availability
  Zones. You must select at least two Availability Zones in the following
  procedure that traffic will be routed to, and the subnets in these
  Availability Zones must be private to prevent the receipt of Internet traffic.
</Note>

1. From the EC2 section in the AWS console, choose Load Balancers.

2. Click **Create Network Load Balancer**.

   <img src="https://mintcdn.com/aviatrix-14b37c43/1zOMu4WXCFpEtXhJ/images/guides/connectivity/vpn/create-load-balancer.png?fit=max&auto=format&n=1zOMu4WXCFpEtXhJ&q=85&s=12fd9c2387da152bc4ba2c5c91c67e4d" alt="Create Load Balancer" width="1916" height="594" data-path="images/guides/connectivity/vpn/create-load-balancer.png" />

   <img src="https://mintcdn.com/aviatrix-14b37c43/Gre8pdluiL7JmlpL/images/guides/connectivity/vpn/select-balancer.png?fit=max&auto=format&n=Gre8pdluiL7JmlpL&q=85&s=f09b732b8c487e62e6620d91b119a3a8" alt="Select Balancer" width="959" height="618" data-path="images/guides/connectivity/vpn/select-balancer.png" />

3. Give the load balancer a name.

4. Select the **Internal** Scheme.

5. Select the **IPv4** IP address type.

6. In the Network mapping area, select all the Availability Zones in the
   US-East-1 VPC. Remember that these Availability Zones must contain private
   subnets.

7. In the Listeners and routing area, select Protocol **TCP** and Port **80**.

8. Also in this area, create a new target group using port 80 (this opens a new
   tab in your browser). The target type is 'instance'. Health Checks will be
   TCP-based.

   <img src="https://mintcdn.com/aviatrix-14b37c43/1zOMu4WXCFpEtXhJ/images/guides/connectivity/vpn/config-routing.png?fit=max&auto=format&n=1zOMu4WXCFpEtXhJ&q=85&s=72cf537cb75c0911d57477f4839c14ce" alt="Config Routing" width="755" height="556" data-path="images/guides/connectivity/vpn/config-routing.png" />

9. Click **Next**.

10. On the Register targets page, select the Aviatrix Gateways in our US-East-1
    VPC and move them to Registered Targets.

11. Go back to the Load Balancer creation browser tab. In the Listeners and
    routing area, select the target group you created above.

    <img src="https://mintcdn.com/aviatrix-14b37c43/1zOMu4WXCFpEtXhJ/images/guides/connectivity/vpn/aws-add-targetgroup.png?fit=max&auto=format&n=1zOMu4WXCFpEtXhJ&q=85&s=55febb15b5e02c9a17c4bc5b81f2d8d2" alt="AWS Add Target Group" width="1768" height="858" data-path="images/guides/connectivity/vpn/aws-add-targetgroup.png" />

12. Click **Create load balancer**.

    On the next tab you can view your load balancer.

    <img src="https://mintcdn.com/aviatrix-14b37c43/Gre8pdluiL7JmlpL/images/guides/connectivity/vpn/nlb-created.png?fit=max&auto=format&n=Gre8pdluiL7JmlpL&q=85&s=2d2b39665735f5d6c5c93897913f338f" alt="NLB Created" width="2226" height="724" data-path="images/guides/connectivity/vpn/nlb-created.png" />

### Attach an Endpoint Service to Load Balancer

1. From the VPC dashboard area of the AWS console, click Endpoint Services.

2. Click **Create endpoint service**. The new Load Balancer will be in the list
   as an available Network Load Balancer.

   <img src="https://mintcdn.com/aviatrix-14b37c43/1zOMu4WXCFpEtXhJ/images/guides/connectivity/vpn/create-endpoint.png?fit=max&auto=format&n=1zOMu4WXCFpEtXhJ&q=85&s=fb20f8352b4bb8fffc1aba8a11e16deb" alt="Create Endpoint" width="1270" height="1568" data-path="images/guides/connectivity/vpn/create-endpoint.png" />

3. Enter a name for the endpoint.

4. Ensure that the **Network** Load balancer type is selected.

5. Under Available load balancers, select the load balancer you created.

6. Under Additional settings, select the **Acceptance required** checkbox.

7. Ensure that the **IPv4** supported IP address type is selected.

8. Click **Create**.

The Service ARN will be what our customer uses to register a service in their
VPC.

<img src="https://mintcdn.com/aviatrix-14b37c43/1zOMu4WXCFpEtXhJ/images/guides/connectivity/vpn/endpoint-service.png?fit=max&auto=format&n=1zOMu4WXCFpEtXhJ&q=85&s=782e789ccd4793490ab0f5d0a4b4a33f" alt="Endpoint Service" width="2222" height="756" data-path="images/guides/connectivity/vpn/endpoint-service.png" />

### Create Endpoint in Customer VPC

1. In the VPC area of the AWS console, create a new Endpoint.
2. Enter the ARN from the last step, and select the Customer VPC to expose an
   endpoint in. Once built, the Endpoint DNS names can be used to route traffic.

   <img src="https://mintcdn.com/aviatrix-14b37c43/1zOMu4WXCFpEtXhJ/images/guides/connectivity/vpn/endpoints-vpc.png?fit=max&auto=format&n=1zOMu4WXCFpEtXhJ&q=85&s=2607d38d0c848681918b8f565197eb80" alt="Endpoint VPC" width="1990" height="1408" data-path="images/guides/connectivity/vpn/endpoints-vpc.png" />

## Configure Destination NAT rules on Aviatrix Gateway

A Destination NAT (DNAT) rule sends traffic from our VPC in US-East-1 to the
workload VPC in US-East-2.

1. In Aviatrix CoPilot, click the name of the gateway associated with the VPC
   you created in US-East-1.

2. On the Settings tab, expand the Network Address Translation (NAT) area.

3. Turn **On** Destination NAT.

4. Select the instance (not the HA instance).

5. Add a new rule with the following values:
   * Src (Source) CIDR: 10.10.11.0/24 (source of US-East-1 VPC)
   * Dst (Destination) CIDR: private IP of primary gateway
   * Dst (Destination) Port: 80
   * Protocol: TCP
   * Connection: None
   * DNAT IP: 10.10.12.69 (workload VPC available via Site2Cloud tunnel)
   * DNAT port: 80

6. Click **Save**.

7. Turn **On** Apply Route Entry to commit the rule.

8. Select the HA instance and repeat steps 4-6 to create a second rule for
   updating the Destination CIDR to point to the private IP of the HA gateway.

## Test Connections

Ensure health checks on your internal Load Balancer are healthy. Network
Security Groups on your workload VPC (10.10.12.0/24) allow traffic from the
Aviatrix VPC in US-East-1 (10.10.11.0/24).

Only one tunnel will be active in our scenario, and Aviatrix will update the
route tables to point to the active tunnel.

A simple way to test connectivity is to edit the /etc/hosts file on a Linux
instance to point to one of the DNS entries from the Endpoint in the Customer
VPC.
