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

# Creating a VXC between an MCR and AWS with the API

> This help topic describes how to use the Megaport API to create a VXC between a Megaport Cloud Router (MCR) and AWS Direct Connect.

This topic describes the API procedure to create a VXC from an MCR to AWS Direct Connect, including how to look up AWS interconnect locations and order VXCs.

You can set up two types of AWS connections from an MCR; an AWS Hosted VIF and an AWS Hosted Connection.

* **Hosted VIF** – Connects to public or private AWS cloud services. Hosted VIFs are fully integrated with AWS and provide access to routing information for automatic configuration of your MCR BGP peering.

* **Hosted Connection** – Supports one private, public, or transit virtual interface. The Hosted Connection configuration process does not have automatic access to routing information for the MCR, so you need to configure routing manually and specify BGP peering details on both the AWS virtual interface and the MCR A-End configuration.

The MCR to AWS deployment includes these tasks:

1. **Look up AWS port location details**

   To create a VXC to AWS, you first need to identify the `productUid` of the AWS port to which you want to connect.

2. **Create and deploy a VXC**

   With the port details identified, you can create the VXC to AWS from the MCR.

Before you begin, obtain a valid access token. For more information, see [Creating an API Key](/api/api-key).

## Look up AWS port location details

Use the API to look up the `productUid` of the AWS port you want to connect to. The response includes details of the available ports. You need the port details to create the VXC.

The `connectType` indicates the type of connection:

* `AWS` – Hosted VIF
* `AWSHC` – Hosted Connection

**To look up AWS port location details**

1. Make a GET request to the Partner Megaports endpoint.

   ```http theme={"theme":{"light":"github-light-high-contrast","dark":"github-dark-high-contrast"}}
   GET {baseUrl}/v2/dropdowns/partner/megaports
   ```

   This request returns all the interfaces Megaport has with Cloud Service Providers (CSPs). In the response, locate the required port by searching on location, data center, or other parameter.

   You can filter the results by `connectType` and `vxcPermitted`.

   For Hosted VIF connections:

   ```http theme={"theme":{"light":"github-light-high-contrast","dark":"github-dark-high-contrast"}}
   GET {baseUrl}/v2/dropdowns/partner/megaports?connectType=AWS&vxcPermitted=true
   ```

   For Hosted Connections:

   ```http theme={"theme":{"light":"github-light-high-contrast","dark":"github-dark-high-contrast"}}
   GET {baseUrl}/v2/dropdowns/partner/megaports?connectType=AWSHC&vxcPermitted=true
   ```

   In the response, available ports that accept VXCs are listed as `"vxcPermitted": true`.

Here is a sample response for a Hosted VIF port in the EU (Ireland) region:

```json theme={"theme":{"light":"github-light-high-contrast","dark":"github-dark-high-contrast"}}
{
    "connectType": "AWS",
    "productUid": "6cc21ccb-5ecc-4869-ab0e-b3fa17f5110f",
    "vxcPermitted": true,
    "companyUid": "623cb950-abb4-4b07-b372-8cf55756c322",
    "companyName": "AWS",
    "title": "EU (Ireland) (eu-west-1)",
    "locationId": 96,
    "speed": 10000,
    "rank": 61,
    "lag_id": 2,
    "lag_primary": true,
    "aggregation_id": 54188
}
```

Here is a sample response for a Hosted Connection port with diversity zone information:

```json theme={"theme":{"light":"github-light-high-contrast","dark":"github-dark-high-contrast"}}
{
    "connectType": "AWSHC",
    "productUid": "f274bd09-1796-43af-8837-28fa4fa2a1ab",
    "vxcPermitted": true,
    "companyUid": "605cb850-dfb4-4a05-a171-8bf17757b3a2",
    "companyName": "AWS",
    "title": "US West (Oregon) (us-west-2) [DZ-RED]",
    "locationId": 57,
    "speed": 10000,
    "rank": 275,
    "lag_id": 5,
    "lag_primary": true,
    "aggregation_id": 106462
}
```

<Note>
  \[DZ-RED] and \[DZ-BLUE] indicate diversity zones. Each AWS Hosted Connection site provides two diversity zones to provide redundancy.
</Note>

## Creating a VXC with a Hosted VIF

With the port details from the **GET Partner Megaports** endpoint, you can create a VXC with a Hosted VIF. For Hosted VIF connections, Megaport can set up the IP addressing and BGP details on both the MCR and the AWS side, ensuring a working BGP setup.

This autoconfiguration is triggered when the `interfaces` key in `partnerConfig` does not exist or is null.

**To create the VXC**

1. Create a request with this URL:

   ```http theme={"theme":{"light":"github-light-high-contrast","dark":"github-dark-high-contrast"}}
   POST {baseUrl}/v3/networkdesign/buy
   ```

   <Tip>
     To test your request before you order, you can use:
     `POST {baseUrl}/v3/networkdesign/validate`
   </Tip>

