

本文属于机器翻译版本。若本译文内容与英语原文存在差异，则一律以英文原文为准。

# 将 `DescribeCustomerGateways` 与 CLI 配合使用
<a name="example_ec2_DescribeCustomerGateways_section"></a>

以下代码示例演示如何使用 `DescribeCustomerGateways`。

------
#### [ CLI ]

**AWS CLI**  
**描述客户网关**  
此示例描述客户网关。  
命令:  

```
aws ec2 describe-customer-gateways
```
输出：  

```
{
    "CustomerGateways": [
        {
            "CustomerGatewayId": "cgw-b4dc3961",
            "IpAddress": "203.0.113.12",
            "State": "available",
            "Type": "ipsec.1",
            "BgpAsn": "65000"
        },
        {
            "CustomerGatewayId": "cgw-0e11f167",
            "IpAddress": "12.1.2.3",
            "State": "available",
            "Type": "ipsec.1",
            "BgpAsn": "65534"
        }
    ]
}
```
**描述特定的客户网关**  
此示例描述指定的客户网关。  
命令:  

```
aws ec2 describe-customer-gateways --customer-gateway-ids cgw-0e11f167
```
输出：  

```
{
    "CustomerGateways": [
        {
            "CustomerGatewayId": "cgw-0e11f167",
            "IpAddress": "12.1.2.3",
            "State": "available",
            "Type": "ipsec.1",
            "BgpAsn": "65534"
        }
    ]
}
```
+  有关 API 的详细信息，请参阅*AWS CLI 命令参考[DescribeCustomerGateways](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/ec2/describe-customer-gateways.html)*中的。

------
#### [ PowerShell ]

**适用于 PowerShell V4 的工具**  
**示例 1：此示例描述指定的客户网关。**  

```
Get-EC2CustomerGateway -CustomerGatewayId cgw-1a2b3c4d
```
**输出**：  

```
BgpAsn            : 65534
CustomerGatewayId : cgw-1a2b3c4d
IpAddress         : 203.0.113.12
State             : available
Tags              : {}
Type              : ipsec.1
```
**示例 2：此示例描述状态为待定或可用的所有客户网关。**  

```
$filter = New-Object Amazon.EC2.Model.Filter
$filter.Name = "state"
$filter.Values = @( "pending", "available" )

Get-EC2CustomerGateway -Filter $filter
```
**示例 3：此示例描述所有客户网关。**  

```
Get-EC2CustomerGateway
```
+  有关 API 的详细信息，请参阅 *AWS Tools for PowerShell Cmdlet 参考 (V* 4) [DescribeCustomerGateways](https://docs.aws.amazon.com/powershell/v4/reference)中的。

**适用于 PowerShell V5 的工具**  
**示例 1：此示例描述指定的客户网关。**  

```
Get-EC2CustomerGateway -CustomerGatewayId cgw-1a2b3c4d
```
**输出**：  

```
BgpAsn            : 65534
CustomerGatewayId : cgw-1a2b3c4d
IpAddress         : 203.0.113.12
State             : available
Tags              : {}
Type              : ipsec.1
```
**示例 2：此示例描述状态为待定或可用的所有客户网关。**  

```
$filter = New-Object Amazon.EC2.Model.Filter
$filter.Name = "state"
$filter.Values = @( "pending", "available" )

Get-EC2CustomerGateway -Filter $filter
```
**示例 3：此示例描述所有客户网关。**  

```
Get-EC2CustomerGateway
```
+  有关 API 的详细信息，请参阅 *AWS Tools for PowerShell Cmdlet 参考 (V* 5) [DescribeCustomerGateways](https://docs.aws.amazon.com/powershell/v5/reference)中的。

------

有关 S AWS DK 开发者指南和代码示例的完整列表，请参阅[使用 AWS SDK 创建 Amazon EC2 资源](sdk-general-information-section.md)。本主题还包括有关入门的信息以及有关先前的 SDK 版本的详细信息。