AWS Direct Connectの各種リソースをAWS CLIでDescribeしてみた

AWS Direct Connectの各種リソースをAWS CLIでDescribeしてみた

普段AWSマネジメントコンソールから参照する機会の多い各種AWS Direct ConnectのリソースをAWS CLIで参照してみました。
2025.09.22

コンバンハ、千葉(幸)です。

わたしはいろんなAWSリソースをAWS CLIで参照するのが好きです。触ったことがないサービスのリソースの全体像をパッと掴んだり、普段から使い慣れているリソースの詳細を改めて確認するのに便利だからです。

最近AWS Direct Connect関連のリソースを触る機会がありました。触るのがこれが初めてというわけではありませんが、これまではマネジメントコンソールだけで操作していました。今回は各種リソースをAWS CLIで参照して、解像度を高めてみたいと思います。

今回AWS CLIで参照するAWS Direct Connectのリソース

AWS CLIのaws directconnectコマンドで実行できるdescribe-系のコマンドの一覧(2025/09現在)とその概要、今回実行するかどうかをまとめました。

コマンド 概要 今回実行
describe-connections Direct Connect接続の詳細情報を取得 ⚪︎
describe-customer-metadata 顧客メタデータの情報を取得 ⚪︎
describe-direct-connect-gateway-association-proposals Direct Connectゲートウェイの関連付け提案を取得
describe-direct-connect-gateway-associations Direct Connectゲートウェイの関連付け情報を取得 ⚪︎
describe-direct-connect-gateway-attachments Direct Connectゲートウェイのアタッチメント情報を取得 ⚪︎
describe-direct-connect-gateways Direct Connectゲートウェイの詳細情報を取得 ⚪︎
describe-hosted-connections ホスト型接続の詳細情報を取得
describe-interconnects インターコネクトの詳細情報を取得
describe-lags Link Aggregation Group (LAG)の詳細情報を取得
describe-loa Letter of Authorization (LOA)の情報を取得 ⚪︎
describe-locations Direct Connect利用可能なロケーション情報を取得 ⚪︎
describe-router-configuration ルーター設定情報を取得 ⚪︎
describe-tags リソースに付与されたタグ情報を取得
describe-virtual-gateways 仮想プライベートゲートウェイの詳細情報を取得 ⚪︎
describe-virtual-interfaces 仮想インターフェースの詳細情報を取得 ⚪︎
  • ⚪︎:実行した
  • :実行したがエラー
  • :実行しない(該当するリソースが無いなど)

今回実行したコマンドを勝手に以下のように分類します。

  • A.Direct Connectリソース系
    1. describe-connections
    2. describe-virtual-interfaces
    3. describe-direct-connect-gateways
    4. describe-virtual-gateways
  • B. Direct Connectリソース間リソース系
    1. describe-direct-connect-gateway-attachments
    2. describe-direct-connect-gateway-associations
  • C. 実行したがエラー系
    1. describe-interconnects
    2. describe-hosted-connections
  • D. その他Direct Connect系
    1. describe-customer-metadata
    2. describe-loa
    3. describe-locations
    4. describe-router-configuration

以下の構成のもと各種対象にコマンド実行しました。

AWS DirectConnect Enviroment_null

AWS DirectConnect Enviroment

AWS CLI実行の前提条件

今回使用したAWS CLIのバージョンは以下です。

			
			$ aws --version
aws-cli/2.15.61 Python/3.11.8 Darwin/23.6.0 exe/x86_64

		

コマンド内のオプションとして指定はしていませんが、リージョンは全て東京(ap-northeast-1)です。

このブログの構成

以降は冒頭にまとめたコマンドを順番に取り上げていきます。計12個分です。コマンドごとに以下を書きます。

  • コマンドの簡単な説明
    • 1行まとめとCLIのリファレンスへのリンクを貼っています
  • コマンドの実行結果の項目のまとめ
    • AWS CLIのリファレンスで確認できるOutputを基に作成したまとめです。生成AIにまとめてもらいました
  • 実行結果のサンプル
    • 今回の構成で実際に実行した結果をマスクしたものです

A.Direct Connectリソース系

AWS DirectConnect Enviroment_A

1. describe-connections

Direct Connectのコネクション(接続)を参照するコマンドです。この後に出てくる仮想インターフェース(VIF)とあわせて分類を確認しておきたい方はこちらをご参考ください。

https://dev.classmethod.jp/articles/aws-direct-connect-connection-vif-organize-terms/

コマンドの実行結果の項目