2. Create the Body of the request with the configuration details.

### Hosted VIF with autoconfiguration

Use this template to create a Hosted VIF with automatic BGP configuration. The `interfaces` key is omitted, which triggers autoconfiguration:

```json hl_lines="4 11 15 16" theme={"theme":{"light":"github-light-high-contrast","dark":"github-dark-high-contrast"}}
[
 {
   "productUid": "{ mcrid }",
   "associatedVxcs": [
     {
       "productName": "Test AWS VIF MCR VXC",
       "rateLimit": "100",
       "aEnd": {
         "vlan": 101
       },
       "bEnd": {
         "productUid": "6cc21ccb-5ecc-4869-ab0e-b3fa17f5110f",
         "vlan": 0,
         "partnerConfig": {
           "connectType": "AWS",
           "type": "private",
           "asn": 133937,
           "amazonAsn": 64555,
           "ownerAccount": "{ AWSAccount }",
           "authKey": "123455",
           "customerIpAddress": null,
           "amazonIpAddress": null
         }
       }
     }
   ]
 }
]
```

The `type` field specifies the VIF type:

* `private` – Access private AWS services such as a VPC, EC2 instances, load balancers, and RDS DB instances on private IP address space.
* `public` – Access public AWS services such as Amazon S3, DynamoDB, CloudFront, and Glacier. You will also receive Amazon's global IP prefixes.

### Hosted VIF with manual configuration

If you need more control over the BGP configuration, you can specify the `interfaces` array in the A-End `partnerConfig`:

```json {3,12-31,35,36} theme={"theme":{"light":"github-light-high-contrast","dark":"github-dark-high-contrast"}}
[
    {
        "productUid": "{ mcrid }",
        "associatedVxcs": [
            {
                "productName": "AWS VIF with Manual BGP",
                "rateLimit": 100,
                "term": 12,
                "shutdown": false,
                "aEnd": {
                    "vlan": 0,
                    "partnerConfig": {
                        "connectType": "VROUTER",
                        "interfaces": [
                            {
                                "ipAddresses": ["10.191.0.25/29"],
                                "bgpConnections": [
                                    {
                                        "peerAsn": 64555,
                                        "localIpAddress": "10.191.0.25",
                                        "peerIpAddress": "10.191.0.26",
                                        "password": "yourBGPpassword",
                                        "shutdown": false,
                                        "description": "BGP to AWS",
                                        "bfdEnabled": true
                                    }
                                ]
                            }
                        ]
                    }
                },
                "bEnd": {
                    "productUid": "6cc21ccb-5ecc-4869-ab0e-b3fa17f5110f",
                    "partnerConfig": {
                        "name": "awshc",
                        "connectType": "AWS",
                        "type": "private",
                        "ownerAccount": "{ yourAWSAccountNumber }",
                        "asn": 65105,
                        "amazonAsn": 64555,
                        "authKey": "yourBGPpassword",
                        "customerIpAddress": "10.191.0.25/29",
                        "amazonIpAddress": "10.191.0.26/29"
                    }
                }
            }
        ]
    }
]
```

### B-End partnerConfig fields for Hosted VIF

| **Field**         | **Description**                                           | **Required** |
| ----------------- | --------------------------------------------------------- | ------------ |
| name              | The name of the virtual interface in the AWS console.     | No           |
| connectType       | The connection type. Use `AWS` for Hosted VIF.            | Yes          |
| type              | The VIF type: `private` or `public`.                      | Yes          |
| ownerAccount      | Your 12-digit AWS account number.                         | Yes          |
| asn               | The ASN for your network (Customer ASN).                  | No           |
| amazonAsn         | The ASN of the AWS gateway.                               | No           |
| authKey           | The shared key used to authenticate the BGP peer.         | No           |
| customerIpAddress | The IP address on your network for peering (CIDR format). | No           |
| amazonIpAddress   | The IP address on the AWS side for peering (CIDR format). | No           |
| prefixes          | IP prefixes to announce to AWS (for public VIFs only).    | No           |

## Creating a VXC with a Hosted Connection

Hosted Connections support private, public, and transit virtual interfaces. Because Hosted Connections do not have automatic access to routing information, you need to configure BGP peering details manually.

**To create the VXC**

1. Create a request with this URL:

   ```http theme={"theme":{"light":"github-light-high-contrast","dark":"github-dark-high-contrast"}}
   POST {baseUrl}/v3/networkdesign/buy
   ```

   <Tip>
     To test your request before you order, you can use:
     `POST {baseUrl}/v3/networkdesign/validate`
   </Tip>

2. Create the Body of the request with the configuration details.

Use this template to create a Hosted Connection:

