AWS CLI の使用 - AWS Direct Connect

翻訳は機械翻訳により提供されています。提供された翻訳内容と英語版の間で齟齬、不一致または矛盾がある場合、英語版が優先します。

AWS CLI の使用

AWS CLI を使用して AWS Direct Connect リソースを作成し、操作できます。

以下の例では、AWS CLI コマンドを使用して、AWS Direct Connect 接続を作成します。また、Letter of Authorization and Connecting Facility Assignment (LOA-CFA) をダウンロードしたり、プライベートまたはパブリック仮想インターフェイスをプロビジョニングしたりすることもできます。

開始する前に、AWS CLI がインストールされ、設定されていることを確認します。詳細については、AWS Command Line Interface ユーザーガイドを参照してください。

ステップ 1: 接続を作成する

最初のステップでは、接続リクエストを送信します。必要なポート速度と AWS Direct Connect ロケーションがわかっていることを確認します。詳細については、「AWS Direct Connect 接続」を参照してください。

接続リクエストを作成するには
  1. 現在のリージョンの AWS Direct Connect ロケーションについて説明します。返される出力で、接続を確立するロケーションのロケーションコードを書き留めます。

    aws directconnect describe-locations
    { "locations": [ { "locationName": "City 1, United States", "locationCode": "Example Location 1" }, { "locationName": "City 2, United States", "locationCode": "Example location" } ] }
  2. 接続を作成し、名前、ポート速度、およびロケーションコードを指定します。返される出力で、接続 ID を書き留めます。次のステップで LOA-CFA を取得するには、この ID が必要になります。

    aws directconnect create-connection --location Example location --bandwidth 1Gbps --connection-name "Connection to AWS"
    { "ownerAccount": "123456789012", "connectionId": "dxcon-EXAMPLE", "connectionState": "requested", "bandwidth": "1Gbps", "location": "Example location", "connectionName": "Connection to AWS", "region": "sa-east-1" }

ステップ 2: LOA-CFA をダウンロードする

接続をリクエストした後、describe-loa コマンドを使用して LOA-CFA を取得できます。出力は base64 でエンコードされます。関連する LOA コンテンツを抽出し、デコードして、PDF ファイルを作成する必要があります。

Linux または macOS を使用して LOA-CFA を取得するには

この例では、コマンドの最後の部分で base64 ユーティリティを使用してコンテンツをデコードし、出力を PDF ファイルに送信します。

aws directconnect describe-loa --connection-id dxcon-fg31dyv6 --output text --query loaContent|base64 --decode > myLoaCfa.pdf
Windows を使用して LOA-CFA を取得するには

この例では、出力は myLoaCfa.base64 というファイルに解凍されます。2 番目のコマンドでは、certutil ユーティリティを使用してファイルをデコードし、PDF ファイルに出力を送信します。

aws directconneawsct describe-loa --connection-id dxcon-fg31dyv6 --output text --query loaContent > myLoaCfa.base64
certutil -decode myLoaCfa.base64 myLoaCfa.pdf

LOA-CFA をダウンロードした後、ネットワークプロバイダーまたはコロケーションプロバイダーに送信します。

ステップ 3: 仮想インターフェイスを作成し、ルーター設定を取得する

AWS Direct Connect 接続を申し込んだ後、その接続の使用を開始するために仮想インターフェイスを作成する必要があります。プライベート仮想インターフェイスを作成して、VPC に接続することができます。または、VPC 外の AWS のサービスに接続するパブリック仮想インターフェイスを作成することもできます。IPv4 または IPv6 トラフィックをサポートする仮想インターフェイスを作成できます。

開始する前に、必ず「仮想インターフェイスの前提条件」の前提条件を参照してください。

AWS CLI を使用して仮想インターフェイスを作成すると、出力には汎用的なルーター設定情報が含まれます。デバイスに固有のルーター設定を作成するには、AWS Direct Connect コンソールを使用します。詳細については、「ルーター設定ファイルをダウンロードする」を参照してください。