項目名 概要 値例
ownerAccount 接続を所有するAWSアカウントのID 123456789012, 987654321098
connectionId 接続のID dxcon-abcd1234, dxcon-efgh5678
connectionName 接続の名前 prod-dx-connection, dev-dx-connection
connectionState 接続の状態 available, down, ordering, requested, pending, deleting, deleted, rejected, unknown
region 接続が配置されているAWSリージョン ap-northeast-1, us-east-1
location 接続のロケーション EqTY2, EqDC2
bandwidth 接続の帯域幅 1Gbps, 10Gbps, 100Mbps
vlan VLANのID 100, 200, 3000
partnerName 接続に関連付けられたDirect Connectサービスプロバイダーの名前 NTT Communications, KDDI
loaIssueTime 最新のDescribeLoaコールの時刻 2019-01-07T08:35:45+09:00, 2023-03-15T10:20:30+09:00
lagId LAGのID dxlag-abcd1234, dxlag-efgh5678
awsDevice 物理接続が終端するDirect Connectエンドポイント EqTY2-abcdefghijk, EqDC2-lmnopqrstuv
jumboFrameCapable ジャンボフレームがサポートされているかどうか true, false
awsDeviceV2 物理接続が終端するDirect Connectエンドポイント(V2) EqTY2-abcdefghijk, EqDC2-lmnopqrstuv
awsLogicalDeviceId 論理接続が終端するDirect Connectエンドポイント EqTY2-abcdefghijk, EqDC2-lmnopqrstuv
hasLogicalRedundancy 同じアドレスファミリでセカンダリBGPピアをサポートするかどうか yes, no, unknown
tags 接続に関連付けられたタグ [], [{"key": "Environment", "value": "Production"}]
providerName 接続に関連付けられたサービスプロバイダーの名前 NTT Communications, KDDI
macSecCapable MAC Security (MACsec)をサポートするかどうか true, false
portEncryptionStatus MAC Security (MACsec)ポートリンクステータス Encryption Up, Encryption Down
encryptionMode MAC Security (MACsec)接続暗号化モード no_encrypt, should_encrypt, must_encrypt
macSecKeys 接続に関連付けられたMAC Security (MACsec)セキュリティキー [], [{"secretARN": "arn:aws:...", "ckn": "...", "state": "associated"}]
partnerInterconnectMacSecCapable この接続をホストするインターコネクトがMAC Security (MACsec)をサポートするかどうか true, false

実行結果サンプル

「直接接続」のConnectionが1つある環境での実行です。

			
			$ aws directconnect describe-connections
{
    "connections": [
        {
            "ownerAccount": "123456789101",
            "connectionId": "dxcon-abcd123",
            "connectionName": "sample-connect",
            "connectionState": "available",
            "region": "ap-northeast-1",
            "location": "EqTY2",
            "bandwidth": "1Gbps",
            "loaIssueTime": "2019-01-07T08:35:45+09:00",
            "awsDevice": "EqTY2-aaaaaaaaaaaaa",
            "jumboFrameCapable": true,
            "awsDeviceV2": "EqTY2-123bbbbzzzzzz",
            "awsLogicalDeviceId": "EqTY2-123bbbbzzzzzz",
            "hasLogicalRedundancy": "no",
            "tags": [],
            "macSecCapable": false
        }
    ]
}

		

「直接接続」か「ホスト型接続」かが一目で分かるような項目はないようでした。

また、MACセキュリティ関連の各種項目は、"macSecCapable": falseの場合は軒並み表示されないことがわかりました。

2. describe-virtual-interfaces

仮想インターフェース(VIF)を参照するコマンドです。

コマンドの実行結果の項目

項目名 概要 値例
ownerAccount 仮想インターフェースを所有するAWSアカウントのID 123456789012, 987654321098
virtualInterfaceId 仮想インターフェースのID dxvif-abcd1234, dxvif-efgh5678
location 接続のロケーション EqTY2, TIVIT, EqDC2
connectionId 接続のID dxcon-abcd1234, dxcon-efgh5678
virtualInterfaceType 仮想インターフェースのタイプ private, public, transit
virtualInterfaceName 顧客が割り当てた仮想インターフェースの名前 prod-vif-01, PrivateVirtualInterface, PublicVirtualInterface
vlan VLANのID 96, 101, 2000
asn 自律システム番号(ASN)(1-2147483646) 65000, 65000, 64512
asnLong 長いASN(1-4294967294) 4200000000, 4294967294
amazonSideAsn Amazon側の自律システム番号 65001, 7224, 64512
authKey BGP設定の認証キー abcd1234example, examplekey11examplekey11
amazonAddress Amazonインターフェースに割り当てられたIPアドレス 169.254.252.1/30, 192.168.1.1/30, 203.0.113.1/30
customerAddress 顧客インターフェースに割り当てられたIPアドレス 169.254.252.2/30, 192.168.1.2/30, 203.0.113.2/30
addressFamily BGPピアのアドレスファミリ ipv4, ipv6
virtualInterfaceState 仮想インターフェースの状態 available, down, confirming, verifying, pending, testing, deleting, deleted, rejected, unknown
customerRouterConfig 顧客ルーター設定 <?xml version="1.0" encoding="UTF-8"?>...
mtu 最大転送単位(MTU)のバイト数 1500, 8500
jumboFrameCapable ジャンボフレームがサポートされているかどうか true, false
virtualGatewayId 仮想プライベートゲートウェイのID(プライベート仮想インターフェースのみ) vgw-abcd1234, ""
directConnectGatewayId Direct ConnectゲートウェイのID abcd1234-5678-90ab-cdef-1234567890ab, ""
routeFilterPrefixes このリージョンのAWSネットワークにアドバタイズされるルート [], [{"cidr": "203.0.113.4/30"}, {"cidr": "203.0.113.0/30"}]
bgpPeers この仮想インターフェースで設定されたBGPピア [{"bgpPeerId": "dxpeer-abcd1234", "asn": 65000, ...}]
region 仮想インターフェースが配置されているAWSリージョン ap-northeast-1, us-east-1
awsDeviceV2 物理接続が終端するDirect Connectエンドポイント EqTY2-abcdefghijk, EqDC2-lmnopqrstuv
awsLogicalDeviceId 論理接続が終端するDirect Connectエンドポイント EqTY2-abcdefghijk, EqDC2-lmnopqrstuv
tags 仮想インターフェースに関連付けられたタグ [], [{"key": "Environment", "value": "Production"}]
siteLinkEnabled SiteLinkが有効かどうか true, false