```json {3,13-38,41,44,45,46} theme={"theme":{"light":"github-light-high-contrast","dark":"github-dark-high-contrast"}}

[
 {
   "productUid": "{ mcrid }",
   "associatedVxcs": [
     {
       "rateLimit": 100,
       "productName": "awshc",
       "term": 12,
       "shutdown": false,
       "aEnd": {
         "locationId": 96,
         "vlan": 0,
         "partnerConfig": {
           "connectType": "VROUTER",
           "interfaces": [
             {
               "ipAddresses": [
                 "10.191.0.27/29"
               ],
               "bgpConnections": [
                 {
                   "peerAsn": 62511,
                   "localIpAddress": "10.191.0.27",
                   "peerIpAddress": "10.191.0.28",
                   "password": "cnn23049asdkfj",
                   "shutdown": false,
                   "description": "BGP without MED or BFD",
                   "medIn": null,
                   "medOut": null,
                   "bfdEnabled": false
                 }
               ],
               "natIpAddresses": []
             }
           ]
         }
       },
       "bEnd": {
         "locationId": 89,
         "ownerUid": "{ ownerUid }",
         "productUid": "f274bd09-1796-43af-8837-28fa4fa2a1ab",
         "vlan": 0,
         "partnerConfig": {
           "name": "awshc",
           "ownerAccount": "{ AWSAccount }",
           "connectType": "AWSHC"
         }
       },
       "productType": "VXC",
       "connectType": "AWSHC"
     }
   ]
 }
]

```

### B-End partnerConfig fields for Hosted Connection

| **Field**    | **Description**                                         | **Required** |
| ------------ | ------------------------------------------------------- | ------------ |
| name         | The name of the connection in the AWS console.          | No           |
| ownerAccount | Your 12-digit AWS account number.                       | Yes          |
| connectType  | The connection type. Use `AWSHC` for Hosted Connection. | Yes          |

## Static routes and BGP connections

You can create static routes and BGP connections per interface by adding `ipRoutes` and `bgpConnections` arrays to the interfaces array of the A-End partner configuration object.

For detailed information about configuring static routes and BGP connections, including field descriptions and examples, see [Creating an MCR VXC with the API](/api/api-mcr-vxc-csp).

## Example successful order response

Here is a sample response for a successful Hosted VIF order:

```json theme={"theme":{"light":"github-light-high-contrast","dark":"github-dark-high-contrast"}}
{
    "message": "VXC [47d6cc4d-6a1a-4301-b06c-cebb5f9b8f3e] created.",
    "terms": "This data is subject to the Acceptable Use Policy https://www.megaport.com/legal/acceptable-use-policy",
    "data": [
        {
            "createDate": 1588868593704,
            "vxcOrderId": 42328,
            "payerMegaPortId": 68124,
            "nonPayerMegaPortId": 52786,
            "payerMegaPortName": "MCR",
            "nonPayerMegaPortName": "EU (Ireland) (eu-west-1)",
            "payerCompanyId": 2278,
            "nonPayerCompanyId": 117,
            "serviceName": "from MCR to EU (Ireland) (eu-west-1)",
            "payerStatus": "APPROVED",
            "nonPayerStatus": "APPROVED",
            "speed": 100,
            "vxcJTechnicalServiceUid": "47d6cc4d-6a1a-4301-b06c-cebb5f9b8f3e",
            "amazonDirectConnectConfigDto": {
                "type": "private",
                "asn": 65105,
                "ownerAccount": "123456789012",
                "authKey": "yourBGPpassword",
                "customerIpAddress": null,
                "amazonIpAddress": null,
                "prefixes": null,
                "name": "Test AWS VIF VXC"
            },
            "connectType": "AWS",
            "fullyApproved": true
        }
    ]
}
```

## Accepting the connection in AWS

After you create the VXC, you need to accept the connection in the AWS console.

**For Hosted VIF**

1. In the AWS console, go to **Direct Connect > Virtual Interfaces**.
2. Click the ID of the interface to display the configuration and peering details.
3. Click **Accept**.
4. For private VIFs, select the gateway type and the specific gateway for the new virtual interface.
5. Click **Accept virtual interface**.

The state of the connection changes from *confirming* to *pending*, and then changes to *available* once BGP has established.

<Note>
  Public VIFs require manual verification by Amazon, which can take up to 72 hours.
</Note>

**For Hosted Connection**

1. In the AWS console, go to **Direct Connect > Connections**.
2. Click the connection name to review the details.
3. Click **Accept**.
4. After the connection is accepted, click **Create Virtual Interface** and create a virtual interface for the hosted connection.

When you create the virtual interface in AWS, make sure the BGP peering values match the configuration you specified in the MCR A-End.

For more information about creating virtual interfaces in AWS, see the [AWS Direct Connect documentation](https://docs.aws.amazon.com/directconnect/latest/UserGuide/create-vif.html).
