

文件 AWS 開發套件範例 GitHub 儲存庫中有更多可用的 [AWS SDK 範例](https://github.com/awsdocs/aws-doc-sdk-examples)。

本文為英文版的機器翻譯版本，如內容有任何歧義或不一致之處，概以英文版為準。

# Direct Connect 使用 的範例 AWS CLI
<a name="cli_2_direct-connect_code_examples"></a>

下列程式碼範例示範如何使用 AWS Command Line Interface 搭配 來執行動作和實作常見案例 Direct Connect。

*Actions* 是大型程式的程式碼摘錄，必須在內容中執行。雖然動作會告訴您如何呼叫個別服務函數，但您可以在其相關情境中查看內容中的動作。

每個範例均包含完整原始碼的連結，您可在連結中找到如何設定和執行內容中程式碼的相關指示。

**Topics**
+ [動作](#actions)

## 動作
<a name="actions"></a>

### `accept-direct-connect-gateway-association-proposal`
<a name="direct-connect_AcceptDirectConnectGatewayAssociationProposal_cli_2_topic"></a>

以下程式碼範例顯示如何使用 `accept-direct-connect-gateway-association-proposal`。

**AWS CLI**  
**接受閘道關聯提案**  
以下 `accept-direct-connect-gateway-association-proposal` 接受指定的提案。  

```
aws directconnect  accept-direct-connect-gateway-association-proposal \
    --direct-connect-gateway-id 11460968-4ac1-4fd3-bdb2-00599EXAMPLE \
    --proposal-id cb7f41cb-8128-43a5-93b1-dcaedEXAMPLE \
    --associated-gateway-owner-account 111122223333

{
    "directConnectGatewayAssociation": {
        "directConnectGatewayId": "11460968-4ac1-4fd3-bdb2-00599EXAMPLE",
        "directConnectGatewayOwnerAccount": "111122223333",
        "associationState": "associating",
        "associatedGateway": {
            "id": "tgw-02f776b1a7EXAMPLE",
            "type": "transitGateway",
            "ownerAccount": "111122223333",
            "region": "us-east-1"
        },
        "associationId": "6441f8bf-5917-4279-ade1-9708bEXAMPLE",
        "allowedPrefixesToDirectConnectGateway": [
            {
                "cidr": "192.168.1.0/30"
            }
        ]
    }
}
```
如需詳細資訊，請參閱《*AWS Direct Connect 使用者指南*》中的[接受或拒絕傳輸閘道關聯提案](https://docs.aws.amazon.com/directconnect/latest/UserGuide/multi-account-associate-tgw.html#multi-account-tgw-accept-reject-proposal)。  
+  如需 API 詳細資訊，請參閱《*AWS CLI 命令參考*》中的 [AcceptDirectConnectGatewayAssociationProposal](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/directconnect/accept-direct-connect-gateway-association-proposal.html)。

### `allocate-connection-on-interconnect`
<a name="direct-connect_AllocateConnectionOnInterconnect_cli_2_topic"></a>

以下程式碼範例顯示如何使用 `allocate-connection-on-interconnect`。

**AWS CLI**  
**在互連上建立託管連線**  
下列 `allocate-connection-on-interconnect` 命令會在互連上建立託管連線：  

```
aws directconnect allocate-connection-on-interconnect --bandwidth 500Mbps --connection-name mydcinterconnect --owner-account 123456789012 --interconnect-id dxcon-fgktov66 --vlan 101
```
輸出：  

```
{
    "partnerName": "TIVIT",
    "vlan": 101,
    "ownerAccount": "123456789012",
    "connectionId": "dxcon-ffzc51m1",
    "connectionState": "ordering",
    "bandwidth": "500Mbps",
    "location": "TIVIT",
    "connectionName": "mydcinterconnect",
    "region": "sa-east-1"
}
```
+  如需 API 詳細資訊，請參閱《*AWS CLI 命令參考*》中的 [AllocateConnectionOnInterconnect](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/directconnect/allocate-connection-on-interconnect.html)。

### `allocate-hosted-connection`
<a name="direct-connect_AllocateHostedConnection_cli_2_topic"></a>

以下程式碼範例顯示如何使用 `allocate-hosted-connection`。

**AWS CLI**  
**在互連上建立託管連線**  
下列 `allocate-hosted-connection` 範例會在指定的互連上建立託管連線。  

```
aws directconnect allocate-hosted-connection \
    --bandwidth 500Mbps \
    --connection-name mydcinterconnect \
    --owner-account 123456789012
    -connection-id dxcon-fgktov66
    -vlan 101
```
輸出：  

```
{
    "partnerName": "TIVIT",
    "vlan": 101,
    "ownerAccount": "123456789012",
    "connectionId": "dxcon-ffzc51m1",
    "connectionState": "ordering",
    "bandwidth": "500Mbps",
    "location": "TIVIT",
    "connectionName": "mydcinterconnect",
    "region": "sa-east-1"
}
```
+  如需 API 詳細資訊，請參閱《*AWS CLI 命令參考*》中的 [AllocateHostedConnection](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/directconnect/allocate-hosted-connection.html)。

### `allocate-private-virtual-interface`
<a name="direct-connect_AllocatePrivateVirtualInterface_cli_2_topic"></a>

以下程式碼範例顯示如何使用 `allocate-private-virtual-interface`。

**AWS CLI**  
**佈建私有虛擬介面**  
下列 `allocate-private-virtual-interface` 命令會佈建不同客戶擁有的私有虛擬介面。  

```
aws directconnect allocate-private-virtual-interface --connection-id dxcon-ffjrkx17 --owner-account 123456789012 --new-private-virtual-interface-allocation virtualInterfaceName=PrivateVirtualInterface,vlan=1000,asn=65000,authKey=asdf34example,amazonAddress=192.168.1.1/30,customerAddress=192.168.1.2/30
```
輸出：  

```
{
    "virtualInterfaceState": "confirming",
    "asn": 65000,
    "vlan": 1000,
    "customerAddress": "192.168.1.2/30",
    "ownerAccount": "123456789012",
    "connectionId": "dxcon-ffjrkx17",
    "virtualInterfaceId": "dxvif-fgy8orxu",
    "authKey": "asdf34example",
    "routeFilterPrefixes": [],
    "location": "TIVIT",
    "customerRouterConfig": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n  <logical_connection id=\"dxvif-fgy8orxu\">\n  <vlan>1000</vlan>\n  <customer_address>192.168.1.2/30</customer_address>\n  <amazon_address>192.168.1.1/30</amazon_address>\n  <bgp_asn>65000</bgp_asn>\n  <bgp_auth_key>asdf34example</bgp_auth_key>\n  <amazon_bgp_asn>7224</amazon_bgp_asn>\n  <connection_type>private</connection_type>\n</logical_connection>\n",
    "amazonAddress": "192.168.1.1/30",
    "virtualInterfaceType": "private",
    "virtualInterfaceName": "PrivateVirtualInterface"
}
```
+  如需 API 詳細資訊，請參閱《*AWS CLI 命令參考*》中的 [AllocatePrivateVirtualInterface](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/directconnect/allocate-private-virtual-interface.html)。

### `allocate-public-virtual-interface`
<a name="direct-connect_AllocatePublicVirtualInterface_cli_2_topic"></a>

以下程式碼範例顯示如何使用 `allocate-public-virtual-interface`。

**AWS CLI**  
**佈建公有虛擬介面**  
下列 `allocate-public-virtual-interface` 命令會佈建不同客戶擁有的公有虛擬介面。  

```
aws directconnect allocate-public-virtual-interface --connection-id dxcon-ffjrkx17 --owner-account 123456789012 --new-public-virtual-interface-allocation virtualInterfaceName=PublicVirtualInterface,vlan=2000,asn=65000,authKey=asdf34example,amazonAddress=203.0.113.1/30,customerAddress=203.0.113.2/30,routeFilterPrefixes=[{cidr=203.0.113.0/30},{cidr=203.0.113.4/30}]
```
輸出：  

```
{
    "virtualInterfaceState": "confirming",
    "asn": 65000,
    "vlan": 2000,
    "customerAddress": "203.0.113.2/30",
    "ownerAccount": "123456789012",
    "connectionId": "dxcon-ffjrkx17",
    "virtualInterfaceId": "dxvif-fg9xo9vp",
    "authKey": "asdf34example",
    "routeFilterPrefixes": [
        {
            "cidr": "203.0.113.0/30"
        },
        {
            "cidr": "203.0.113.4/30"
        }
    ],
    "location": "TIVIT",
    "customerRouterConfig": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<logical_connection id=\"dxvif-fg9xo9vp\">\n  <vlan>2000</vlan>\n  <customer_address>203.0.113.2/30</customer_address>\n  <amazon_address>203.0.113.1/30</amazon_address>\n  <bgp_asn>65000</bgp_asn>\n  <bgp_auth_key>asdf34example</bgp_auth_key>\n  <amazon_bgp_asn>7224</amazon_bgp_asn>\n  <connection_type>public</connection_type>\n</logical_connection>\n",
    "amazonAddress": "203.0.113.1/30",
    "virtualInterfaceType": "public",
    "virtualInterfaceName": "PublicVirtualInterface"
}
```
+  如需 API 詳細資訊，請參閱《*AWS CLI 命令參考*》中的 [AllocatePublicVirtualInterface](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/directconnect/allocate-public-virtual-interface.html)。

### `allocate-transit-virtual-interface`
<a name="direct-connect_AllocateTransitVirtualInterface_cli_2_topic"></a>

以下程式碼範例顯示如何使用 `allocate-transit-virtual-interface`。

**AWS CLI**  
**佈建要由指定 AWS 帳戶擁有的傳輸虛擬介面**  
下列 `allocate-transit-virtual-interface` 範例會為指定的帳戶佈建傳輸虛擬介面。  

```
aws directconnect allocate-transit-virtual-interface \
    --connection-id dxlag-fEXAMPLE \
    --owner-account 123456789012 \
    --new-transit-virtual-interface-allocation "virtualInterfaceName=Example Transit Virtual Interface,vlan=126,asn=65110,mtu=1500,authKey=0xzxgA9YoW9h58u8SEXAMPLE,amazonAddress=192.168.1.1/30,customerAddress=192.168.1.2/30,addressFamily=ipv4,tags=[{key=Tag,value=Example}]"
```
輸出：  

```
{
    "virtualInterface": {
        "ownerAccount": "123456789012",
        "virtualInterfaceId": "dxvif-fEXAMPLE",
        "location": "loc1",
        "connectionId": "dxlag-fEXAMPLE",
        "virtualInterfaceType": "transit",
        "virtualInterfaceName": "Example Transit Virtual Interface",
        "vlan": 126,
        "asn": 65110,
        "amazonSideAsn": 7224,
        "authKey": "0xzxgA9YoW9h58u8SEXAMPLE",
        "amazonAddress": "192.168.1.1/30",
        "customerAddress": "192.168.1.2/30",
        "addressFamily": "ipv4",
        "virtualInterfaceState": "confirming",
        "customerRouterConfig": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<logical_connection id=\"dxvif-fEXAMPLE\">\n  <vlan>126</vlan>\n  <customer_address>192.168.1.2/30</customer_address>\n  <amazon_address>192.168.1.1/30</amazon_address>\n  <bgp_asn>65110</bgp_asn>\n  <bgp_auth_key>0xzxgA9YoW9h58u8SEXAMPLE</bgp_auth_key>\n  <amazon_bgp_asn>7224</amazon_bgp_asn>\n  <connection_type>transit</connection_type>\n</logical_connection>\n",
        "mtu": 1500,
        "jumboFrameCapable": true,
        "virtualGatewayId": "",
        "directConnectGatewayId": "",
        "routeFilterPrefixes": [],
        "bgpPeers": [
            {
                "bgpPeerId": "dxpeer-fEXAMPLE",
                "asn": 65110,
                "authKey": "0xzxgA9YoW9h58u8EXAMPLE",
                "addressFamily": "ipv4",
                "amazonAddress": "192.168.1.1/30",
                "customerAddress": "192.168.1.2/30",
                "bgpPeerState": "pending",
                "bgpStatus": "down",
                "awsDeviceV2": "loc1-26wz6vEXAMPLE"
            }
        ],
        "region": "sa-east-1",
        "awsDeviceV2": "loc1-26wz6vEXAMPLE",
        "tags": [
            {
                "key": "Tag",
                "value": "Example"
            }
        ]
    }
}
```
如需詳細資訊，請參閱《*AWS Direct Connect 使用者指南*》中的[建立託管的傳輸虛擬介面](https://docs.aws.amazon.com/directconnect/latest/UserGuide/createhostedvirtualinterface.html#create-hosted-transit-vif)。  
+  如需 API 詳細資訊，請參閱《*AWS CLI 命令參考*》中的 [AllocateTransitVirtualInterface](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/directconnect/allocate-transit-virtual-interface.html)。

### `associate-connection-with-lag`
<a name="direct-connect_AssociateConnectionWithLag_cli_2_topic"></a>

以下程式碼範例顯示如何使用 `associate-connection-with-lag`。

**AWS CLI**  
**將連線與 LAG 相關聯**  
下列範例會為指定的連線與指定的 LAG 建立關聯。  
命令：  

```
aws directconnect associate-connection-with-lag --lag-id dxlag-fhccu14t --connection-id dxcon-fg9607vm
```
輸出：  

```
{
  "ownerAccount": "123456789012",
  "connectionId": "dxcon-fg9607vm",
  "lagId": "dxlag-fhccu14t",
  "connectionState": "requested",
  "bandwidth": "1Gbps",
  "location": "EqDC2",
  "connectionName": "Con2ForLag",
  "region": "us-east-1"
}
```
+  如需 API 詳細資訊，請參閱《AWS CLI 命令參考》**中的 [AssociateConnectionWithLag](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/directconnect/associate-connection-with-lag.html)。

### `associate-hosted-connection`
<a name="direct-connect_AssociateHostedConnection_cli_2_topic"></a>

以下程式碼範例顯示如何使用 `associate-hosted-connection`。

**AWS CLI**  
**為託管的連線與 LAG 建立關聯**  
下列範例會為指定的託管連線與指定的 LAG 建立關聯。  
命令：  

```
aws directconnect associate-hosted-connection --parent-connection-id dxlag-fhccu14t --connection-id dxcon-fg9607vm
```
輸出：  

```
{
  "partnerName": "TIVIT",
  "vlan": 101,
  "ownerAccount": "123456789012",
  "connectionId": "dxcon-fg9607vm",
  "lagId": "dxlag-fhccu14t",
  "connectionState": "ordering",
  "bandwidth": "500Mbps",
  "location": "TIVIT",
  "connectionName": "mydcinterconnect",
  "region": "sa-east-1"
}
```
+  如需 API 詳細資訊，請參閱《AWS CLI 命令參考》**中的 [AssociateHostedConnection](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/directconnect/associate-hosted-connection.html)。

### `associate-virtual-interface`
<a name="direct-connect_AssociateVirtualInterface_cli_2_topic"></a>

以下程式碼範例顯示如何使用 `associate-virtual-interface`。

**AWS CLI**  
**為虛擬介面與連線建立關聯**  
下列範例會為指定的虛擬介面與指定的 LAG 建立關聯。或者，若要將虛擬介面與連線建立關聯，請指定 的 AWS Direct Connect 連線 ID`--connection-id`；例如 `dxcon-ffnikghc`。  
命令：  

```
aws directconnect associate-virtual-interface --connection-id dxlag-ffjhj9lx --virtual-interface-id dxvif-fgputw0j
```
輸出：  

```
{
  "virtualInterfaceState": "pending",
  "asn": 65000,
  "vlan": 123,
  "customerAddress": "169.254.255.2/30",
  "ownerAccount": "123456789012",
  "connectionId": "dxlag-ffjhj9lx",
  "addressFamily": "ipv4",
  "virtualGatewayId": "vgw-38e90b51",
  "virtualInterfaceId": "dxvif-fgputw0j",
  "authKey": "0x123pK5_VBqv.UQ3kJ4123_",
  "routeFilterPrefixes": [],
  "location": "CSVA1",
  "bgpPeers": [
      {
          "bgpStatus": "down",
          "customerAddress": "169.254.255.2/30",
          "addressFamily": "ipv4",
          "authKey": "0x123pK5_VBqv.UQ3kJ4123_",
          "bgpPeerState": "deleting",
          "amazonAddress": "169.254.255.1/30",
          "asn": 65000
      },
      {
          "bgpStatus": "down",
          "customerAddress": "169.254.255.2/30",
          "addressFamily": "ipv4",
          "authKey": "0x123pK5_VBqv.UQ3kJ4123_",
          "bgpPeerState": "pending",
          "amazonAddress": "169.254.255.1/30",
          "asn": 65000
      }
  ],
  "customerRouterConfig": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<logical_connection id=\"dxvif-fgputw0j\">\n  <vlan>123</vlan>\n  <customer_address>169.254.255.2/30</customer_address>\n  <amazon_address>169.254.255.1/30</amazon_address>\n  <bgp_asn>65000</bgp_asn>\n  <bgp_auth_key>0x123pK5_VBqv.UQ3kJ4123_</bgp_auth_key>\n  <amazon_bgp_asn>7224</amazon_bgp_asn>\n  <connection_type>private</connection_type>\n</logical_connection>\n",
  "amazonAddress": "169.254.255.1/30",
  "virtualInterfaceType": "private",
  "virtualInterfaceName": "VIF1A"
}
```
+  如需 API 詳細資訊，請參閱《AWS CLI 命令參考》**中的 [AssociateVirtualInterface](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/directconnect/associate-virtual-interface.html)。

### `confirm-connection`
<a name="direct-connect_ConfirmConnection_cli_2_topic"></a>

以下程式碼範例顯示如何使用 `confirm-connection`。

**AWS CLI**  
**確認在互連上建立的託管連線**  
下列 `confirm-connection` 命令確認在互連上建立的託管連線：  

```
aws directconnect confirm-connection --connection-id dxcon-fg2wi7hy
```
輸出：  

```
{
    "connectionState": "pending"
}
```
+  如需 API 詳細資訊，請參閱《*AWS CLI 命令參考*》中的 [ConfirmConnection](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/directconnect/confirm-connection.html)。

### `confirm-private-virtual-interface`
<a name="direct-connect_ConfirmPrivateVirtualInterface_cli_2_topic"></a>

以下程式碼範例顯示如何使用 `confirm-private-virtual-interface`。

**AWS CLI**  
**接受私有虛擬介面的擁有權**  
下列 `confirm-private-virtual-interface` 命令接受其他客戶建立的私有虛擬介面的擁有權。  

```
aws directconnect confirm-private-virtual-interface --virtual-interface-id dxvif-fgy8orxu --virtual-gateway-id vgw-e4a47df9
```
輸出：  

```
{
    "virtualInterfaceState": "pending"
}
```
+  如需 API 詳細資訊，請參閱《AWS CLI 命令參考》**中的 [ConfirmPrivateVirtualInterface](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/directconnect/confirm-private-virtual-interface.html)。

### `confirm-public-virtual-interface`
<a name="direct-connect_ConfirmPublicVirtualInterface_cli_2_topic"></a>

以下程式碼範例顯示如何使用 `confirm-public-virtual-interface`。

**AWS CLI**  
**接受公有虛擬介面的擁有權**  
下列 `confirm-public-virtual-interface` 命令接受其他客戶建立的公有虛擬介面的擁有權。  

```
aws directconnect confirm-public-virtual-interface --virtual-interface-id dxvif-fg9xo9vp
```
輸出：  

```
{
    "virtualInterfaceState": "verifying"
}
```
+  如需 API 詳細資訊，請參閱《AWS CLI 命令參考》**中的 [ConfirmPublicVirtualInterface](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/directconnect/confirm-public-virtual-interface.html)。

### `confirm-transit-virtual-interface`
<a name="direct-connect_ConfirmTransitVirtualInterface_cli_2_topic"></a>

以下程式碼範例顯示如何使用 `confirm-transit-virtual-interface`。

**AWS CLI**  
**接受傳輸虛擬介面的擁有權**  
下列 `confirm-transit-virtual-interface` 接受其他客戶建立的傳輸虛擬介面的擁有權。  

```
aws directconnect confirm-transit-virtual-interface \
    --virtual-interface-id dxvif-fEXAMPLE \
    --direct-connect-gateway-id 4112ccf9-25e9-4111-8237-b6c5dEXAMPLE
```
輸出：  

```
{
    "virtualInterfaceState": "pending"
}
```
如需詳細資訊，請參閱《*AWS Direct Connect 使用者指南*》中的[接受託管的虛擬介面](https://docs.aws.amazon.com/directconnect/latest/UserGuide/accepthostedvirtualinterface.html)。  
+  如需 API 詳細資訊，請參閱《AWS CLI 命令參考》**中的 [ConfirmTransitVirtualInterface](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/directconnect/confirm-transit-virtual-interface.html)。

### `create-bgp-peer`
<a name="direct-connect_CreateBgpPeer_cli_2_topic"></a>

以下程式碼範例顯示如何使用 `create-bgp-peer`。

**AWS CLI**  
**建立 IPv6 BGP 對等工作階段**  
下列範例會在私有虛擬介面 `dxvif-fg1vuj3d` 上建立 IPv6 BGP 對等工作階段。Amazon 會自動配置對等 IPv6 位址。  
命令：  

```
aws directconnect create-bgp-peer --virtual-interface-id dxvif-fg1vuj3d --new-bgp-peer asn=64600,addressFamily=ipv6
```
輸出：  

```
{
  "virtualInterface": {
      "virtualInterfaceState": "available",
      "asn": 65000,
      "vlan": 125,
      "customerAddress": "169.254.255.2/30",
      "ownerAccount": "123456789012",
      "connectionId": "dxcon-fguhmqlc",
      "addressFamily": "ipv4",
      "virtualGatewayId": "vgw-f9eb0c90",
      "virtualInterfaceId": "dxvif-fg1vuj3d",
      "authKey": "0xC_ukbCerl6EYA0example",
      "routeFilterPrefixes": [],
      "location": "EqDC2",
      "bgpPeers": [
          {
              "bgpStatus": "down",
              "customerAddress": "169.254.255.2/30",
              "addressFamily": "ipv4",
              "authKey": "0xC_ukbCerl6EYA0uexample",
              "bgpPeerState": "available",
              "amazonAddress": "169.254.255.1/30",
              "asn": 65000
          },
          {
              "bgpStatus": "down",
              "customerAddress": "2001:db8:1100:2f0:0:1:9cb4:4216/125",
              "addressFamily": "ipv6",
              "authKey": "0xS27kAIU_VHPjjAexample",
              "bgpPeerState": "pending",
              "amazonAddress": "2001:db8:1100:2f0:0:1:9cb4:4211/125",
              "asn": 64600
          }
      ],
      "customerRouterConfig": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<logical_connection id=\"dxvif-fg1vuj3d\">\n  <vlan>125</vlan>\n  <customer_address>169.254.255.2/30</customer_address>\n  <amazon_address>169.254.255.1/30</amazon_address>\n  <bgp_asn>65000</bgp_asn>\n  <bgp_auth_key>0xC_ukbCerl6EYA0uexample</bgp_auth_key>\n  <ipv6_customer_address>2001:db8:1100:2f0:0:1:9cb4:4216/125</ipv6_customer_address>\n  <ipv6_amazon_address>2001:db8:1100:2f0:0:1:9cb4:4211/125</ipv6_amazon_address>\n  <ipv6_bgp_asn>64600</ipv6_bgp_asn>\n  <ipv6_bgp_auth_key>0xS27kAIU_VHPjjAexample</ipv6_bgp_auth_key>\n  <amazon_bgp_asn>7224</amazon_bgp_asn>\n  <connection_type>private</connection_type>\n</logical_connection>\n",
      "amazonAddress": "169.254.255.1/30",
      "virtualInterfaceType": "private",
      "virtualInterfaceName": "Test"
  }
}
```
+  如需 API 詳細資訊，請參閱《AWS CLI 命令參考》**中的 [CreateBgpPeer](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/directconnect/create-bgp-peer.html)。

### `create-connection`
<a name="direct-connect_CreateConnection_cli_2_topic"></a>

以下程式碼範例顯示如何使用 `create-connection`。

**AWS CLI**  
**建立從網路到 AWS Direct Connect 位置的連線**  
下列`create-connection`命令會建立從網路到 AWS Direct Connect 位置的連線：  

```
aws directconnect create-connection --location TIVIT --bandwidth 1Gbps --connection-name "Connection to AWS"
```
輸出：  

```
{
    "ownerAccount": "123456789012",
    "connectionId": "dxcon-fg31dyv6",
    "connectionState": "requested",
    "bandwidth": "1Gbps",
    "location": "TIVIT",
    "connectionName": "Connection to AWS",
    "region": "sa-east-1"
}
```
+  如需 API 詳細資訊，請參閱《AWS CLI 命令參考》**中的 [CreateConnection](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/directconnect/create-connection.html)。

### `create-direct-connect-gateway-association-proposal`
<a name="direct-connect_CreateDirectConnectGatewayAssociationProposal_cli_2_topic"></a>

以下程式碼範例顯示如何使用 `create-direct-connect-gateway-association-proposal`。

**AWS CLI**  
**建立提案，為指定的傳輸閘道與指定的 Direct Connect 閘道建立關聯**  
下列 `create-direct-connect-gateway-association-proposal` 範例會建立提案，為指定的傳輸閘道與指定的 Direct Connect 閘道建立關聯。  

```
aws directconnect create-direct-connect-gateway-association-proposal \
    --direct-connect-gateway-id 11460968-4ac1-4fd3-bdb2-00599EXAMPLE \
    --direct-connect-gateway-owner-account 111122223333 \
    --gateway-id tgw-02f776b1a7EXAMPLE \
    --add-allowed-prefixes-to-direct-connect-gateway cidr=192.168.1.0/30
```
輸出：  

```
{
    "directConnectGatewayAssociationProposal": {
        "proposalId": "cb7f41cb-8128-43a5-93b1-dcaedEXAMPLE",
        "directConnectGatewayId": "11460968-4ac1-4fd3-bdb2-00599EXAMPLE",
        "directConnectGatewayOwnerAccount": "111122223333",
        "proposalState": "requested",
        "associatedGateway": {
            "id": "tgw-02f776b1a7EXAMPLE",
            "type": "transitGateway",
            "ownerAccount": "111122223333",
            "region": "us-east-1"
        },
        "requestedAllowedPrefixesToDirectConnectGateway": [
            {
                "cidr": "192.168.1.0/30"
            }
        ]
    }
}
```
如需詳細資訊，請參閱《*AWS Direct Connect 使用者指南*》中的[建立傳輸閘道關聯提案](https://docs.aws.amazon.com/directconnect/latest/UserGuide/multi-account-associate-tgw.html#multi-account-tgw-create-proposal)。  
+  如需 API 詳細資訊，請參閱《*AWS CLI 命令參考*》中的 [CreateDirectConnectGatewayAssociationProposal](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/directconnect/create-direct-connect-gateway-association-proposal.html)。

### `create-direct-connect-gateway-association`
<a name="direct-connect_CreateDirectConnectGatewayAssociation_cli_2_topic"></a>

以下程式碼範例顯示如何使用 `create-direct-connect-gateway-association`。

**AWS CLI**  
**為虛擬私有閘道與 Direct Connect 閘道建立關聯**  
下列範例會為虛擬私有閘道 `vgw-6efe725e` 與 Direct Connect 閘道建立關聯`5f294f92-bafb-4011-916d-9b0bexample`。您必須在虛擬私有閘道所在的區域中執行命令。  
命令：  

```
aws directconnect create-direct-connect-gateway-association --direct-connect-gateway-id 5f294f92-bafb-4011-916d-9b0bexample --virtual-gateway-id vgw-6efe725e
```
輸出：  

```
{
  "directConnectGatewayAssociation": {
      "associationState": "associating",
      "virtualGatewayOwnerAccount": "123456789012",
      "directConnectGatewayId": "5f294f92-bafb-4011-916d-9b0bexample",
      "virtualGatewayId": "vgw-6efe725e",
      "virtualGatewayRegion": "us-east-2"
  }
}
```
+  如需 API 詳細資訊，請參閱《*AWS CLI 命令參考*》中的 [CreateDirectConnectGatewayAssociation](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/directconnect/create-direct-connect-gateway-association.html)。

### `create-direct-connect-gateway`
<a name="direct-connect_CreateDirectConnectGateway_cli_2_topic"></a>

以下程式碼範例顯示如何使用 `create-direct-connect-gateway`。

**AWS CLI**  
**建立 Direct Connect 閘道**  
下列範例會建立名稱為 `DxGateway1` 的 Direct Connect 閘道。  
命令：  

```
aws directconnect create-direct-connect-gateway --direct-connect-gateway-name "DxGateway1"
```
輸出：  

```
{
  "directConnectGateway": {
      "amazonSideAsn": 64512,
      "directConnectGatewayId": "5f294f92-bafb-4011-916d-9b0bdexample",
      "ownerAccount": "123456789012",
      "directConnectGatewayName": "DxGateway1",
      "directConnectGatewayState": "available"
  }
}
```
+  如需 API 詳細資訊，請參閱《*AWS CLI 命令參考*》中的 [CreateDirectConnectGateway](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/directconnect/create-direct-connect-gateway.html)。

### `create-interconnect`
<a name="direct-connect_CreateInterconnect_cli_2_topic"></a>

以下程式碼範例顯示如何使用 `create-interconnect`。

**AWS CLI**  
**在合作夥伴的網路與 之間建立互連 AWS**  
下列`create-interconnect`命令會在 AWS Direct Connect 合作夥伴的網路與特定 AWS Direct Connect 位置之間建立互連：  

```
aws directconnect create-interconnect --interconnect-name "1G Interconnect to AWS" --bandwidth 1Gbps --location TIVIT
```
輸出：  

```
{
    "region": "sa-east-1",
    "bandwidth": "1Gbps",
    "location": "TIVIT",
    "interconnectName": "1G Interconnect to AWS",
    "interconnectId": "dxcon-fgktov66",
    "interconnectState": "requested"
}
```
+  如需 API 詳細資訊，請參閱《AWS CLI 命令參考》**中的 [CreateInterconnect](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/directconnect/create-interconnect.html)。

### `create-lag`
<a name="direct-connect_CreateLag_cli_2_topic"></a>

以下程式碼範例顯示如何使用 `create-lag`。

**AWS CLI**  
**以新連線建立 LAG**  
下列範例會建立 LAG，並為頻寬為 1 Gbps 的 LAG 請求兩個新的 AWS Direct Connect 連線。  
命令：  

```
aws directconnect create-lag --location CSVA1 --number-of-connections 2 --connections-bandwidth 1Gbps --lag-name 1GBLag
```
輸出：  

```
{
  "awsDevice": "CSVA1-23u8tlpaz8iks",
  "numberOfConnections": 2,
  "lagState": "pending",
  "ownerAccount": "123456789012",
  "lagName": "1GBLag",
  "connections": [
      {
          "ownerAccount": "123456789012",
          "connectionId": "dxcon-ffqr6x5q",
          "lagId": "dxlag-ffjhj9lx",
          "connectionState": "requested",
          "bandwidth": "1Gbps",
          "location": "CSVA1",
          "connectionName": "Requested Connection 1 for Lag dxlag-ffjhj9lx",
          "region": "us-east-1"
      },
      {
          "ownerAccount": "123456789012",
          "connectionId": "dxcon-fflqyj95",
          "lagId": "dxlag-ffjhj9lx",
          "connectionState": "requested",
          "bandwidth": "1Gbps",
          "location": "CSVA1",
          "connectionName": "Requested Connection 2 for Lag dxlag-ffjhj9lx",
          "region": "us-east-1"
      }
  ],
  "lagId": "dxlag-ffjhj9lx",
  "minimumLinks": 0,
  "connectionsBandwidth": "1Gbps",
  "region": "us-east-1",
  "location": "CSVA1"
}
```
**使用現有的連線建立 LAG**  
下列範例從您帳戶中的現有連線建立 LAG，並針對與現有連線具有相同頻寬和位置的 LAG，請求第二個新連線。  
命令：  

```
aws directconnect create-lag --location EqDC2 --number-of-connections 2 --connections-bandwidth 1Gbps --lag-name 2ConnLAG --connection-id dxcon-fgk145dr
```
輸出：  

```
{
  "awsDevice": "EqDC2-4h6ce2r1bes6",
  "numberOfConnections": 2,
  "lagState": "pending",
  "ownerAccount": "123456789012",
  "lagName": "2ConnLAG",
  "connections": [
      {
          "ownerAccount": "123456789012",
          "connectionId": "dxcon-fh6ljcvo",
          "lagId": "dxlag-fhccu14t",
          "connectionState": "requested",
          "bandwidth": "1Gbps",
          "location": "EqDC2",
          "connectionName": "Requested Connection 1 for Lag dxlag-fhccu14t",
          "region": "us-east-1"
      },
      {
          "ownerAccount": "123456789012",
          "connectionId": "dxcon-fgk145dr",
          "lagId": "dxlag-fhccu14t",
          "connectionState": "down",
          "bandwidth": "1Gbps",
          "location": "EqDC2",
          "connectionName": "VAConn1",
          "region": "us-east-1"
      }
  ],
  "lagId": "dxlag-fhccu14t",
  "minimumLinks": 0,
  "connectionsBandwidth": "1Gbps",
  "region": "us-east-1",
  "location": "EqDC2"
}
```
+  如需 API 詳細資訊，請參閱《AWS CLI 命令參考》**中的 [CreateLag](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/directconnect/create-lag.html)。

### `create-private-virtual-interface`
<a name="direct-connect_CreatePrivateVirtualInterface_cli_2_topic"></a>

以下程式碼範例顯示如何使用 `create-private-virtual-interface`。

**AWS CLI**  
**建立私有虛擬介面**  
下列 `create-private-virtual-interface` 命令會建立私有虛擬介面：  

```
aws directconnect create-private-virtual-interface --connection-id dxcon-ffjrkx17 --new-private-virtual-interface virtualInterfaceName=PrivateVirtualInterface,vlan=101,asn=65000,authKey=asdf34example,amazonAddress=192.168.1.1/30,customerAddress=192.168.1.2/30,virtualGatewayId=vgw-aba37db6
```
輸出：  

```
{
    "virtualInterfaceState": "pending",
    "asn": 65000,
    "vlan": 101,
    "customerAddress": "192.168.1.2/30",
    "ownerAccount": "123456789012",
    "connectionId": "dxcon-ffjrkx17",
    "virtualGatewayId": "vgw-aba37db6",
    "virtualInterfaceId": "dxvif-ffhhk74f",
    "authKey": "asdf34example",
    "routeFilterPrefixes": [],
    "location": "TIVIT",
    "customerRouterConfig": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<logical_connection id=\"dxvif-ffhhk74f\">\n  <vlan>101</vlan>\n  <customer_address>192.168.1.2/30</customer_address>\n  <amazon_address>192.168.1.1/30</amazon_address>\n  <bgp_asn>65000</bgp_asn>\n  <bgp_auth_key>asdf34example</bgp_auth_key>\n  <amazon_bgp_asn>7224</amazon_bgp_asn>\n  <connection_type>private</connection_type>\n</logical_connection>\n",
    "amazonAddress": "192.168.1.1/30",
    "virtualInterfaceType": "private",
    "virtualInterfaceName": "PrivateVirtualInterface"
}
```
+  如需 API 詳細資訊，請參閱《*AWS CLI 命令參考*》中的 [CreatePrivateVirtualInterface](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/directconnect/create-private-virtual-interface.html)。

### `create-public-virtual-interface`
<a name="direct-connect_CreatePublicVirtualInterface_cli_2_topic"></a>

以下程式碼範例顯示如何使用 `create-public-virtual-interface`。

**AWS CLI**  
**建立公有虛擬介面**  
下列 `create-public-virtual-interface` 命令會建立公有虛擬介面：  

```
aws directconnect create-public-virtual-interface --connection-id dxcon-ffjrkx17 --new-public-virtual-interface virtualInterfaceName=PublicVirtualInterface,vlan=2000,asn=65000,authKey=asdf34example,amazonAddress=203.0.113.1/30,customerAddress=203.0.113.2/30,routeFilterPrefixes=[{cidr=203.0.113.0/30},{cidr=203.0.113.4/30}]
```
輸出：  

```
{
    "virtualInterfaceState": "verifying",
    "asn": 65000,
    "vlan": 2000,
    "customerAddress": "203.0.113.2/30",
    "ownerAccount": "123456789012",
    "connectionId": "dxcon-ffjrkx17",
    "virtualInterfaceId": "dxvif-fgh0hcrk",
    "authKey": "asdf34example",
    "routeFilterPrefixes": [
        {
            "cidr": "203.0.113.0/30"
        },
        {
            "cidr": "203.0.113.4/30"
        }
    ],
    "location": "TIVIT",
    "customerRouterConfig": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<logical_connection id=\"dxvif-fgh0hcrk\">\n  <vlan>2000</vlan>\n  <customer_address>203.0.113.2/30</customer_address>\n  <amazon_address>203.0.113.1/30</amazon_address>\n  <bgp_asn>65000</bgp_asn>\n  <bgp_auth_key>asdf34example</bgp_auth_key>\n  <amazon_bgp_asn>7224</amazon_bgp_asn>\n  <connection_type>public</connection_type>\n</logical_connection>\n",
    "amazonAddress": "203.0.113.1/30",
    "virtualInterfaceType": "public",
    "virtualInterfaceName": "PublicVirtualInterface"
}
```
+  如需 API 詳細資訊，請參閱《*AWS CLI 命令參考*》中的 [CreatePublicVirtualInterface](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/directconnect/create-public-virtual-interface.html)。

### `create-transit-virtual-interface`
<a name="direct-connect_CreateTransitVirtualInterface_cli_2_topic"></a>

以下程式碼範例顯示如何使用 `create-transit-virtual-interface`。

**AWS CLI**  
**建立傳輸虛擬介面**  
下列 `create-transit-virtual-interface` 範例會為指定的連線建立傳輸虛擬介面。  

```
aws directconnect create-transit-virtual-interface \
    --connection-id dxlag-fEXAMPLE \
    --new-transit-virtual-interface "virtualInterfaceName=Example Transit Virtual Interface,vlan=126,asn=65110,mtu=1500,authKey=0xzxgA9YoW9h58u8SvEXAMPLE,amazonAddress=192.168.1.1/30,customerAddress=192.168.1.2/30,addressFamily=ipv4,directConnectGatewayId=8384da05-13ce-4a91-aada-5a1baEXAMPLE,tags=[{key=Tag,value=Example}]"
```
輸出：  

```
{
    "virtualInterface": {
        "ownerAccount": "1111222233333",
        "virtualInterfaceId": "dxvif-fEXAMPLE",
        "location": "loc1",
        "connectionId": "dxlag-fEXAMPLE",
        "virtualInterfaceType": "transit",
        "virtualInterfaceName": "Example Transit Virtual Interface",
        "vlan": 126,
        "asn": 65110,
        "amazonSideAsn": 4200000000,
        "authKey": "0xzxgA9YoW9h58u8SEXAMPLE",
        "amazonAddress": "192.168.1.1/30",
        "customerAddress": "192.168.1.2/30",
        "addressFamily": "ipv4",
        "virtualInterfaceState": "pending",
        "customerRouterConfig": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<logical_connection id=\"dxvif-fEXAMPLE\">\n  <vlan>126</vlan>\n  <customer_address>192.168.1.2/30</customer_address>\n  <amazon_address>192.168.1.1/30</amazon_address>\n  <bgp_asn>65110</bgp_asn>\n  <bgp_auth_key>0xzxgA9YoW9h58u8SvOmXRTw</bgp_auth_key>\n  <amazon_bgp_asn>4200000000</amazon_bgp_asn>\n  <connection_type>transit</connection_type>\n</logical_connection>\n",
        "mtu": 1500,
        "jumboFrameCapable": true,
        "virtualGatewayId": "",
        "directConnectGatewayId": "8384da05-13ce-4a91-aada-5a1baEXAMPLE",
        "routeFilterPrefixes": [],
        "bgpPeers": [
            {
                "bgpPeerId": "dxpeer-EXAMPLE",
                "asn": 65110,
                "authKey": "0xzxgA9YoW9h58u8SEXAMPLE",
                "addressFamily": "ipv4",
                "amazonAddress": "192.168.1.1/30",
                "customerAddress": "192.168.1.2/30",
                "bgpPeerState": "pending",
                "bgpStatus": "down",
                "awsDeviceV2": "loc1-26wz6vEXAMPLE"
            }
        ],
        "region": "sa-east-1",
        "awsDeviceV2": "loc1-26wz6vEXAMPLE",
        "tags": [
            {
                "key": "Tag",
                "value": "Example"
            }
        ]
    }
}
```
如需詳細資訊，請參閱《*AWS Direct Connect 使用者指南*》中的[建立 Direct Connect 閘道的傳輸虛擬介面](https://docs.aws.amazon.com/directconnect/latest/UserGuide/create-vif.html#create-transit-vif)。  
+  如需 API 詳細資訊，請參閱《*AWS CLI 命令參考*》中的 [CreateTransitVirtualInterface](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/directconnect/create-transit-virtual-interface.html)。

### `delete-bgp-peer`
<a name="direct-connect_DeleteBgpPeer_cli_2_topic"></a>

以下程式碼範例顯示如何使用 `delete-bgp-peer`。

**AWS CLI**  
**從虛擬介面刪除 BGP 對等**  
下列範例會從虛擬介面 `dxvif-fg1vuj3d` 刪除 IPv6 BGP 對等。  
命令：  

```
aws directconnect delete-bgp-peer --virtual-interface-id dxvif-fg1vuj3d --asn 64600 --customer-address 2001:db8:1100:2f0:0:1:9cb4:4216/125
```
輸出：  

```
{
  "virtualInterface": {
      "virtualInterfaceState": "available",
      "asn": 65000,
      "vlan": 125,
      "customerAddress": "169.254.255.2/30",
      "ownerAccount": "123456789012",
      "connectionId": "dxcon-fguhmqlc",
      "addressFamily": "ipv4",
      "virtualGatewayId": "vgw-f9eb0c90",
      "virtualInterfaceId": "dxvif-fg1vuj3d",
      "authKey": "0xC_ukbCerl6EYA0example",
      "routeFilterPrefixes": [],
      "location": "EqDC2",
      "bgpPeers": [
          {
              "bgpStatus": "down",
              "customerAddress": "169.254.255.2/30",
              "addressFamily": "ipv4",
              "authKey": "0xC_ukbCerl6EYA0uexample",
              "bgpPeerState": "available",
              "amazonAddress": "169.254.255.1/30",
              "asn": 65000
          },
          {
              "bgpStatus": "down",
              "customerAddress": "2001:db8:1100:2f0:0:1:9cb4:4216/125",
              "addressFamily": "ipv6",
              "authKey": "0xS27kAIU_VHPjjAexample",
              "bgpPeerState": "deleting",
              "amazonAddress": "2001:db8:1100:2f0:0:1:9cb4:4211/125",
              "asn": 64600
          }
      ],
      "customerRouterConfig": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<logical_connection id=\"dxvif-fg1vuj3d\">\n  <vlan>125</vlan>\n  <customer_address>169.254.255.2/30</customer_address>\n  <amazon_address>169.254.255.1/30</amazon_address>\n  <bgp_asn>65000</bgp_asn>\n  <bgp_auth_key>0xC_ukbCerl6EYA0example</bgp_auth_key>\n  <amazon_bgp_asn>7224</amazon_bgp_asn>\n  <connection_type>private</connection_type>\n</logical_connection>\n",
      "amazonAddress": "169.254.255.1/30",
      "virtualInterfaceType": "private",
      "virtualInterfaceName": "Test"
  }
}
```
+  如需 API 詳細資訊，請參閱《AWS CLI 命令參考》**中的 [DeleteBgpPeer](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/directconnect/delete-bgp-peer.html)。

### `delete-connection`
<a name="direct-connect_DeleteConnection_cli_2_topic"></a>

以下程式碼範例顯示如何使用 `delete-connection`。

**AWS CLI**  
**刪除連線**  
以下 `delete-connection` 命令會刪除指定的連線。  

```
aws directconnect delete-connection --connection-id dxcon-fg31dyv6
```
輸出：  

```
{
    "ownerAccount": "123456789012",
    "connectionId": "dxcon-fg31dyv6",
    "connectionState": "deleted",
    "bandwidth": "1Gbps",
    "location": "TIVIT",
    "connectionName": "Connection to AWS",
    "region": "sa-east-1"
}
```
+  如需 API 詳細資訊，請參閱《AWS CLI 命令參考》**中的 [DeleteConnection](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/directconnect/delete-connection.html)。

### `delete-direct-connect-gateway-association`
<a name="direct-connect_DeleteDirectConnectGatewayAssociation_cli_2_topic"></a>

以下程式碼範例顯示如何使用 `delete-direct-connect-gateway-association`。

**AWS CLI**  
**建立 Direct Connect 閘道關聯**  
下列 `delete-direct-connect-gateway-association` 範例會刪除與具有指定關聯 ID 之傳輸閘道的 Direct Connect 閘道關聯。  

```
aws directconnect delete-direct-connect-gateway-association --association-id  be85116d-46eb-4b43-a27a-da0c2ad648de
```
輸出：  

```
{
    "directConnectGatewayAssociation": {
        "directConnectGatewayId": "11460968-4ac1-4fd3-bdb2-00599EXAMPlE",
        "directConnectGatewayOwnerAccount": "123456789012",
        "associationState": "disassociating",
        "associatedGateway": {
            "id": "tgw-095b3b0b54EXAMPLE",
            "type": "transitGateway",
            "ownerAccount": "123456789012",
            "region": "us-east-1"
       },
        "associationId": " be85116d-46eb-4b43-a27a-da0c2ad648deEXAMPLE ",
        "allowedPrefixesToDirectConnectGateway": [
            {
                "cidr": "192.0.1.0/28"
            }
        ]
    }
}
```
如需詳細資訊，請參閱《*AWS Direct Connect 使用者指南*》中的[建立傳輸閘道關聯和取消關聯](https://docs.aws.amazon.com/directconnect/latest/UserGuide/direct-connect-transit-gateways.html#associate-tgw-with-direct-connect-gateway)。  
+  如需 API 詳細資訊，請參閱《AWS CLI 命令參考》**中的 [DeleteDirectConnectGatewayAssociation](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/directconnect/delete-direct-connect-gateway-association.html)。

### `delete-direct-connect-gateway`
<a name="direct-connect_DeleteDirectConnectGateway_cli_2_topic"></a>

以下程式碼範例顯示如何使用 `delete-direct-connect-gateway`。

**AWS CLI**  
**刪除 Direct Connect 閘道**  
下列範例會刪除 Direct Connect 閘道 `5f294f92-bafb-4011-916d-9b0bexample`。  
命令：  

```
aws directconnect delete-direct-connect-gateway --direct-connect-gateway-id 5f294f92-bafb-4011-916d-9b0bexample
```
輸出：  

```
{
  "directConnectGateway": {
      "amazonSideAsn": 64512,
      "directConnectGatewayId": "5f294f92-bafb-4011-916d-9b0bexample",
      "ownerAccount": "123456789012",
      "directConnectGatewayName": "DxGateway1",
      "directConnectGatewayState": "deleting"
  }
}
```
+  如需 API 詳細資訊，請參閱《AWS CLI 命令參考》**中的 [DeleteDirectConnectGateway](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/directconnect/delete-direct-connect-gateway.html)。

### `delete-interconnect`
<a name="direct-connect_DeleteInterconnect_cli_2_topic"></a>

以下程式碼範例顯示如何使用 `delete-interconnect`。

**AWS CLI**  
**刪除互連**  
下列 `delete-interconnect` 命令會刪除指定的互連：  

```
aws directconnect delete-interconnect --interconnect-id dxcon-fgktov66
```
輸出：  

```
{
    "interconnectState": "deleted"
}
```
+  如需 API 詳細資訊，請參閱《AWS CLI 命令參考》**中的 [DeleteInterconnect](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/directconnect/delete-interconnect.html)。

### `delete-lag`
<a name="direct-connect_DeleteLag_cli_2_topic"></a>

以下程式碼範例顯示如何使用 `delete-lag`。

**AWS CLI**  
**刪除 LAG**  
以下範例會刪除指定的 LAG。  
命令：  

```
aws directconnect delete-lag --lag-id dxlag-ffrhowd9
```
輸出：  

```
{
  "awsDevice": "EqDC2-4h6ce2r1bes6",
  "numberOfConnections": 0,
  "lagState": "deleted",
  "ownerAccount": "123456789012",
  "lagName": "TestLAG",
  "connections": [],
  "lagId": "dxlag-ffrhowd9",
  "minimumLinks": 0,
  "connectionsBandwidth": "1Gbps",
  "region": "us-east-1",
  "location": "EqDC2"
}
```
+  如需 API 詳細資訊，請參閱《AWS CLI 命令參考》**中的 [DeleteLag](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/directconnect/delete-lag.html)。

### `delete-virtual-interface`
<a name="direct-connect_DeleteVirtualInterface_cli_2_topic"></a>

以下程式碼範例顯示如何使用 `delete-virtual-interface`。

**AWS CLI**  
**刪除虛擬介面**  
下列 `delete-virtual-interface` 命令會刪除指定的虛擬介面：  

```
aws directconnect delete-virtual-interface --virtual-interface-id dxvif-ffhhk74f
```
輸出：  

```
{
    "virtualInterfaceState": "deleting"
}
```
+  如需 API 詳細資訊，請參閱《AWS CLI 命令參考》**中的 [DeleteVirtualInterface](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/directconnect/delete-virtual-interface.html)。

### `describe-connection-loa`
<a name="direct-connect_DescribeConnectionLoa_cli_2_topic"></a>

以下程式碼範例顯示如何使用 `describe-connection-loa`。

**AWS CLI**  
**使用 Linux 或 Mac OS X 描述連線的 LOA-CFA**  
下列範例描述連線 `dxcon-fh6ayh1d` 的 LOA-CFA。LOA-CFA 的內容以 base64 編碼。此命令使用 `--output` 和 `--query` 參數來控制輸出，並擷取 `loaContent` 結構的內容。命令的最後部分使用 `base64` 公用程式將內容解碼，並傳送輸出至 PDF 檔案。  

```
aws directconnect describe-connection-loa --connection-id dxcon-fh6ayh1d --output text --query loa.loaContent|base64 --decode > myLoaCfa.pdf
```
**使用 Windows 描述連線的 LOA-CFA**  
先前的範例需要使用 `base64` 公用程式將輸出解碼。在 Windows 電腦上，您可以改為使用 `certutil`。在下列範例中，第一個命令描述連線 `dxcon-fh6ayh1d` 的 LOA-CFA，並使用 `--output` 和 `--query` 參數控制輸出，將 `loaContent` 結構的內容擷取至名為 `myLoaCfa.base64` 的檔案。第二個命令使用 `certutil` 公用程式將該檔案解碼並傳送輸出至 PDF 檔案。  

```
aws directconnect describe-connection-loa --connection-id dxcon-fh6ayh1d --output text --query loa.loaContent > myLoaCfa.base64
```

```
certutil -decode myLoaCfa.base64 myLoaCfa.pdf
```
如需控制 AWS CLI 輸出的詳細資訊，請參閱《 [命令列界面使用者指南》中的從 AWS 命令列界面控制命令輸出](https://docs.aws.amazon.com/cli/latest/userguide/controlling-output.html)。 *AWS *  
+  如需 API 詳細資訊，請參閱《AWS CLI 命令參考》**中的 [DescribeConnectionLoa](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/directconnect/describe-connection-loa.html)。

### `describe-connections-on-interconnect`
<a name="direct-connect_DescribeConnectionsOnInterconnect_cli_2_topic"></a>

以下程式碼範例顯示如何使用 `describe-connections-on-interconnect`。

**AWS CLI**  
**列出互連上的連線**  
下列 `describe-connections-on-interconnect` 命令列出已在指定互連上佈建的連線：  

```
aws directconnect describe-connections-on-interconnect --interconnect-id dxcon-fgktov66
```
輸出：  

```
{
    "connections": [
        {
            "partnerName": "TIVIT",
            "vlan": 101,
            "ownerAccount": "123456789012",
            "connectionId": "dxcon-ffzc51m1",
            "connectionState": "ordering",
            "bandwidth": "500Mbps",
            "location": "TIVIT",
            "connectionName": "mydcinterconnect",
            "region": "sa-east-1"
        }
    ]
}
```
+  如需 API 詳細資訊，請參閱《AWS CLI 命令參考》**中的 [DescribeConnectionsOnInterconnect](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/directconnect/describe-connections-on-interconnect.html)。

### `describe-connections`
<a name="direct-connect_DescribeConnections_cli_2_topic"></a>

以下程式碼範例顯示如何使用 `describe-connections`。

**AWS CLI**  
**列出目前區域中的所有連線**  
下列 `describe-connections` 命令會列出目前區域中的所有連線：  

```
aws directconnect describe-connections
```
輸出：  

```
{
  "connections": [
      {
          "awsDevice": "EqDC2-123h49s71dabc",
          "ownerAccount": "123456789012",
          "connectionId": "dxcon-fguhmqlc",
          "lagId": "dxlag-ffrz71kw",
          "connectionState": "down",
          "bandwidth": "1Gbps",
          "location": "EqDC2",
          "connectionName": "My_Connection",
          "loaIssueTime": 1491568964.0,
          "region": "us-east-1"
      }
  ]
}
```
+  如需 API 詳細資訊，請參閱《AWS CLI 命令參考》**中的 [DescribeConnections](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/directconnect/describe-connections.html)。

### `describe-direct-connect-gateway-association-proposals`
<a name="direct-connect_DescribeDirectConnectGatewayAssociationProposals_cli_2_topic"></a>

以下程式碼範例顯示如何使用 `describe-direct-connect-gateway-association-proposals`。

**AWS CLI**  
**描述您的 Direct Connect 閘道關聯提案**  
下列 `describe-direct-connect-gateway-association-proposals` 範例顯示有關 Direct Connect 閘道關聯提案的詳細資訊。  

```
aws directconnect describe-direct-connect-gateway-association-proposals
```
輸出：  

```
{
    "directConnectGatewayAssociationProposals": [
        {
            "proposalId": "c2ede9b4-bbc6-4d33-923c-bc4feEXAMPLE",
            "directConnectGatewayId": "11460968-4ac1-4fd3-bdb2-00599EXAMPLE",
            "directConnectGatewayOwnerAccount": "111122223333",
            "proposalState": "requested",
            "associatedGateway": {
                "id": "tgw-02f776b1a7EXAMPLE",
                "type": "transitGateway",
                "ownerAccount": "111122223333",
                "region": "us-east-1"
            },
            "existingAllowedPrefixesToDirectConnectGateway": [
                {
                    "cidr": "192.168.2.0/30"
                },
                {
                    "cidr": "192.168.1.0/30"
                }
            ],
            "requestedAllowedPrefixesToDirectConnectGateway": [
                {
                    "cidr": "192.168.1.0/30"
                }
            ]
        },
        {
            "proposalId": "cb7f41cb-8128-43a5-93b1-dcaedEXAMPLE",
            "directConnectGatewayId": "11560968-4ac1-4fd3-bcb2-00599EXAMPLE",
            "directConnectGatewayOwnerAccount": "111122223333",
            "proposalState": "accepted",
            "associatedGateway": {
                "id": "tgw-045776b1a7EXAMPLE",
                "type": "transitGateway",
                "ownerAccount": "111122223333",
                "region": "us-east-1"
            },
            "existingAllowedPrefixesToDirectConnectGateway": [
                {
                    "cidr": "192.168.4.0/30"
                },
                {
                    "cidr": "192.168.5.0/30"
                }
            ],
            "requestedAllowedPrefixesToDirectConnectGateway": [
                {
                    "cidr": "192.168.5.0/30"
                }
            ]
        }
    ]
}
```
如需詳細資訊，請參閱《*AWS Direct Connect 使用者指南*》中的[建立傳輸閘道關聯和取消關聯](https://docs.aws.amazon.com/directconnect/latest/UserGuide/direct-connect-transit-gateways.html#associate-tgw-with-direct-connect-gateway)。  
+  如需 API 詳細資訊，請參閱《AWS CLI 命令參考》**中的 [DescribeDirectConnectGatewayAssociationProposals](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/directconnect/describe-direct-connect-gateway-association-proposals.html)。

### `describe-direct-connect-gateway-associations`
<a name="direct-connect_DescribeDirectConnectGatewayAssociations_cli_2_topic"></a>

以下程式碼範例顯示如何使用 `describe-direct-connect-gateway-associations`。

**AWS CLI**  
**描述 Direct Connect 閘道關聯**  
下列範例描述與 Direct Connect 閘道的所有關聯`5f294f92-bafb-4011-916d-9b0bexample`。  
命令：  

```
aws directconnect describe-direct-connect-gateway-associations --direct-connect-gateway-id 5f294f92-bafb-4011-916d-9b0bexample
```
輸出：  

```
{
  "nextToken": "eyJ2IjoxLCJzIjoxLCJpIjoiOU83OTFodzdycnZCbkN4MExHeHVwQT09IiwiYyI6InIxTEN0UEVHV0I1UFlkaWFnNlUxanJkRWF6eW1iOElHM0FRVW1MdHRJK0dxcnN1RWtvcFBKWFE2ZjRNRGdGTkhCa0tDZmVINEtZOEYwZ0dEYWZpbmU0ZnZMYVhKRjdXRVdENmdQZ1Y4d2w0PSJ9",
  "directConnectGatewayAssociations": [
      {
          "associationState": "associating",
          "virtualGatewayOwnerAccount": "123456789012",
          "directConnectGatewayId": "5f294f92-bafb-4011-916d-9b0bexample",
          "virtualGatewayId": "vgw-6efe725e",
          "virtualGatewayRegion": "us-east-2"
      },
      {
          "associationState": "disassociating",
          "virtualGatewayOwnerAccount": "123456789012",
          "directConnectGatewayId": "5f294f92-bafb-4011-916d-9b0bexample",
          "virtualGatewayId": "vgw-ebaa27db",
          "virtualGatewayRegion": "us-east-2"
      }
  ]
}
```
+  如需 API 詳細資訊，請參閱《AWS CLI 命令參考》**中的 [DescribeDirectConnectGatewayAssociations](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/directconnect/describe-direct-connect-gateway-associations.html)。

### `describe-direct-connect-gateway-attachments`
<a name="direct-connect_DescribeDirectConnectGatewayAttachments_cli_2_topic"></a>

以下程式碼範例顯示如何使用 `describe-direct-connect-gateway-attachments`。

**AWS CLI**  
**描述 Direct Connect 閘道附件**  
下列範例描述連接至 Direct Connect 閘道的虛擬介面`5f294f92-bafb-4011-916d-9b0bexample`。  
命令：  

```
aws directconnect describe-direct-connect-gateway-attachments --direct-connect-gateway-id 5f294f92-bafb-4011-916d-9b0bexample
```
輸出：  

```
{
  "directConnectGatewayAttachments": [
      {
          "virtualInterfaceOwnerAccount": "123456789012",
          "directConnectGatewayId": "5f294f92-bafb-4011-916d-9b0bexample",
          "virtualInterfaceRegion": "us-east-2",
          "attachmentState": "attaching",
          "virtualInterfaceId": "dxvif-fg9zyabc"
      }
  ],
  "nextToken": "eyJ2IjoxLCJzIjoxLCJpIjoibEhXdlNpUXF5RzhoL1JyUW52SlV2QT09IiwiYyI6Im5wQjFHQ0RyQUdRS3puNnNXcUlINCtkTTA4dTk3KzBiU0xtb05JQmlaczZ6NXRIYmk3c3VESUxFTTd6a2FzVHM0VTFwaGJkZGNxTytqWmQ3QzMzOGRQaTVrTThrOG1zelRsV3gyMWV3VTNFPSJ9"
}
```
+  如需 API 詳細資訊，請參閱《AWS CLI 命令參考》**中的 [DescribeDirectConnectGatewayAttachments](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/directconnect/describe-direct-connect-gateway-attachments.html)。

### `describe-direct-connect-gateways`
<a name="direct-connect_DescribeDirectConnectGateways_cli_2_topic"></a>

以下程式碼範例顯示如何使用 `describe-direct-connect-gateways`。

**AWS CLI**  
**描述您的 Direct Connect 閘道**  
下列範例描述所有 Direct Connect 閘道。  
命令：  

```
aws directconnect describe-direct-connect-gateways
```
輸出：  

```
{
  "directConnectGateways": [
      {
          "amazonSideAsn": 64512,
          "directConnectGatewayId": "cf68415c-f4ae-48f2-87a7-3b52cexample",
          "ownerAccount": "123456789012",
          "directConnectGatewayName": "DxGateway2",
          "directConnectGatewayState": "available"
      },
      {
          "amazonSideAsn": 64512,
          "directConnectGatewayId": "5f294f92-bafb-4011-916d-9b0bdexample",
          "ownerAccount": "123456789012",
          "directConnectGatewayName": "DxGateway1",
          "directConnectGatewayState": "available"
      }
  ]
}
```
+  如需 API 詳細資訊，請參閱《AWS CLI 命令參考》**中的 [DescribeDirectConnectGateways](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/directconnect/describe-direct-connect-gateways.html)。

### `describe-hosted-connections`
<a name="direct-connect_DescribeHostedConnections_cli_2_topic"></a>

以下程式碼範例顯示如何使用 `describe-hosted-connections`。

**AWS CLI**  
**列出互連上的連線**  
下列範例列出已在指定互連上佈建的連線。  
命令：  

```
aws directconnect describe-hosted-connections --connection-id dxcon-fgktov66
```
輸出：  

```
{
    "connections": [
        {
            "partnerName": "TIVIT",
            "vlan": 101,
            "ownerAccount": "123456789012",
            "connectionId": "dxcon-ffzc51m1",
            "connectionState": "ordering",
            "bandwidth": "500Mbps",
            "location": "TIVIT",
            "connectionName": "mydcinterconnect",
            "region": "sa-east-1"
        }
    ]
}
```
+  如需 API 詳細資訊，請參閱《AWS CLI 命令參考》**中的 [DescribeHostedConnections](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/directconnect/describe-hosted-connections.html)。

### `describe-interconnect-loa`
<a name="direct-connect_DescribeInterconnectLoa_cli_2_topic"></a>

以下程式碼範例顯示如何使用 `describe-interconnect-loa`。

**AWS CLI**  
**描述使用 Linux 或 Mac OS X 互連的 LOA-CFA**  
下列範例描述用於互連 `dxcon-fh6ayh1d` 的 LOA-CFA。LOA-CFA 的內容以 base64 編碼。此命令使用 `--output` 和 `--query` 參數來控制輸出，並擷取 `loaContent` 結構的內容。命令的最後部分使用 `base64` 公用程式將內容解碼，並傳送輸出至 PDF 檔案。  

```
aws directconnect describe-interconnect-loa --interconnect-id dxcon-fh6ayh1d --output text --query loa.loaContent|base64 --decode > myLoaCfa.pdf
```
**描述使用 Windows 互連的 LOA-CFA**  
先前的範例需要使用 `base64` 公用程式將輸出解碼。在 Windows 電腦上，您可以改為使用 `certutil`。在下列範例中，第一個命令描述互連 `dxcon-fh6ayh1d` 的 LOA-CFA，並使用 `--output` 和 `--query` 參數控制輸出，將 `loaContent` 結構的內容擷取至名為 `myLoaCfa.base64` 的檔案。第二個命令使用 `certutil` 公用程式將該檔案解碼並傳送輸出至 PDF 檔案。  

```
aws directconnect describe-interconnect-loa --interconnect-id dxcon-fh6ayh1d --output text --query loa.loaContent > myLoaCfa.base64
```

```
certutil -decode myLoaCfa.base64 myLoaCfa.pdf
```
如需控制 AWS CLI 輸出的詳細資訊，請參閱《 [命令列界面使用者指南》中的從 AWS 命令列界面控制命令輸出](https://docs.aws.amazon.com/cli/latest/userguide/controlling-output.html)。 *AWS *  
+  如需 API 詳細資訊，請參閱《AWS CLI 命令參考》**中的 [DescribeInterconnectLoa](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/directconnect/describe-interconnect-loa.html)。

### `describe-interconnects`
<a name="direct-connect_DescribeInterconnects_cli_2_topic"></a>

以下程式碼範例顯示如何使用 `describe-interconnects`。

**AWS CLI**  
**列出互連**  
下列`describe-interconnects`命令會列出 AWS 您的帳戶擁有的互連：  

```
aws directconnect describe-interconnects
```
輸出：  

```
{
    "interconnects": [
        {
            "region": "sa-east-1",
            "bandwidth": "1Gbps",
            "location": "TIVIT",
            "interconnectName": "1G Interconnect to AWS",
            "interconnectId": "dxcon-fgktov66",
            "interconnectState": "down"
        }
    ]
}
```
+  如需 API 詳細資訊，請參閱《AWS CLI 命令參考》**中的 [DescribeInterconnects](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/directconnect/describe-interconnects.html)。

### `describe-lags`
<a name="direct-connect_DescribeLags_cli_2_topic"></a>

以下程式碼範例顯示如何使用 `describe-lags`。

**AWS CLI**  
**描述您的 LAG**  
下列命令描述目前區域的所有 LAG。  
命令：  

```
aws directconnect describe-lags
```
輸出：  

```
{
  "lags": [
      {
          "awsDevice": "EqDC2-19y7z3m17xpuz",
          "numberOfConnections": 2,
          "lagState": "down",
          "ownerAccount": "123456789012",
          "lagName": "DA-LAG",
          "connections": [
              {
                  "ownerAccount": "123456789012",
                  "connectionId": "dxcon-ffnikghc",
                  "lagId": "dxlag-fgsu9erb",
                  "connectionState": "requested",
                  "bandwidth": "10Gbps",
                  "location": "EqDC2",
                  "connectionName": "Requested Connection 1 for Lag dxlag-fgsu9erb",
                  "region": "us-east-1"
              },
              {
                  "ownerAccount": "123456789012",
                  "connectionId": "dxcon-fglgbdea",
                  "lagId": "dxlag-fgsu9erb",
                  "connectionState": "requested",
                  "bandwidth": "10Gbps",
                  "location": "EqDC2",
                  "connectionName": "Requested Connection 2 for Lag dxlag-fgsu9erb",
                  "region": "us-east-1"
              }
          ],
          "lagId": "dxlag-fgsu9erb",
          "minimumLinks": 0,
          "connectionsBandwidth": "10Gbps",
          "region": "us-east-1",
          "location": "EqDC2"
      }
  ]
}
```
+  如需 API 詳細資訊，請參閱《AWS CLI 命令參考》**中的 [DescribeLags](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/directconnect/describe-lags.html)。

### `describe-loa`
<a name="direct-connect_DescribeLoa_cli_2_topic"></a>

以下程式碼範例顯示如何使用 `describe-loa`。

**AWS CLI**  
**使用 Linux 或 Mac OS X 描述連線的 LOA-CFA**  
下列範例描述連線 `dxcon-fh6ayh1d` 的 LOA-CFA。LOA-CFA 的內容以 base64 編碼。此命令使用 `--output` 和 `--query` 參數來控制輸出，並擷取 `loaContent` 結構的內容。命令的最後部分使用 `base64` 公用程式將內容解碼，並傳送輸出至 PDF 檔案。  

```
aws directconnect describe-loa --connection-id dxcon-fh6ayh1d --output text --query loa.loaContent|base64 --decode > myLoaCfa.pdf
```
**使用 Windows 描述連線的 LOA-CFA**  
先前的範例需要使用 `base64` 公用程式將輸出解碼。在 Windows 電腦上，您可以改為使用 `certutil`。在下列範例中，第一個命令描述連線 `dxcon-fh6ayh1d` 的 LOA-CFA，並使用 `--output` 和 `--query` 參數控制輸出，將 `loaContent` 結構的內容擷取至名為 `myLoaCfa.base64` 的檔案。第二個命令使用 `certutil` 公用程式將該檔案解碼並傳送輸出至 PDF 檔案。  

```
aws directconnect describe-loa --connection-id dxcon-fh6ayh1d --output text --query loa.loaContent > myLoaCfa.base64
```

```
certutil -decode myLoaCfa.base64 myLoaCfa.pdf
```
如需控制 AWS CLI 輸出的詳細資訊，請參閱《 [命令列界面使用者指南》中的從 AWS 命令列界面控制命令輸出](https://docs.aws.amazon.com/cli/latest/userguide/controlling-output.html)。 *AWS *  
+  如需 API 詳細資訊，請參閱《AWS CLI 命令參考》**中的 [DescribeLoa](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/directconnect/describe-loa.html)。

### `describe-locations`
<a name="direct-connect_DescribeLocations_cli_2_topic"></a>

以下程式碼範例顯示如何使用 `describe-locations`。

**AWS CLI**  
**列出 AWS Direct Connect 合作夥伴和位置**  
下列`describe-locations`命令列出目前區域中的 AWS Direct Connect 合作夥伴和位置：  

```
aws directconnect describe-locations
```
輸出：  

```
{
    "locations": [
        {
            "locationName": "NAP do Brasil, Barueri, Sao Paulo",
            "locationCode": "TNDB"
        },
        {
            "locationName": "Tivit - Site Transamerica (Sao Paulo)",
            "locationCode": "TIVIT"
        }
    ]
}
```
+  如需 API 詳細資訊，請參閱《AWS CLI 命令參考》**中的 [DescribeLocations](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/directconnect/describe-locations.html)。

### `describe-tags`
<a name="direct-connect_DescribeTags_cli_2_topic"></a>

以下程式碼範例顯示如何使用 `describe-tags`。

**AWS CLI**  
**描述 AWS Direct Connect 資源的標籤**  
下列命令描述連線 `dxcon-abcabc12` 的標籤。  
命令：  

```
aws directconnect describe-tags --resource-arns arn:aws:directconnect:us-east-1:123456789012:dxcon/dxcon-abcabc12
```
輸出：  

```
{
  "resourceTags": [
      {
          "resourceArn": "arn:aws:directconnect:us-east-1:123456789012:dxcon/dxcon-abcabc12",
          "tags": [
              {
                  "value": "VAConnection",
                  "key": "Name"
              }
          ]
      }
  ]
}
```
+  如需 API 詳細資訊，請參閱《AWS CLI 命令參考》**中的 [DescribeTags](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/directconnect/describe-tags.html)。

### `describe-virtual-gateways`
<a name="direct-connect_DescribeVirtualGateways_cli_2_topic"></a>

以下程式碼範例顯示如何使用 `describe-virtual-gateways`。

**AWS CLI**  
**列出虛擬私有閘道**  
下列`describe-virtual-gateways`命令會列出您 AWS 帳戶擁有的虛擬私有閘道：  

```
aws directconnect describe-virtual-gateways
```
輸出：  

```
{
    "virtualGateways": [
        {
            "virtualGatewayId": "vgw-aba37db6",
            "virtualGatewayState": "available"
        }
    ]
}
```
+  如需 API 詳細資訊，請參閱《AWS CLI 命令參考》**中的 [DescribeVirtualGateways](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/directconnect/describe-virtual-gateways.html)。

### `describe-virtual-interfaces`
<a name="direct-connect_DescribeVirtualInterfaces_cli_2_topic"></a>

以下程式碼範例顯示如何使用 `describe-virtual-interfaces`。

**AWS CLI**  
**列出所有虛擬介面**  
下列`describe-virtual-interfaces`命令會列出與 AWS 您的帳戶相關聯的所有虛擬介面的相關資訊：  

```
aws directconnect describe-virtual-interfaces --connection-id dxcon-ffjrkx17
```
輸出：  

```
{
    "virtualInterfaces": [
        {
            "virtualInterfaceState": "down",
            "asn": 65000,
            "vlan": 101,
            "customerAddress": "192.168.1.2/30",
            "ownerAccount": "123456789012",
            "connectionId": "dxcon-ffjrkx17",
            "virtualGatewayId": "vgw-aba37db6",
            "virtualInterfaceId": "dxvif-ffhhk74f",
            "authKey": "asdf34example",
            "routeFilterPrefixes": [],
            "location": "TIVIT",
            "customerRouterConfig": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<logical_connection id=\"dxvif-ffhhk74f\">\n  <vlan>101</vlan>\n  <customer_address>192.168.1.2/30</customer_address>\n  <amazon_address>192.168.1.1/30</amazon_address>\n  <bgp_asn>65000</bgp_asn>\n  <bgp_auth_key>asdf34example</bgp_auth_key>\n  <amazon_bgp_asn>7224</amazon_bgp_asn>\n  <connection_type>private</connection_type>\n</logical_connection>\n",
            "amazonAddress": "192.168.1.1/30",
            "virtualInterfaceType": "private",
            "virtualInterfaceName": "PrivateVirtualInterface"
        },
        {
            "virtualInterfaceState": "verifying",
            "asn": 65000,
            "vlan": 2000,
            "customerAddress": "203.0.113.2/30",
            "ownerAccount": "123456789012",
            "connectionId": "dxcon-ffjrkx17",
            "virtualGatewayId": "",
            "virtualInterfaceId": "dxvif-fgh0hcrk",
            "authKey": "asdf34example",
            "routeFilterPrefixes": [
                {
                    "cidr": "203.0.113.4/30"
                },
                {
                    "cidr": "203.0.113.0/30"
                }
            ],
            "location": "TIVIT",
            "customerRouterConfig": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<logical_connection id=\"dxvif-fgh0hcrk\">\n  <vlan>2000</vlan>\n  <customer_address>203.0.113.2/30</customer_address>\n  <amazon_address>203.0.113.1/30</amazon_address>\n  <bgp_asn>65000</bgp_asn>\n  <bgp_auth_key>asdf34example</bgp_auth_key>\n  <amazon_bgp_asn>7224</amazon_bgp_asn>\n  <connection_type>public</connection_type>\n</logical_connection>\n",
            "amazonAddress": "203.0.113.1/30",
            "virtualInterfaceType": "public",
            "virtualInterfaceName": "PublicVirtualInterface"
        }
    ]
}
```
+  如需 API 詳細資訊，請參閱《AWS CLI 命令參考》**中的 [DescribeVirtualInterfaces](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/directconnect/describe-virtual-interfaces.html)。

### `disassociate-connection-from-lag`
<a name="direct-connect_DisassociateConnectionFromLag_cli_2_topic"></a>

以下程式碼範例顯示如何使用 `disassociate-connection-from-lag`。

**AWS CLI**  
**取消 LAG 連線的關聯**  
下列範例會最消指定的連線與指定的 LAG 的關聯。  
命令：  

```
aws directconnect disassociate-connection-from-lag --lag-id dxlag-fhccu14t --connection-id  dxcon-fg9607vm
```
輸出：  

```
{
  "ownerAccount": "123456789012",
  "connectionId": "dxcon-fg9607vm",
  "connectionState": "requested",
  "bandwidth": "1Gbps",
  "location": "EqDC2",
  "connectionName": "Con2ForLag",
  "region": "us-east-1"
}
```
+  如需 API 詳細資訊，請參閱《*AWS CLI 命令參考*》中的 [DisassociateConnectionFromLag](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/directconnect/disassociate-connection-from-lag.html)。

### `tag-resource`
<a name="direct-connect_TagResource_cli_2_topic"></a>

以下程式碼範例顯示如何使用 `tag-resource`。

**AWS CLI**  
**將標籤新增至 AWS Direct Connect 資源**  
下列命令會新增具索引鍵 `Name`、值為 `VAConnection` 的標籤，並加入至連線 `dxcon-abcabc12`。如果命令成功，則不會傳回任何輸出。  
命令：  

```
aws directconnect tag-resource --resource-arn arn:aws:directconnect:us-east-1:123456789012:dxcon/dxcon-abcabc12 --tags "key=Name,value=VAConnection"
```
+  如需 API 詳細資訊，請參閱《AWS CLI 命令參考》**中的 [TagResource](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/directconnect/tag-resource.html)。

### `untag-resource`
<a name="direct-connect_UntagResource_cli_2_topic"></a>

以下程式碼範例顯示如何使用 `untag-resource`。

**AWS CLI**  
**從 AWS Direct Connect 資源移除標籤**  
下列命令會從連線 `dxcon-abcabc12` 移除具有索引鍵 `Name` 的標籤。如果命令成功，則不會傳回任何輸出。  
命令：  

```
aws directconnect untag-resource --resource-arn arn:aws:directconnect:us-east-1:123456789012:dxcon/dxcon-abcabc12 --tag-keys Name
```
+  如需 API 詳細資訊，請參閱《AWS CLI 命令參考》**中的 [UntagResource](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/directconnect/untag-resource.html)。

### `update-direct-connect-gateway-association`
<a name="direct-connect_UpdateDirectConnectGatewayAssociation_cli_2_topic"></a>

以下程式碼範例顯示如何使用 `update-direct-connect-gateway-association`。

**AWS CLI**  
**更新 Direct Connect 閘道關聯的指定屬性**  
下列 `update-direct-connect-gateway-association` 範例會將指定的 CIDR 區塊，新增至 Direct Connect 閘道關聯。  

```
aws directconnect update-direct-connect-gateway-association \
    --association-id 820a6e4f-5374-4004-8317-3f64bEXAMPLE \
    --add-allowed-prefixes-to-direct-connect-gateway cidr=192.168.2.0/30
```
輸出：  

```
{
    "directConnectGatewayAssociation": {
        "directConnectGatewayId": "11460968-4ac1-4fd3-bdb2-00599EXAMPLE",
        "directConnectGatewayOwnerAccount": "111122223333",
        "associationState": "updating",
        "associatedGateway": {
            "id": "tgw-02f776b1a7EXAMPLE",
            "type": "transitGateway",
            "ownerAccount": "111122223333",
            "region": "us-east-1"
        },
        "associationId": "820a6e4f-5374-4004-8317-3f64bEXAMPLE",
        "allowedPrefixesToDirectConnectGateway": [
            {
                "cidr": "192.168.2.0/30"
            },
            {
                "cidr": "192.168.1.0/30"
            }
        ]
    }
}
```
如需詳細資訊，請參閱《*AWS Direct Connect 使用者指南*》中的[使用者 Direct Connect 閘道](https://docs.aws.amazon.com/directconnect/latest/UserGuide/direct-connect-gateways.html)。  
+  如需 API 詳細資訊，請參閱《AWS CLI 命令參考》**中的 [UpdateDirectConnectGatewayAssociation](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/directconnect/update-direct-connect-gateway-association.html)。

### `update-lag`
<a name="direct-connect_UpdateLag_cli_2_topic"></a>

以下程式碼範例顯示如何使用 `update-lag`。

**AWS CLI**  
**更新 LAG**  
下列範例會變更指定的 LAG 名稱。  
命令：  

```
aws directconnect update-lag --lag-id dxlag-ffjhj9lx --lag-name 2ConnLag
```
輸出：  

```
{
  "awsDevice": "CSVA1-23u8tlpaz8iks",
  "numberOfConnections": 2,
  "lagState": "down",
  "ownerAccount": "123456789012",
  "lagName": "2ConnLag",
  "connections": [
      {
          "ownerAccount": "123456789012",
          "connectionId": "dxcon-fflqyj95",
          "lagId": "dxlag-ffjhj9lx",
          "connectionState": "requested",
          "bandwidth": "1Gbps",
          "location": "CSVA1",
          "connectionName": "Requested Connection 2 for Lag dxlag-ffjhj9lx",
          "region": "us-east-1"
      },
      {
          "ownerAccount": "123456789012",
          "connectionId": "dxcon-ffqr6x5q",
          "lagId": "dxlag-ffjhj9lx",
          "connectionState": "requested",
          "bandwidth": "1Gbps",
          "location": "CSVA1",
          "connectionName": "Requested Connection 1 for Lag dxlag-ffjhj9lx",
          "region": "us-east-1"
      }
  ],
  "lagId": "dxlag-ffjhj9lx",
  "minimumLinks": 0,
  "connectionsBandwidth": "1Gbps",
  "region": "us-east-1",
  "location": "CSVA1"
}
```
+  如需 API 詳細資訊，請參閱《AWS CLI 命令參考》**中的 [UpdateLag](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/directconnect/update-lag.html)。

### `update-virtual-interface-attributes`
<a name="direct-connect_UpdateVirtualInterfaceAttributes_cli_2_topic"></a>

以下程式碼範例顯示如何使用 `update-virtual-interface-attributes`。

**AWS CLI**  
**更新虛擬介面的 MTU**  
下列 `update-virtual-interface-attributes` 範例會更新指定虛擬介面的 MTU。  

```
aws directconnect update-virtual-interface-attributes \
    --virtual-interface-id dxvif-fEXAMPLE \
    --mtu 1500
```
輸出：  

```
{
    "ownerAccount": "1111222233333",
    "virtualInterfaceId": "dxvif-fEXAMPLE",
    "location": "loc1",
    "connectionId": "dxlag-fEXAMPLE",
    "virtualInterfaceType": "transit",
    "virtualInterfaceName": "example transit virtual interface",
    "vlan": 125,
    "asn": 650001,
    "amazonSideAsn": 64512,
    "authKey": "0xzxgA9YoW9h58u8SEXAMPLE",
    "amazonAddress": "169.254.248.1/30",
    "customerAddress": "169.254.248.2/30",
    "addressFamily": "ipv4",
    "virtualInterfaceState": "down",
    "customerRouterConfig": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<logical_connection id=\"dxvif-fEXAMPLE\">\n  <vlan>125</vlan>\n  <customer_address>169.254.248.2/30</customer_address>\n  <amazon_address>169.254.248.1/30</amazon_address>\n  <bgp_asn>650001</bgp_asn>\n  <bgp_auth_key>0xzxgA9YoW9h58u8SEXAMPLE</bgp_auth_key>\n  <amazon_bgp_asn>64512</amazon_bgp_asn>\n  <connection_type>transit</connection_type>\n</logical_connection>\n",
    "mtu": 1500,
    "jumboFrameCapable": true,
    "virtualGatewayId": "",
    "directConnectGatewayId": "879b76a1-403d-4700-8b53-4a56ed85436e",
    "routeFilterPrefixes": [],
    "bgpPeers": [
        {
            "bgpPeerId": "dxpeer-fEXAMPLE",
            "asn": 650001,
            "authKey": "0xzxgA9YoW9h58u8SEXAMPLE",
            "addressFamily": "ipv4",
            "amazonAddress": "169.254.248.1/30",
            "customerAddress": "169.254.248.2/30",
            "bgpPeerState": "available",
            "bgpStatus": "down",
            "awsDeviceV2": "loc1-26wz6vEXAMPLE"
        }
    ],
    "region": "sa-east-1",
    "awsDeviceV2": "loc1-26wz6vEXAMPLE",
    "tags": []
}
```
如需詳細資訊，請參閱《*AWS Direct Connect 使用者指南*》中的[設定私有虛擬介面或傳輸虛擬介面的網路 MTU](https://docs.aws.amazon.com/directconnect/latest/UserGuide/set-jumbo-frames-vif.html)。  
+  如需 API 詳細資訊，請參閱《AWS CLI 命令參考》**中的 [UpdateVirtualInterfaceAttributes](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/directconnect/update-virtual-interface-attributes.html)。