実行結果サンプル

「標準VIF」の「プライベートVIF」が1つのみある環境での実行です。

			
			$ aws directconnect describe-virtual-interfaces
{
    "virtualInterfaces": [
        {
            "ownerAccount": "123456789101",
            "virtualInterfaceId": "dxvif-123aaaaa",
            "location": "EqTY2",
            "connectionId": "dxcon-abcd123",
            "virtualInterfaceType": "private",
            "virtualInterfaceName": "sample-vif01",
            "vlan": 96,
            "asn": 65000,
            "amazonSideAsn": 65001,
            "authKey": "examplekey11examplekey11",
            "amazonAddress": "169.254.252.1/30",
            "customerAddress": "169.254.252.2/30",
            "addressFamily": "ipv4",
            "virtualInterfaceState": "available",
            "customerRouterConfig": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<logical_connection id=\"dxvif-123aaaaa\">\n  <vlan>96</vlan>\n  <customer_address>169.254.252.2/30</customer_address>\n  <amazon_address>169.254.252.1/30</amazon_address>\n  <bgp_asn>65000</bgp_asn>\n  <bgp_auth_key>examplekey11examplekey11</bgp_auth_key>\n  <amazon_bgp_asn>65001</amazon_bgp_asn>\n  <connection_type>private</connection_type>\n</logical_connection>\n",
            "mtu": 1500,
            "jumboFrameCapable": true,
            "virtualGatewayId": "",
            "directConnectGatewayId": "abcde123-aaaa-bbbb-abcdefabcde11",
            "routeFilterPrefixes": [],
            "bgpPeers": [
                {
                    "bgpPeerId": "dxpeer-aaa11bbb",
                    "asn": 65000,
                    "authKey": "examplekey11examplekey11",
                    "addressFamily": "ipv4",
                    "amazonAddress": "169.254.252.1/30",
                    "customerAddress": "169.254.252.2/30",
                    "bgpPeerState": "available",
                    "bgpStatus": "up",
                    "awsDeviceV2": "EqTY2-123bbbbzzzzzz",
                    "awsLogicalDeviceId": "EqTY2-123bbbbzzzzzz"
                }
            ],
            "region": "ap-northeast-1",
            "awsDeviceV2": "EqTY2-123bbbbzzzzzz",
            "awsLogicalDeviceId": "EqTY2-123bbbbzzzzzz",
            "tags": [],
            "siteLinkEnabled": false
        }
    ]
}

		

BGPピアのIDも採番されるんですね。似たような項目が繰り返し出てくるのも印象的です。

3. describe-direct-connect-gateways

Direct Connectゲートウェイを参照するコマンドです。

コマンドの実行結果の項目

項目名 概要 値例
directConnectGatewayId Direct ConnectゲートウェイのID abcd1234-5678-90ab-cdef-1234567890ab, efgh5678-90ab-cdef-1234-567890abcdef
directConnectGatewayName Direct Connectゲートウェイの名前 prod-dcg, DxGateway1, DxGateway2
amazonSideAsn Amazon側の自律システム番号(AS) 64512, 65001, 7224
ownerAccount Direct Connectゲートウェイを所有するAWSアカウントのID 123456789012, 987654321098
directConnectGatewayState Direct Connectゲートウェイの状態 available, pending, deleting, deleted
stateChangeError オブジェクトの状態が進行に失敗した場合のエラーメッセージ "Resource limit exceeded", "Invalid configuration"
tags Direct Connectゲートウェイに関連付けられたタグ [], [{"key": "Environment", "value": "Production"}]