プライベート仮想インターフェイスを作成するには
  1. VPC にアタッチされた仮想プライベートゲートウェイの ID (vgw-xxxxxxxx) を取得します。次のステップで仮想インターフェイスを作成するために、この ID が必要になります。

    aws ec2 describe-vpn-gateways
    { "VpnGateways": [ { "State": "available", "Tags": [ { "Value": "DX_VGW", "Key": "Name" } ], "Type": "ipsec.1", "VpnGatewayId": "vgw-ebaa27db", "VpcAttachments": [ { "State": "attached", "VpcId": "vpc-24f33d4d" } ] } ] }
  2. プライベート仮想インターフェイスを作成します。名前、VLAN ID、および BGP 自律システム番号 (ASN) を指定する必要があります。

    IPv4 トラフィックの場合、BGP ピアリングセッションの両側にプライベート IPv4 アドレスが必要です。独自の IPv4 アドレスを指定するか、このアドレスを自動的に生成できます。次の例では、IPv4 アドレスが自動的に生成されます。

    aws directconnect create-private-virtual-interface --connection-id dxcon-fg31dyv6 --new-private-virtual-interface virtualInterfaceName=PrivateVirtualInterface,vlan=101,asn=65000,virtualGatewayId=vgw-ebaa27db,addressFamily=ipv4
    { "virtualInterfaceState": "pending", "asn": 65000, "vlan": 101, "customerAddress": "192.168.1.2/30", "ownerAccount": "123456789012", "connectionId": "dxcon-fg31dyv6", "addressFamily": "ipv4", "virtualGatewayId": "vgw-ebaa27db", "virtualInterfaceId": "dxvif-ffhhk74f", "authKey": "asdf34example", "routeFilterPrefixes": [], "location": "Example location", "bgpPeers": [ { "bgpStatus": "down", "customerAddress": "192.168.1.2/30", "addressFamily": "ipv4", "authKey": "asdf34example", "bgpPeerState": "pending", "amazonAddress": "192.168.1.1/30", "asn": 65000 } "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" }

    IPv6 トラフィックをサポートするプライベート仮想インターフェイスを作成するには、上記と同じコマンドを使用して、ipv6 パラメーターに addressFamily を指定します。BGP ピアセッションに独自の IPv6 アドレスを指定することはできません。IPv6 アドレスは自動的に割り当てられます。

  3. ルーター設定情報を XML 形式で表示するには、作成した仮想インターフェイスについて説明します。--query パラメーターを使用して customerRouterConfig 情報を抽出し、--output パラメーターを使用してテキストをタブ区切り行に整理します。

    aws directconnect describe-virtual-interfaces --virtual-interface-id dxvif-ffhhk74f --query virtualInterfaces[*].customerRouterConfig --output text
    <?xml version="1.0" encoding="UTF-8"?> <logical_connection id="dxvif-ffhhk74f"> <vlan>101</vlan> <customer_address>192.168.1.2/30</customer_address> <amazon_address>192.168.1.1/30</amazon_address> <bgp_asn>65000</bgp_asn> <bgp_auth_key>asdf34example</bgp_auth_key> <amazon_bgp_asn>7224</amazon_bgp_asn> <connection_type>private</connection_type> </logical_connection>
パブリック仮想インターフェイスを作成するには
  1. パブリック仮想インターフェイスを作成するには、名前、VLAN ID、および BGP 自律システム番号 (ASN) を指定する必要があります。

    IPv4 トラフィックの場合は、BGP ピア接続の両端にパブリック IPv4 アドレスと、BGP 経由でアドバタイズするパブリック IPv4 ルートを指定する必要もあります。次の例では、IPv4 トラフィック用のパブリック仮想インターフェイスを作成します。

    aws directconnect create-public-virtual-interface --connection-id dxcon-fg31dyv6 --new-public-virtual-interface virtualInterfaceName=PublicVirtualInterface,vlan=2000,asn=65000,amazonAddress=203.0.113.1/30,customerAddress=203.0.113.2/30,addressFamily=ipv4,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-fg31dyv6", "addressFamily": "ipv4", "virtualGatewayId": "", "virtualInterfaceId": "dxvif-fgh0hcrk", "authKey": "asdf34example", "routeFilterPrefixes": [ { "cidr": "203.0.113.0/30" }, { "cidr": "203.0.113.4/30" } ], "location": "Example location", "bgpPeers": [ { "bgpStatus": "down", "customerAddress": "203.0.113.2/30", "addressFamily": "ipv4", "authKey": "asdf34example", "bgpPeerState": "verifying", "amazonAddress": "203.0.113.1/30", "asn": 65000 } ], "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" }

    IPv6 トラフィックをサポートするパブリック仮想インターフェイスを作成するには、BGP 経由でアドバタイズする IPv6 ルートを指定できます。ピアセッションに独自の IPv6 アドレスを指定することはできません。IPv6 アドレスは自動的に割り当てられます。次の例では、IPv6 トラフィック用のパブリック仮想インターフェイスを作成します。

    aws directconnect create-public-virtual-interface --connection-id dxcon-fg31dyv6 --new-public-virtual-interface virtualInterfaceName=PublicVirtualInterface,vlan=2000,asn=65000,addressFamily=ipv6,routeFilterPrefixes=[{cidr=2001:db8:64ce:ba00::/64},{cidr=2001:db8:64ce:ba01::/64}]
  2. ルーター設定情報を XML 形式で表示するには、作成した仮想インターフェイスについて説明します。--query パラメーターを使用して customerRouterConfig 情報を抽出し、--output パラメーターを使用してテキストをタブ区切り行に整理します。

    aws directconnect describe-virtual-interfaces --virtual-interface-id dxvif-fgh0hcrk --query virtualInterfaces[*].customerRouterConfig --output text

    <?xml version="1.0" encoding="UTF-8"?> <logical_connection id="dxvif-fgh0hcrk"> <vlan>2000</vlan> <customer_address>203.0.113.2/30</customer_address> <amazon_address>203.0.113.1/30</amazon_address> <bgp_asn>65000</bgp_asn> <bgp_auth_key>asdf34example</bgp_auth_key> <amazon_bgp_asn>7224</amazon_bgp_asn> <connection_type>public</connection_type> </logical_connection>