AWS Direct Connect 使用範例 AWS CLI - AWS Command Line Interface

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

AWS Direct Connect 使用範例 AWS CLI

下列程式碼範例說明如何使用 AWS Command Line Interface 與來執行動作及實作常見案例 AWS Direct Connect。

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

Scenarios (案例) 是向您展示如何呼叫相同服務中的多個函數來完成特定任務的程式碼範例。

每個範例都包含一個連結 GitHub,您可以在其中找到如何在內容中設定和執行程式碼的指示。

主題

動作

下列程式碼範例會示範如何使用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 直接 Connect 使用者指南中的接受或拒絕 Transit Gateway 聯提案

下列程式碼範例會示範如何使用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" }

下列程式碼範例會示範如何使用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" }

下列程式碼範例會示範如何使用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" }

下列程式碼範例會示範如何使用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" }

下列程式碼範例會示範如何使用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 使用手冊中的建立託管傳輸虛擬介面

下列程式碼範例會示範如何使用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" }

下列程式碼範例會示範如何使用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" }

下列程式碼範例會示範如何使用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" }

下列程式碼範例會示範如何使用confirm-connection

AWS CLI

確認在互連上建立託管連線的步驟

下列confirm-connection指令會確認在互連上建立託管連線:

aws directconnect confirm-connection --connection-id dxcon-fg2wi7hy

輸出:

{ "connectionState": "pending" }

下列程式碼範例會示範如何使用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" }

下列程式碼範例會示範如何使用confirm-public-virtual-interface

AWS CLI

接受公共虛擬界面的所有權

下列confirm-public-virtual-interface指令接受其他客戶建立的公用虛擬介面的所有權:

aws directconnect confirm-public-virtual-interface --virtual-interface-id dxvif-fg9xo9vp

輸出:

{ "virtualInterfaceState": "verifying" }

下列程式碼範例會示範如何使用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 直接連線使用手冊中的 Connect 受託管虛擬介面

下列程式碼範例會示範如何使用create-bgp-peer

AWS CLI

若要建立 IPv6 BGP 對等互連工作階段

下列範例會在私有虛擬介面上建立 IPv6 BGP 對等工作階段。dxvif-fg1vuj3d對等 IPv6 地址由 Amazon 自動分配。

命令:

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中的。

下列程式碼範例會示範如何使用create-connection

AWS CLI

建立從網路到 AWS 直 Connect 連線位置的連線

下列create-connection指令會建立從網路到「 AWS 直 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中的。

下列程式碼範例會示範如何使用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 直 Connect 使用指南中的建立 Transit Gateway 關聯提案

下列程式碼範例會示範如何使用create-direct-connect-gateway-association

AWS CLI

建立虛擬私人閘道與直 Connect 閘道的關聯

下列範例會將虛擬私vgw-6efe725e有閘道與直 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" } }

下列程式碼範例會示範如何使用create-direct-connect-gateway

AWS CLI

建立直接 Connect 閘道

下列範例會建立名稱為「直 Connect」閘道DxGateway1

命令:

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" } }

下列程式碼範例會示範如何使用create-interconnect

AWS CLI

若要建立合作夥伴網路和 AWS

下列create-interconnect指令會在直接連線夥伴的網路與特定 AWS 的「 AWS 直 Connect」位置之間建立互 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" }

下列程式碼範例會示範如何使用create-lag

AWS CLI

使用新連線建立 LAG

下列範例會建立 LAG,並針對頻寬為 1 Gbps 的 LAG 要求兩個新的 AWS 直 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中的。

下列程式碼範例會示範如何使用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" }

下列程式碼範例會示範如何使用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" }

下列程式碼範例會示範如何使用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" } ] } }

如需詳細資訊,請參閱 Direct Connect 使用手冊中的建立直接連線閘道的AWS 傳輸虛擬介面

下列程式碼範例會示範如何使用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中的。

下列程式碼範例會示範如何使用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中的。

下列程式碼範例會示範如何使用delete-direct-connect-gateway-association

AWS CLI

刪除直接 Connect 閘道關聯

下列delete-direct-connect-gateway-association範例會刪除與具有指定關聯識別碼之傳輸閘道之間的 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 直 Connect 使用指南」中的「關聯和取消傳輸閘道關聯」。

下列程式碼範例會示範如何使用delete-direct-connect-gateway

AWS CLI

刪除直接 Connect 閘道

下列範例會刪除直 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" } }

下列程式碼範例會示範如何使用delete-interconnect

AWS CLI

刪除相互連線的步驟

以下delete-interconnect命令刪除指定的互連:

aws directconnect delete-interconnect --interconnect-id dxcon-fgktov66

輸出:

{ "interconnectState": "deleted" }

下列程式碼範例會示範如何使用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中的。

下列程式碼範例會示範如何使用delete-virtual-interface

AWS CLI

刪除虛擬介面

下列指delete-virtual-interface令會刪除指定的虛擬介面:

aws directconnect delete-virtual-interface --virtual-interface-id dxvif-ffhhk74f

輸出:

{ "virtualInterfaceState": "deleting" }

下列程式碼範例會示範如何使用describe-connection-loa

AWS CLI

描述您使用 Linux 或 Mac OS X 連接的 LOA-非洲共同體法郎