実行結果サンプル

			
			$ aws directconnect describe-direct-connect-gateways
{
    "directConnectGateways": [
        {
            "directConnectGatewayId": "abcde123-aaaa-bbbb-abcdefabcde11",
            "directConnectGatewayName": "sample-dgw",
            "amazonSideAsn": 65001,
            "ownerAccount": "123456789101",
            "directConnectGatewayState": "available"
        }
    ]
}

		

Direct ConnectゲートウェイとVIFのアタッチメントや、Direct Connectゲートウェイと他のゲートウェイの関連付けはここには現れてこないので、シンプルな出力結果です。

4. describe-virtual-gateways

仮想プライベートゲートウェイ(VGW)を参照するコマンドですが、現在では非推奨(Deprecated)となっています。

コマンドの実行結果の項目

項目名 概要 設定値例
virtualGatewayId 仮想プライベートゲートウェイのID vgw-abcd1234, vgw-efgh5678
virtualGatewayState 仮想プライベートゲートウェイの状態 available, pending, deleting, deleted

実行サンプル

非推奨ですが、実行してみました。

			
			$ aws directconnect describe-virtual-gateways
{
    "virtualGateways": [
        {
            "virtualGatewayId": "vgw-abcde12345678abcde",
            "virtualGatewayState": "available"
        }
    ]
}

		

びっくりするくらいシンプルですね。

Ex. aws ec2 describe-vpn-gateways

非推奨となったdescribe-virtual-gatewaysの代わりに使用を推奨されているのがこちらのコマンドです。これはaws directconnectではなく、aws ec2のコマンドであることに注意してください。

コマンドの実行結果の項目

項目名 概要 設定値例
AmazonSideAsn BGPセッションのAmazon側のプライベート自律システム番号(ASN) 64512, 65001, 7224
Tags 仮想プライベートゲートウェイに割り当てられたタグ [], [{"Key": "Name", "Value": "prod-vgw"}]
VpnGatewayId 仮想プライベートゲートウェイのID vgw-abcd1234, vgw-efgh5678
State 仮想プライベートゲートウェイの現在の状態 available, pending, deleting, deleted
Type 仮想プライベートゲートウェイがサポートするVPN接続のタイプ ipsec.1
AvailabilityZone 仮想プライベートゲートウェイが作成されたアベイラビリティゾーン ""
VpcAttachments 仮想プライベートゲートウェイにアタッチされたVPC [], [{"VpcId": "vpc-abcd1234", "State": "attached"}]
  • AvailabilityZoneはEC2-Classic環境の名残りのようで、現在であればこの結果が返ってくることはほぼ無さそうです。
  • Typeは2025/09現在ipsec1のみが取りうる値です

--type (string)

The type of VPN connection this virtual private gateway supports.

Possible values:

  • ipsec.1

create-vpn-gateway — AWS CLI 2.28.21 Command Reference

実行結果サンプル

			
			$ aws ec2 describe-vpn-gateways
{
    "VpnGateways": [
        {
            "State": "available",
            "Type": "ipsec.1",
            "VpcAttachments": [
                {
                    "State": "attached",
                    "VpcId": "vpc-aaaabbbb"
                }
            ],
            "VpnGatewayId": "vgw-abcde12345678abcde",
            "AmazonSideAsn": 65001,
            "Tags": [
                {
                    "Key": "Name",
                    "Value": "sample-vgw"
                }
            ]
        }
    ]
}

		

やはりAvailabilityZoneは返ってきませんでした。項目としてそもそも返ってこない、という状態です。

B. Direct Connectリソース間リソース系

「リソース間リソース」という表現を勝手にしましたが、一般的ではないと思います。真似しないでください。

「関連づけ」とか「アタッチメント」を独立したリソースとして捉えるのがなんかしっくりこないな〜という個人的な思惑からの名付けです。

AWS DirectConnect Enviroment_B

1. describe-direct-connect-gateway-attachments

Direct ConnectゲートウェイへのVIFのアタッチメントを確認するコマンドです。Direct ConnectゲートウェイかVIFかどちらかのIDを指定しないとエラーになります。

			
			$ aws directconnect describe-direct-connect-gateway-attachments

An error occurred (DirectConnectClientException) when calling the DescribeDirectConnectGatewayAttachments operation: Either a Direct Connect Gateway ID or Virtual Interface ID must be set

		

コマンドの実行結果の項目

