> ## 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.

# Transit Gateway Peering over Public Network Workflow

> Aviatrix Transit Gateway peering over public network expands Aviatrix Transit Gateway peering across multicloud where the connection between cloud service providers is over the internet.

Aviatrix Transit Gateway peering over public network expands Aviatrix Transit
Gateway peering across multicloud where the connection between cloud service
providers is over the internet. The Aviatrix Controller builds multiple tunnels
between the peered transit gateways using High Performance Encryption (HPE)
Mode, enabling high performance data throughput and data security.

For more information about Multicloud Transit Gateway encrypted peering, see the
following documents:

* <a href={"/docs/enterprise/" + "10.1" + "/guides/connectivity/peering/transit-gateway-peering-workflow"}>Aviatrix Transit Gateway Peering</a>
* <a href={"/docs/enterprise/" + "10.1" + "/concepts-architectures/architecture/connectivity/multi-cloud-design-patterns"}>Transit Network Design Patterns</a>
* <a href={"/docs/enterprise/" + "10.1" + "/guides/connectivity/transit/transitvpc-workflow"}>Multicloud Transit Network Workflow Instructions (AWS/Azure/GCP/OCI)</a>

## Topology

<img src="https://mintcdn.com/aviatrix-14b37c43/xzfnEI4Ko3Ysw6na/images/guides/connectivity/peering/transit-gateway-peering-over-internet.png?fit=max&auto=format&n=xzfnEI4Ko3Ysw6na&q=85&s=9a51bfe8030c7688ca2a92c924cc2091" alt="transit_gateway_peering_over_internet_topology" width="2340" height="1700" data-path="images/guides/connectivity/peering/transit-gateway-peering-over-internet.png" />

## Prerequisites

1. Upgrade Aviatrix Controller to the latest version. Refer to
   <a href={"/docs/enterprise/" + "10.1" + "/guides/maintenance/controller-upgrade-workflow"}>Upgrading the Aviatrix Cloud Network Platform</a>
   .
2. Create and launch the Aviatrix Transit Gateways with HA and High Performance
   Encryption Mode enabled in the clouds where you want to establish peered
   transit connection and attach the Spoke Gateways to the Transit Gateways.
   Refer to
   <a href={"/docs/enterprise/" + "10.1" + "/guides/connectivity/transit/transitvpc-workflow"}>Multicloud Transit Network Workflow Instructions (AWS/Azure/GCP/OCI)</a>
   .

<Note>
  * The Aviatrix Transit Gateway peering over public network solution requires HPE
    (High-Performance Encryption). Aviatrix Transit Gateways must have HPE enabled
    when the Transit Gateway is created for peered connection over the internet.
  * This solution requires ActiveMesh 2.0. To migrate to ActiveMesh 2.0, refer to
    <a href={"/docs/enterprise/" + "10.1" + "/concepts-architectures/components/connectivity/activemesh-about#migrating-to-activemesh-2-0"}>Migrating to ActiveMesh 2.0</a>
    .
</Note>

## Establishing Transit Gateway Peering over Public Internet