下列範例說明連線的 LOA-CFA。dxcon-fh6ayh1dLOA-非洲金融共同體協會的內容是 64 位編碼的。此指令會使用--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-非洲共同體資料庫

前面的範例需要使用公用base64程式來解碼輸出。在 Windows 計算機上,您可以使用certutil代替。在下面的例子中,第一個命令描述了 LOA-CFA 連接,dxcon-fh6ayh1d並使用--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 令行介面使用者指南》中的〈從指AWS 令行介面控制指令輸出〉。

下列程式碼範例會示範如何使用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" } ] }

下列程式碼範例會示範如何使用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" } ] }

下列程式碼範例會示範如何使用describe-direct-connect-gateway-association-proposals

AWS CLI

說明您的直 Connect 閘道關聯提案

下列describe-direct-connect-gateway-association-proposals範例顯示有關直 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 直 Connect 使用指南」中的「關聯和取消傳輸閘道關聯」。

下列程式碼範例會示範如何使用describe-direct-connect-gateway-associations

AWS CLI

說明直 Connect 閘道關聯

下列範例說明與直 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" } ] }

下列程式碼範例會示範如何使用describe-direct-connect-gateway-attachments

AWS CLI

說明直 Connect 閘道附件

下列範例說明附加至直 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" }

下列程式碼範例會示範如何使用describe-direct-connect-gateways

AWS CLI

說明您的直 Connect 閘道

下列範例說明所有直接 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" } ] }

下列程式碼範例會示範如何使用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" } ] }

下列程式碼範例會示範如何使用describe-interconnect-loa

AWS CLI

描述您使用 Linux 或 Mac OS X 進行互連的 LOA-非洲共同體協會

下列範例說明您的 LOA-CFA 進行互連。dxcon-fh6ayh1dLOA-非洲金融共同體協會的內容是 64 位編碼的。此指令會使用--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-非洲金融共同體授權合作夥伴

前面的範例需要使用公用base64程式來解碼輸出。在 Windows 計算機上,您可以使用certutil代替。在下面的例子中,第一個命令描述了 LOA-CFA 用於互連,dxcon-fh6ayh1d並使用--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 令行介面使用者指南》中的〈從指AWS 令行介面控制指令輸出〉。

下列程式碼範例會示範如何使用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" } ] }

下列程式碼範例會示範如何使用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中的。

下列程式碼範例會示範如何使用describe-loa

AWS CLI

描述您使用 Linux 或 Mac OS X 連接的 LOA-非洲共同體法郎

下列範例說明連線的 LOA-CFA。dxcon-fh6ayh1dLOA-非洲金融共同體協會的內容是 64 位編碼的。此指令會使用--output--query參數來控制輸出並擷取loaContent結構的內容。命令的最後一部分使用該實用base64程序解碼內容,並將輸出發送到 PDF 文件。

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

若要描述使用 Windows 連線的 LOA-非洲共同體資料庫

前面的範例需要使用公用base64程式來解碼輸出。在 Windows 計算機上,您可以使用certutil代替。在下面的例子中,第一個命令描述了 LOA-CFA 連接,dxcon-fh6ayh1d並使用--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 令行介面使用者指南》中的〈從指AWS 令行介面控制指令輸出〉。

  • 如需 API 詳細資訊,請參閱AWS CLI 命令參考DescribeLoa中的。

下列程式碼範例會示範如何使用describe-locations

AWS CLI

列出 AWS 直接 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" } ] }

下列程式碼範例會示範如何使用describe-tags

AWS CLI

描述 AWS 直 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中的。

下列程式碼範例會示範如何使用describe-virtual-gateways

AWS CLI

列出虛擬私有閘道

下列describe-virtual-gateways指令會列出您 AWS 帳戶所擁有的虛擬私有閘道:

aws directconnect describe-virtual-gateways

輸出:

{ "virtualGateways": [ { "virtualGatewayId": "vgw-aba37db6", "virtualGatewayState": "available" } ] }

下列程式碼範例會示範如何使用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" } ] }

下列程式碼範例會示範如何使用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" }

下列程式碼範例會示範如何使用tag-resource

AWS CLI

若要將標籤新增至 AWS 直接 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中的。

下列程式碼範例會示範如何使用untag-resource

AWS CLI

若要從 AWS 直 Connect 資源移除標籤

以下命令Name從連接中刪除帶有密鑰的標籤dxcon-abcabc12。如果命令成功,則不會傳回任何輸出。

命令:

aws directconnect untag-resource --resource-arn arn:aws:directconnect:us-east-1:123456789012:dxcon/dxcon-abcabc12 --tag-keys Name
  • 如需 API 詳細資訊,請參閱AWS CLI 命令參考UntagResource中的。

下列程式碼範例會示範如何使用update-direct-connect-gateway-association

AWS CLI

更新直 Connect 閘道關聯的指定屬性

下列update-direct-connect-gateway-association範例會將指定的 CIDR 區塊新增至直 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" } ] } }

如需詳細資訊,請參閱直接 Connect 使用手冊中的使用AWS 直 Connect 閘道

下列程式碼範例會示範如何使用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中的。

下列程式碼範例會示範如何使用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 直 Connect 使用者指南》的〈設定私有虛擬介面的網路 MTU〉或傳輸虛擬介面