項目名 概要 値例
directConnectGatewayId Direct Connect ゲートウェイのID 12345678-abcd-1234-5678-abcdef123456
virtualInterfaceId 仮想インターフェースのID dxvif-12345678
virtualInterfaceRegion 仮想インターフェースが配置されているAWSリージョン us-east-1, us-west-2, ap-northeast-1
virtualInterfaceOwnerAccount 仮想インターフェースを所有するAWSアカウントのID 123456789012
attachmentState アタッチメントの状態 attaching, attached, detaching, detached
attachmentType アタッチメントのタイプ TransitVirtualInterface, PrivateVirtualInterface
stateChangeError オブジェクトの状態変更が失敗した場合のエラーメッセージ

stateChangeErrorは例が見つけられませんでした。たとえばアタッチしている最中にエラーになった場合はここに何らかメッセージが入る、ということでしょうか。

実行結果サンプル

			
			$ aws directconnect describe-direct-connect-gateway-attachments \
  --direct-connect-gateway-id abcde123-aaaa-bbbb-abcdefabcde11
{
    "directConnectGatewayAttachments": [
        {
            "directConnectGatewayId": "abcde123-aaaa-bbbb-abcdefabcde11",
            "virtualInterfaceId": "dxvif-123aaaaa",
            "virtualInterfaceRegion": "ap-northeast-1",
            "virtualInterfaceOwnerAccount": "123456789101",
            "attachmentState": "attached",
            "attachmentType": "privateVirtualInterface"
        }
    ]
}

		

今更ですがDirect ConnectゲートウェイのIDが例えばdxgw-のような接頭辞から始まるわけではないのは何ででしょうね。

2. describe-direct-connect-gateway-associations

Direct Connectゲートウェイの関連付けを参照するコマンドです。Direct Connectゲートウェイには仮想プライベートゲートウェイかトランジットゲートウェイを関連付けできます。

コマンドの実行結果の項目

項目名 概要 設定値例
directConnectGatewayId Direct Connect ゲートウェイのID 12ab34cd-5678-90ef-abcd-123456789abc
directConnectGatewayOwnerAccount Direct Connect ゲートウェイを所有するAWSアカウントのID 123456789012
associationState アソシエーションの状態 associating, associated, disassociating, disassociated, updating
stateChangeError オブジェクトの状態変更が失敗した場合のエラーメッセージ -
associatedGateway 関連付けられたゲートウェイの情報 {"id": "vgw-dummy123", "type": "virtualPrivateGateway", "ownerAccount": "123456789012", "region": "us-east-1"}
associationId Direct Connect ゲートウェイアソシエーションのID abcd1234-5678-abcd-1234-567890abcdef
allowedPrefixesToDirectConnectGateway Direct Connect ゲートウェイにアドバタイズするVPCプレフィックス [{"cidr": "192.168.100.0/24"}, {"cidr": "10.0.0.0/16"}]
associatedCoreNetwork Direct Connect ゲートウェイに関連付けられたCloud WAN コアネットワークの情報 {"id": "core-network-dummy123", "ownerAccount": "123456789012", "attachmentId": "attachment-dummy123"}
virtualGatewayId 仮想プライベートゲートウェイのID vgw-dummy123
virtualGatewayRegion 仮想プライベートゲートウェイが配置されているリージョン us-east-1, us-west-2, ap-northeast-1
virtualGatewayOwnerAccount 仮想プライベートゲートウェイを所有するAWSアカウントのID 123456789012

Direct Connectゲートウェイに関連付けできるゲートウェイは仮想プライベートゲートウェイとトランジットゲートウェイの2種類ですが、他にもCloud WANのコアネットワークを関連付けできるんですね。

https://dev.classmethod.jp/articles/aws-cloud-wan-on-premises-connectivity-direct-connect/

実行結果サンプル