Before you begin, review [Prerequisites](#prerequisites) for transit gateway peering over public network.

The steps to establish transit gateway peering across cloud service providers over the public network are as follows:

<Tabs>
  <Tab title="CoPilot UI" icon="mouse-pointer">
    To establish transit gateway peering across cloud service providers over
    the public network using the CoPilot UI, follow these steps:

    <Steps>
      <Step title="Navigate to the Transit Gateways">
        In Aviatrix CoPilot, go to **Cloud Fabric** > **Gateways** > **Transit Gateways**.
      </Step>

      <Step title="Edit the Transit Gateway">
        Click the edit <img src="https://mintcdn.com/aviatrix-14b37c43/VY6W0iTAMUQkrobS/images/security/edit-icon.png?fit=max&auto=format&n=VY6W0iTAMUQkrobS&q=85&s=d37797a7c48eefc52ed6e66ccf9915bf" alt="edit icon" className="inline-icon" width="21" height="26" data-path="images/security/edit-icon.png" /> icon next to one of the Transit Gateways created in this workflow.
      </Step>

      <Step title="Select the Transit Gateways to Peer">
        In the **Attach To Transit Gateways** field, select the Transit Gateways to peer with your selected Gateway.
      </Step>

      <Step title="Save the Configuration">
        Click **Save**.
      </Step>
    </Steps>

    The Transit Gateways are now peered together.
  </Tab>

  <Tab title="Terraform" icon="file-code">
    To establish transit gateway peering across cloud service providers over the public network using the [Aviatrix Terraform provider](https://registry.terraform.io/providers/AviatrixSystems/aviatrix/latest), follow these steps:

    <Steps>
      <Step title="Get the Transit Gateway Names">
        Use the `aviatrix_transit_gateway` data source to retrieve the names of the existing transit gateways. The data source block checks if the transit gateway exists before creating the peering between them and helps to avoid errors.

        ```hcl theme={null}
        data "aviatrix_transit_gateway" "csp1_transit_gateway" {
          # Replace csp1_transit_gateway_name with the name of the transit gateway
          gw_name = "csp1_transit_gateway_name"
        }

        data "aviatrix_transit_gateway" "csp2_transit_gateway" {
          # Replace csp2_transit_gateway_name with the name of the transit gateway
          gw_name = "csp2_transit_gateway_name"
        }
        ```
      </Step>

      <Step title="Create the Transit Gateway Peering">
        Use the `aviatrix_transit_gateway_peering` resource block to create the peering. Reference the retrieved transit gateway names in the data source block to create dependency between the two data source blocks and the resource block.

        The following code snippet creates the peering between the two Transit Gateways over public network.

        ```hcl theme={null}
        resource "aviatrix_transit_gateway_peering" "transit_gateway_peering" {
          transit_gateway_name1 = data.aviatrix_transit_gateway.csp1_transit_gateway.gw_name
          transit_gateway_name2 = data.aviatrix_transit_gateway.csp2_transit_gateway.gw_name
        }
        ```
      </Step>

      <Step title="Verify and Apply the Configuration">
        Run `terraform plan`, review the planned changes, and then run `terraform apply` to make the changes.
      </Step>
    </Steps>

    ### Examples

    The following examples establish Transit Gateway peering over the public network using the Aviatrix Terraform provider.

    <AccordionGroup>
      <a id="aws-to-azure-peering-example" />

      <Accordion title="AWS-to-Azure Peering for a European Multicloud Hub">
        A European business runs its line-of-business app on Azure in `West Europe` and a customer-data service on AWS in `eu-west-1`. There is no ExpressRoute or Direct Connect between the two clouds, so the two Transit Gateways are peered over the public network using HPE for encrypted line-rate east-west traffic.

        ```hcl theme={null}
        data "aviatrix_transit_gateway" "transit_aws" {
          gw_name = "transit-aws-euw1"
        }

        data "aviatrix_transit_gateway" "transit_azure" {
          gw_name = "transit-azure-weu"
        }

        resource "aviatrix_transit_gateway_peering" "aws_to_azure" {
          transit_gateway_name1 = data.aviatrix_transit_gateway.transit_aws.gw_name
          transit_gateway_name2 = data.aviatrix_transit_gateway.transit_azure.gw_name
        }
        ```
      </Accordion>

      <a id="aws-multi-region-dr-peering-example" />

      <Accordion title="AWS Multi-Region DR Peering with Excluded CIDRs and TGW Connections">
        An organization runs an active-active deployment across AWS `us-east-1` and `us-west-2`, and uses public-network peering between the two Aviatrix Transit Gateways for cross-region failover (Disaster Recovery). Each region also has its own AWS Transit Gateway attached to on-prem over Direct Connect, and two things are excluded from the Aviatrix peering:

        * A shared-services CIDR (`10.0.0.0/24`) that both regions already learn from on-prem. Excluding it prevents the peer from re-advertising a route that should only enter the fabric from on-prem.
        * The region-local AWS TGW connection toward on-prem (`onprem-dx-use1` / `onprem-dx-usw2`). Excluding it stops on-prem traffic from looping through the cross-region peer.

        ```hcl theme={null}
        data "aviatrix_transit_gateway" "transit_aws_use1" {
          gw_name = "transit-aws-use1"
        }

        data "aviatrix_transit_gateway" "transit_aws_usw2" {
          gw_name = "transit-aws-usw2"
        }

        resource "aviatrix_transit_gateway_peering" "aws_use1_to_usw2" {
          transit_gateway_name1 = data.aviatrix_transit_gateway.transit_aws_use1.gw_name
          transit_gateway_name2 = data.aviatrix_transit_gateway.transit_aws_usw2.gw_name

          gateway1_excluded_network_cidrs = ["10.0.0.0/24"]
          gateway2_excluded_network_cidrs = ["10.0.0.0/24"]

          gateway1_excluded_tgw_connections = ["onprem-dx-use1"]
          gateway2_excluded_tgw_connections = ["onprem-dx-usw2"]
        }
        ```

        <Note>
          `gateway1_excluded_tgw_connections` and `gateway2_excluded_tgw_connections` apply only to AWS Transit Gateway attachments. If one side of the peering is not AWS, set the argument only on the AWS side.
        </Note>
      </Accordion>

      <a id="three-cloud-mesh-peering-example" />

      <Accordion title="Three-Cloud Mesh: AWS, Azure, and GCP">
        A SaaS provider runs front-end services on AWS, identity and licensing on Azure, and analytics on GCP. The three Aviatrix Transit Gateways are peered in a full mesh over the public internet so every Spoke can reach every other Spoke without hairpinning through a single hub.

        ```hcl theme={null}
        data "aviatrix_transit_gateway" "transit_aws" {
          gw_name = "transit-aws-euw1"
        }

        data "aviatrix_transit_gateway" "transit_azure" {
          gw_name = "transit-azure-weu"
        }

        data "aviatrix_transit_gateway" "transit_gcp" {
          gw_name = "transit-gcp-euw1"
        }

        resource "aviatrix_transit_gateway_peering" "aws_azure" {
          transit_gateway_name1 = data.aviatrix_transit_gateway.transit_aws.gw_name
          transit_gateway_name2 = data.aviatrix_transit_gateway.transit_azure.gw_name

        }

        resource "aviatrix_transit_gateway_peering" "aws_gcp" {
          transit_gateway_name1 = data.aviatrix_transit_gateway.transit_aws.gw_name
          transit_gateway_name2 = data.aviatrix_transit_gateway.transit_gcp.gw_name

        }

        resource "aviatrix_transit_gateway_peering" "azure_gcp" {
          transit_gateway_name1 = data.aviatrix_transit_gateway.transit_azure.gw_name
          transit_gateway_name2 = data.aviatrix_transit_gateway.transit_gcp.gw_name


        }
        ```
      </Accordion>
    </AccordionGroup>
  </Tab>
</Tabs>

***

## Viewing the Peering Connections

You can view the peering connections by clicking the name of the Transit Gateway, clicking the **Attachments** tab, and then clicking **Transit-Transit Peering**. This tab also displays the Connection Status for the peered Gateways. The Status may take a few minutes to update.

<img src="https://mintcdn.com/aviatrix-14b37c43/xzfnEI4Ko3Ysw6na/images/guides/connectivity/peering/transit-gateway-peering-status.png?fit=max&auto=format&n=xzfnEI4Ko3Ysw6na&q=85&s=b949f7daf1b3b1f3784a4f51a8c5c567" alt="Transit gateway peering connection status in CoPilot" width="1988" height="618" data-path="images/guides/connectivity/peering/transit-gateway-peering-status.png" />

## Related Topics

* [Aviatrix Terraform provider documentation](https://registry.terraform.io/providers/AviatrixSystems/aviatrix/latest/docs)
* <a href={"/docs/enterprise/" + "10.1" + "/guides/connectivity/peering/transit-gateway-peering-workflow#excluded-network-cidrs"}>Excluded Network CIDRs</a>
* <a href={"/docs/enterprise/" + "10.1" + "/guides/connectivity/peering/transit-gateway-peering-workflow#excluded-tgw-connections"}>Excluded TGW Connections</a>