Direct ConnectゲートウェイIDの指定が必要です。

			
			$ aws directconnect describe-direct-connect-gateway-associations \
  --direct-connect-gateway-id abcde123-aaaa-bbbb-abcdefabcde11
{
    "directConnectGatewayAssociations": [
        {
            "directConnectGatewayId": "abcde123-aaaa-bbbb-abcdefabcde11",
            "directConnectGatewayOwnerAccount": "123456789101",
            "associationState": "associated",
            "associatedGateway": {
                "id": "vgw-aaaaaaaabbbbbbbcc",
                "type": "virtualPrivateGateway",
                "ownerAccount": "987654321012",
                "region": "ap-northeast-1"
            },
            "associationId": "sample-uuid-1234-5678-9abc-def012345678",
            "allowedPrefixesToDirectConnectGateway": [
                {
                    "cidr": "192.168.100.0/24"
                }
            ],
            "virtualGatewayId": "vgw-aaaaaaaabbbbbbbcc",
            "virtualGatewayRegion": "ap-northeast-1",
            "virtualGatewayOwnerAccount": "987654321012"
        },
        {
            "directConnectGatewayId": "abcde123-aaaa-bbbb-abcdefabcde11",
            "directConnectGatewayOwnerAccount": "123456789101",
            "associationState": "associated",
            "associatedGateway": {
                "id": "vgw-abcde12345678abcde",
                "type": "virtualPrivateGateway",
                "ownerAccount": "123456789101",
                "region": "ap-northeast-1"
            },
            "associationId": "example-guid-abcd-efgh-ijkl-mnopqrstuvwx",
            "allowedPrefixesToDirectConnectGateway": [
                {
                    "cidr": "192.168.110.0/24"
                }
            ],
            "virtualGatewayId": "vgw-abcde12345678abcde",
            "virtualGatewayRegion": "ap-northeast-1",
            "virtualGatewayOwnerAccount": "123456789101"
        },
        {
            "directConnectGatewayId": "abcde123-aaaa-bbbb-abcdefabcde11",
            "directConnectGatewayOwnerAccount": "123456789101",
            "associationState": "associated",
            "associatedGateway": {
                "id": "vgw-ccccddddeeeeffffa",
                "type": "virtualPrivateGateway",
                "ownerAccount": "999999999999",
                "region": "ap-northeast-3"
            },
            "associationId": "dummy-id-9999-8888-7777-666655554444",
            "allowedPrefixesToDirectConnectGateway": [
                {
                    "cidr": "192.168.120.0/24"
                }
            ],
            "virtualGatewayId": "vgw-ccccddddeeeeffffa",
            "virtualGatewayRegion": "ap-northeast-3",
            "virtualGatewayOwnerAccount": "999999999999"
        }
    ]
}

		

3つの関連付けがある環境だったので、3つ表示されました。

C. 実行したがエラー系

Direct Connectパートナーでないと実行できないコマンドを実行してエラーになった例です。

AWS DirectConnect Enviroment_C

1. describe-interconnects

InterConnectを参照するコマンドです。InterConnectは、Direct Connectパートナーがホスト型接続を提供する際に用いる接続です。

コマンドの実行結果の項目

項目名 概要 値例
interconnectId インターコネクトのID dxcon-xxxxxxxxx
interconnectName インターコネクトの名前 1G Interconnect to AWS
interconnectState インターコネクトの状態 requested, pending, available, down, deleting, deleted, unknown
region 接続が配置されているAWSリージョン sa-east-1
location 接続のロケーション TIVIT
bandwidth 接続の帯域幅 1Gbps
loaIssueTime このインターコネクトに対するDescribeLoaの最新の呼び出し時刻 2023-01-15T10:30:00Z
lagId LAGのID lag-xxxxxxxxx
awsDevice 物理接続が終端するDirect Connectエンドポイント EqDC2-12345678
jumboFrameCapable ジャンボフレームがサポートされているかどうか true, false
awsDeviceV2 物理接続が終端するDirect Connectエンドポイント(V2) EqDC2-12345678
awsLogicalDeviceId 論理接続が終端するDirect Connectエンドポイント device-xxxxxxxxx
hasLogicalRedundancy 同じアドレスファミリでセカンダリBGPをサポートするかどうか yes, no, unknown
tags インターコネクトに関連付けられたタグ [{"key": "Environment", "value": "Production"}]
providerName インターコネクトに関連付けられたサービスプロバイダーの名前 Example Provider
macSecCapable MAC Security (MACsec)をサポートするかどうか true, false
portEncryptionStatus MAC Security (MACsec)ポートリンクステータス Encryption Up, Encryption Down
encryptionMode MAC Security (MACsec)暗号化モード no_encrypt, should_encrypt, must_encrypt
macSecKeys MAC Security (MACsec)セキュリティキー [{"secretARN": "arn:aws:secretsmanager:region:account:secret:name", "ckn": "01234567890123456789012345678901", "state": "associated"}]

describe-connectionsの出力と似た内容になっていますね。

実行結果サンプル(エラー)

			
			$ aws directconnect describe-interconnects

An error occurred (DirectConnectClientException) when calling the DescribeInterconnects operation: Account 123456789101 is not an authorized Direct Connect partner in ap-northeast-1.

		

2. describe-hosted-connections

InterConnectもしくはLAGにプロビジョンされたホスト型接続を参照するコマンドです。

コマンドの実行結果の項目

項目名 概要 値例
ownerAccount 接続を所有するAWSアカウントのID 123456789012
connectionId 接続のID dxcon-ffnikghc
connectionName 接続の名前 mydcinterconnect
connectionState 接続の状態 orderingrequestedpendingavailabledowndeletingdeletedrejectedunknown
region 接続が配置されているAWSリージョン sa-east-1
location 接続の場所 TIVIT
bandwidth 接続の帯域幅 500Mbps
vlan VLANのID 101
partnerName 接続に関連付けられたDirect Connectサービスプロバイダーの名前 TIVIT
loaIssueTime この接続に対するDescribeLoaの最新の呼び出し時刻 2023-01-15T10:30:00Z
lagId LAGのID dxlag-fgsu9erb
awsDevice 物理接続が終端するDirect Connectエンドポイント EqDC2-19y7z3m17xpuz
jumboFrameCapable ジャンボフレームがサポートされているかどうか truefalse
awsDeviceV2 物理接続が終端するDirect Connectエンドポイント(V2) EqDC2-12345678-1
awsLogicalDeviceId 論理接続が終端するDirect Connectエンドポイント EqDC2-12345678-2
hasLogicalRedundancy 同じアドレスファミリでセカンダリBGPピアをサポートするかどうか yesnounknown
tags 接続に関連付けられたタグ [{"key": "Environment", "value": "Production"}]
providerName 接続に関連付けられたサービスプロバイダーの名前 AWS Direct Connect
macSecCapable MAC Security(MACsec)をサポートするかどうか truefalse
portEncryptionStatus MAC Security(MACsec)ポートリンクステータス Encryption UpEncryption Down
encryptionMode MAC Security(MACsec)接続暗号化モード no_encryptshould_encryptmust_encrypt
macSecKeys 接続に関連付けられたMAC Security(MACsec)セキュリティキー [{"secretARN": "arn:aws:secretsmanager:us-east-1:123456789012:secret:name-abc123", "ckn": "0123456789abcdef", "state": "associated", "startOn": "2023-01-15T00:00:00Z"}]
partnerInterconnectMacSecCapable この接続をホストするインターコネクトがMAC Securityをサポートするかどうか truefalse

これもdescribe-connectionsの出力と似た内容になっていますね。直接接続であれホスト型接続であれInterConnectであれ、「接続」という括りだからでしょうかね。

実行結果サンプル(エラー)

実行時にはコネクションIDの指定が必要です。が、Direct Connectパートナーとして認可されたAWSアカウントでない場合、適当な文字列を指定するだけでもエラーが出ます。

			
			$ aws directconnect describe-hosted-connections \
  --connection-id aaa

An error occurred (DirectConnectClientException) when calling the DescribeHostedConnections operation: Account 123456789101 is not an authorized Direct Connect partner in ap-northeast-1.

		

D. その他Direct Connect系

雑多に「その他」とまとめたものたちです。

AWS DirectConnect Enviroment_D

1. describe-customer-metadata

特定のリソースを参照するわけではなく、カスタマー(AWSアカウント)のメタデータを参照するものです。アグリーメントや署名状況、パートナーのステータスを表します。

コマンドの実行結果の項目

項目名 概要 値例
agreements 顧客契約のリスト [{"agreementName": "Direct Connect Agreement", "status": "signed"}]
nniPartnerType ネットワーク間インターフェース(NNI)パートナーのタイプ V1, V2, nonPartner

実行結果サンプル

			
			$ aws directconnect describe-customer-metadata
{
    "agreements": [
        {
            "agreementName": "DirectConnectGatewayInChina.V1",
            "status": "unsigned"
        }
    ],
    "nniPartnerType": "nonPartner"
}

		

おそらくデフォルトであろう、署名をしておらずパートナーでもない状態です。

2. describe-loa

LOA-CFA(Letter of Authorization - Connecting Facility Assignment)をダウンロードするためのものです。マネジメントコンソールでConnectionの詳細画面からダウンロードできるものと同じです。

コマンドの実行結果の項目

項目名 概要 値例
loaContent LOA-CFA文書のバイナリコンテンツ JVBERi0xLjQKJcfsj6IKNSAwIG9iago8PAovTGVuZ3RoIDYgMCBSCi9GaWx0ZXIgL0ZsYXRlRGVjb2RlCj4+CnN0cmVhbQp4nF...
loaContentType LOA-CFA文書の標準メディアタイプ application/pdf

実行結果サンプル

			
			$ aws directconnect describe-loa \
  --connection-id dxcon-abcd123
{
    "loaContent": "XXXXXRU9GCg==.....以下数万文字",
    "loaContentType": "application/pdf"
}

		

👆loaContentはとんでもない分量です。

以下のようにデコードした上でPDFファイルに保存しましょう。

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

		

保存されたPDFファイルはこのような内容です。(大部分マスクして粗くしているので雰囲気だけ読み取ってください。)

myLoaCfa_pdf

ちなみに2025年9月現在のCLIリファレンスではコマンド例が--query loa.loaContentのようになっていますが、実際にはloa.が不要であることに注意してください。

describe-loa_—_AWS_CLI_2_28_21_Command_Reference

3.describe-locations

Direct Connectロケーションを参照するものです。特定のアカウントに依存するわけではなく、パブリックな情報を引いてくるものです。

コマンドの実行結果の項目

項目名 概要 値例
locationCode ロケーションのコード TNDB
locationName ロケーションの名前(コロケーションパートナー名と建物の物理サイトを含む) NAP do Brasil, Barueri, Sao Paulo
region ロケーションのAWSリージョン us-east-1
availablePortSpeeds ロケーションで利用可能なポート速度 ["1Gbps", "10Gbps", "100Gbps"]
availableProviders ロケーションのサービスプロバイダー名 ["Provider A", "Provider B"]
availableMacSecPortSpeeds ロケーションで利用可能なMAC Security (MACsec)ポート速度 ["10Gbps", "100Gbps"]

実行結果サンプル

			
			$ aws directconnect describe-locations
{
    "locations": [
        {
            "locationCode": "EqTY2",
            "locationName": "Equinix TY2, Tokyo, Japan",
            "region": "ap-northeast-1",
            "availablePortSpeeds": [
                "100G",
                "1G",
                "10G"
            ],
            "availableProviders": [
                "Datapath.io GmbH",
                "InterCloud",
                "Sejong",
....以下略

		

長くてこのブログの文字制限に引っかかってしまったので以下にまとめました。実行結果を元に簡単な表も作ったのであわせてご参照ください。

https://zenn.dev/batchi/scraps/7771725908eaaa

4. describe-router-configuration

カスタマールーター用の設定ファイルサンプルをダウンロードするためのものです。マネジメントコンソールからダウンロードできるものと同じです。

DXVIF2

DXVIF-6716102

コマンドの実行結果の項目

項目名 概要 値例
customerRouterConfig 顧客ルーターの設定 interface GigabitEthernet0/0/0\n description Direct Connect to AWS\n no ip address\n negotiation auto
router ルーターの詳細情報 {"vendor": "Cisco Systems Inc.", "platform": "2900 Series Routers", "software": "IOS 12.4"}
virtualInterfaceId 仮想インターフェースに割り当てられたID dxvif-xxxxxxxxx
virtualInterfaceName 仮想インターフェースの名称 My VIF Router Config

実行結果サンプル

--router-type-identifierを指定しないとエラーになりました。

			
			$ aws directconnect describe-router-configuration \
  --virtual-interface-id dxvif-123aaaaa

An error occurred (DirectConnectClientException) when calling the DescribeRouterConfiguration operation: Unable to generate router config with exception com.amazon.awsdx.overture.DirectConnectClientException: Unable to find router type with identifier null

		

指定するとこのような結果に。

			
			$ aws directconnect describe-router-configuration \
  --virtual-interface-id dxvif-123aaaaa \
  --router-type-identifier CiscoSystemsInc-2900SeriesRouters-IOS124
{
    "customerRouterConfig": "! Amazon Web Services\n!=======================================IPV4=======================================\n! Direct Connect\n! Virtual Interface ID: dxvif-123aaaaa\n!\n! ------------------------------------中略       http://docs.amazonwebservices.com/Direc
n apply a community tag to indicate the priority of the associated path for returning traffic.\n! The follow
tConnect/latest/GettingStartedGuide/Welcome.html\n\n        ",
    "router": {
        "vendor": "Cisco Systems, Inc.",
        "platform": "2900 Series Routers",
        "software": "IOS 12.4+",
        "xsltTemplateName": "customer-router-cisco-generic.xslt",
        "xsltTemplateNameForMacSec": "",
        "routerTypeIdentifier": "CiscoSystemsInc-2900SeriesRouters-IOS124"
    },
    "virtualInterfaceId": "dxvif-123aaaaa",
    "virtualInterfaceName": "sample-vif01"
}

		

customerRouterConfigの部分だけを抜き出して改行を除去すればルーターコンフィグのサンプルが入手できます。

ただ、--router-type-identifierとして指定しうるIDの一覧が見つけられなかったので、どこかから手探りで探し当てるしかなさそうです。それをやるくらいならマネジメントコンソールからダウンロードすればいいのでは……となりました。

まとめ

今回は以下のAWS CLIコマンドを実行しました。

AWS DirectConnect Enviroment

  • A.Direct Connectリソース系
    1. describe-connections
    2. describe-virtual-interfaces
    3. describe-direct-connect-gateways
    4. describe-virtual-gateways
  • B. Direct Connectリソース間リソース系
    1. describe-direct-connect-gateway-attachments
    2. describe-direct-connect-gateway-associations
  • C. 実行したがエラー系
    1. describe-interconnects
    2. describe-hosted-connections
  • D. その他Direct Connect系
    1. describe-customer-metadata
    2. describe-loa
    3. describe-locations
    4. describe-router-configuration

終わりに

AWS Direct ConnectのDescribe系のコマンドをたくさん叩いてみました。

普段マネジメントコンソールから参照する機会の多いDirect Connectリソースですが、より詳細にイメージがついた気がします。たくさん実行したので、どこかしらが参考になれば幸いです。

以上、チバユキ (@batchicchi)がお送りしました。

この記事をシェアする

FacebookHatena blogX

関連記事