

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

# 使用 的 API Gateway HTTP 和 WebSocket API 範例 AWS CLI
<a name="cli_apigatewayv2_code_examples"></a>

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

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

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

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

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

### `create-api-mapping`
<a name="apigatewayv2_CreateApiMapping_cli_topic"></a>

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

**AWS CLI**  
**為 API 建立 API 映射**  
下列 `create-api-mapping` 範例將 API 的 `test` 階段映射至 `regional.example.com` 自訂網域名稱的 `/myApi` 路徑。  

```
aws apigatewayv2 create-api-mapping \
    --domain-name regional.example.com \
    --api-mapping-key myApi \
    --api-id a1b2c3d4 \
    --stage test
```
輸出：  

```
{
    "ApiId": "a1b2c3d4",
    "ApiMappingId": "0qzs2sy7bh",
    "ApiMappingKey": "myApi"
    "Stage": "test"
}
```
如需詳細資訊，請參閱《*Amazon API Gateway 開發人員指南*》中的[在 API Gateway 中設定區域自訂網域名稱](https://docs.aws.amazon.com/apigateway/latest/developerguide/apigateway-regional-api-custom-domain-create.html)。  
+  如需 API 詳細資訊，請參閱《AWS CLI 命令參考》**中的 [CreateApiMapping](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/apigatewayv2/create-api-mapping.html)。

### `create-api`
<a name="apigatewayv2_CreateApi_cli_topic"></a>

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

**AWS CLI**  
**建立 HTTP API**  
下列 `create-api` 範例透過使用快速建立來建立 HTTP API。您可以使用快速建立來建立具有 AWS Lambda 或 HTTP 整合的 API、預設全部擷取路由，以及設定為自動部署變更的預設階段。以下命令使用快速建立功能來建立與 Lambda 函式整合的 HTTP API。  

```
aws apigatewayv2 create-api \
    --name my-http-api \
    --protocol-type HTTP \
    --target arn:aws:lambda:us-west-2:123456789012:function:my-lambda-function
```
輸出：  

```
{
    "ApiEndpoint": "https://a1b2c3d4.execute-api.us-west-2.amazonaws.com",
    "ApiId": "a1b2c3d4",
    "ApiKeySelectionExpression": "$request.header.x-api-key",
    "CreatedDate": "2020-04-08T19:05:45+00:00",
    "Name": "my-http-api",
    "ProtocolType": "HTTP",
    "RouteSelectionExpression": "$request.method $request.path"
}
```
如需詳細資訊，請參閱《*Amazon API Gateway 開發人員指南*》中的[在 Amazon API Gateway 中開發 HTTP API](https://docs.aws.amazon.com/apigateway/latest/developerguide/http-api-develop.html)。  
**建立 WebSocket API**  
下列 `create-api` 範例建立具有指定名稱的 WebSocket API。  

```
aws apigatewayv2 create-api \
    --name "myWebSocketApi" \
    --protocol-type WEBSOCKET \
    --route-selection-expression '$request.body.action'
```
輸出：  

```
{
    "ApiKeySelectionExpression": "$request.header.x-api-key",
    "Name": "myWebSocketApi",
    "CreatedDate": "2018-11-15T06:23:51Z",
    "ProtocolType": "WEBSOCKET",
    "RouteSelectionExpression": "'$request.body.action'",
    "ApiId": "aabbccddee"
}
```
如需詳細資訊，請參閱《*Amazon API Gateway 開發人員指南*》中的[在 API Gateway 中建立 WebSocket API](https://docs.aws.amazon.com/apigateway/latest/developerguide/apigateway-websocket-api-create-empty-api.html)。  
+  如需 API 詳細資訊，請參閱《AWS CLI 命令參考》**中的 [CreateApi](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/apigatewayv2/create-api.html)。

### `create-authorizer`
<a name="apigatewayv2_CreateAuthorizer_cli_topic"></a>

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

**AWS CLI**  
**為 HTTP API 建立 JWT 授權方**  
以下 `create-authorizer` 範例建立一個使用 Amazon Cognito 做為身分提供者的 JWT 授權方。  

```
aws apigatewayv2 create-authorizer \
    --name my-jwt-authorizer \
    --api-id a1b2c3d4 \
    --authorizer-type JWT \
    --identity-source '$request.header.Authorization' \
    --jwt-configuration Audience=123456abc,Issuer=https://cognito-idp.us-west-2.amazonaws.com/us-west-2_abc123
```
輸出：  

```
{
    "AuthorizerId": "a1b2c3",
    "AuthorizerType": "JWT",
    "IdentitySource": [
        "$request.header.Authorization"
    ],
    "JwtConfiguration": {
        "Audience": [
            "123456abc"
        ],
        "Issuer": "https://cognito-idp.us-west-2.amazonaws.com/us-west-2_abc123"
    },
    "Name": "my-jwt-authorizer"
}
```
如需詳細資訊，請參閱《*Amazon API Gateway 開發人員指南*》中的[使用 JWT 授權方控制對 HTTP API 的存取](https://docs.aws.amazon.com/apigateway/latest/developerguide/http-api-jwt-authorizer.html)。  
+  如需 API 詳細資訊，請參閱《AWS CLI 命令參考》**中的 [CreateAuthorizer](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/apigatewayv2/create-authorizer.html)。

### `create-deployment`
<a name="apigatewayv2_CreateDeployment_cli_topic"></a>

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

**AWS CLI**  
**為 API 建立部署**  
以下 `create-deployment` 範例建立 API 的部署，並為該部署與 API 的 `dev` 階段建立關聯。  

```
aws apigatewayv2 create-deployment \
    --api-id a1b2c3d4 \
    --stage-name dev
```
輸出：  

```
{
    "AutoDeployed": false,
    "CreatedDate": "2020-04-06T23:38:08Z",
    "DeploymentId": "53lz9l",
    "DeploymentStatus": "DEPLOYED"
}
```
如需詳細資訊，請參閱《*Amazon API Gateway 開發人員指南*》中的 [API 部署](https://docs.aws.amazon.com/apigateway/latest/developerguide/api-gateway-basic-concept.html#apigateway-definition-api-deployment)。  
+  如需 API 詳細資訊，請參閱《AWS CLI 命令參考》**中的 [CreateDeployment](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/apigatewayv2/create-deployment.html)。

### `create-domain-name`
<a name="apigatewayv2_CreateDomainName_cli_topic"></a>

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

**AWS CLI**  
**建立自訂網域名稱**  
下列 `create-domain-name` 範例為 API 建立區域自訂網域名稱。  

```
aws apigatewayv2 create-domain-name \
    --domain-name regional.example.com \
    --domain-name-configurations CertificateArn=arn:aws:acm:us-west-2:123456789012:certificate/123456789012-1234-1234-1234-12345678
```
輸出：  

```
{
    "ApiMappingSelectionExpression": "$request.basepath",
    "DomainName": "regional.example.com",
    "DomainNameConfigurations": [
        {
            "ApiGatewayDomainName": "d-id.execute-api.us-west-2.amazonaws.com",
            "CertificateArn": "arn:aws:acm:us-west-2:123456789012:certificate/123456789012-1234-1234-1234-12345678",
            "EndpointType": "REGIONAL",
            "HostedZoneId": "123456789111",
            "SecurityPolicy": "TLS_1_2",
            "DomainNameStatus": "AVAILABLE"
        }
    ]
}
```
如需詳細資訊，請參閱《*Amazon API Gateway 開發人員指南*》中的[在 API Gateway 中設定區域自訂網域名稱](https://docs.aws.amazon.com/apigateway/latest/developerguide/apigateway-regional-api-custom-domain-create.html)。  
+  如需 API 詳細資訊，請參閱《AWS CLI 命令參考》**中的 [CreateDomainName](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/apigatewayv2/create-domain-name.html)。

### `create-integration`
<a name="apigatewayv2_CreateIntegration_cli_topic"></a>

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

**AWS CLI**  
**建立 WebSocket API 整合**  
下列 `create-integration` 範例為 WebSocket API 建立模擬整合。  

```
aws apigatewayv2 create-integration \
    --api-id aabbccddee \
    --passthrough-behavior WHEN_NO_MATCH \
    --timeout-in-millis 29000 \
    --connection-type INTERNET \
    --integration-type MOCK
```
輸出：  

```
{
    "ConnectionType": "INTERNET",
    "IntegrationId": "0abcdef",
    "IntegrationResponseSelectionExpression": "${integration.response.statuscode}",
    "IntegrationType": "MOCK",
    "PassthroughBehavior": "WHEN_NO_MATCH",
    "PayloadFormatVersion": "1.0",
    "TimeoutInMillis": 29000
}
```
如需詳細資訊，請參閱《*Amazon API Gateway 開發人員指南*》中的[在 API Gateway 中設定 WebSocket API 整合請求](https://docs.aws.amazon.com/apigateway/latest/developerguide/apigateway-websocket-api-integration-requests.html)。  
**建立 HTTP API 整合**  
下列`create-integration`範例會為 HTTP API 建立 AWS Lambda 整合。  

```
aws apigatewayv2 create-integration \
    --api-id a1b2c3d4 \
    --integration-type AWS_PROXY \
    --integration-uri arn:aws:lambda:us-west-2:123456789012:function:my-function \
    --payload-format-version 2.0
```
輸出：  

```
{
    "ConnectionType": "INTERNET",
    "IntegrationId": "0abcdef",
    "IntegrationMethod": "POST",
    "IntegrationType": "AWS_PROXY",
    "IntegrationUri": "arn:aws:lambda:us-west-2:123456789012:function:my-function",
    "PayloadFormatVersion": "2.0",
    "TimeoutInMillis": 30000
}
```
如需詳細資訊，請參閱《*Amazon API Gateway 開發人員指南*》中的[設定 HTTP API 的整合](https://docs.aws.amazon.com/apigateway/latest/developerguide/http-api-develop-integrations.html)。  
+  如需 API 詳細資訊，請參閱《AWS CLI 命令參考》**中的 [CreateIntegration](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/apigatewayv2/create-integration.html)。

### `create-route`
<a name="apigatewayv2_CreateRoute_cli_topic"></a>

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

**AWS CLI**  
**建立 WebSocket 或 HTTP API 的 \$1default 路由**  
下列 `create-route` 範例建立 WebSocket 或 HTTP API 的 `$default` 路由。  

```
aws apigatewayv2 create-route \
    --api-id aabbccddee \
    --route-key '$default'
```
輸出：  

```
{
    "ApiKeyRequired": false,
    "AuthorizationType": "NONE",
    "RouteKey": "$default",
    "RouteId": "1122334"
}
```
如需詳細資訊，請參閱《*Amazon API Gateway 開發人員指南*》中的[使用 WebSocket API 的路由](https://docs.aws.amazon.com/apigateway/latest/developerguide/apigateway-websocket-api-add-route.html)  
**建立 HTTP API 的路由**  
下列 `create-route` 範例建立名為 `signup` 的路由，該路由接受 POST 請求。  

```
aws apigatewayv2 create-route \
    --api-id aabbccddee \
    --route-key 'POST /signup'
```
輸出：  

```
{
    "ApiKeyRequired": false,
    "AuthorizationType": "NONE",
    "RouteKey": "POST /signup",
    "RouteId": "1122334"
}
```
如需詳細資訊，請參閱《*Amazon API Gateway 開發人員指南*》中的[使用 HTTP API 的路由](https://docs.aws.amazon.com/apigateway/latest/developerguide/http-api-develop-routes.html)  
+  如需 API 詳細資訊，請參閱《AWS CLI 命令參考》**中的 [CreateRoute](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/apigatewayv2/create-route.html)。

### `create-routing-rule`
<a name="apigatewayv2_CreateRoutingRule_cli_topic"></a>

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

**AWS CLI**  
**建立路由規則**  
下列 `create-routing-rule` 範例建立優先順序為 `50` 的路由規則。  

```
aws apigatewayv2 create-routing-rule \
    --domain-name 'regional.example.com' \
    --priority 50 \
    --conditions '[ \
        { \
            "MatchBasePaths": { \
                "AnyOf": [ \
                    "PetStoreShopper" \
                ] \
            } \
        } \
    ]' \
    --actions '[ \
        { \
            "InvokeApi": { \
                "ApiId": "abcd1234", \
                "Stage": "prod" \
            } \
        } \
    ]'
```
輸出：  

```
{
    "Actions": [
        {
            "InvokeApi": {
                "ApiId": "abcd1234",
                "Stage": "prod",
                "StripBasePath": false
            }
        }
    ],
    "Conditions": [
        {
            "MatchBasePaths": {
                "AnyOf": [
                    "PetStoreShopper"
                ]
            }
        }
    ],
    "Priority": 50,
    "RoutingRuleArn": "arn:aws:apigateway:us-east-2:123456789012:/domainnames/regional.example.com/routingrules/aaa111",
    "RoutingRuleId": "aaa111"
}
```
如需詳細資訊，請參閱《*Amazon API Gateway 開發人員指南*》中的[將 API 階段連線至 REST API 自訂網域名稱的路由規則](https://docs.aws.amazon.com/apigateway/latest/developerguide/rest-api-routing-rules.html)。  
+  如需 API 詳細資訊，請參閱《AWS CLI 命令參考》**中的 [CreateRoutingRule](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/apigatewayv2/create-routing-rule.html)。

### `create-stage`
<a name="apigatewayv2_CreateStage_cli_topic"></a>

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

**AWS CLI**  
**建立階段**  
下列 `create-stage` 範例為 API 建立名為 dev 的階段。  

```
aws apigatewayv2 create-stage \
    --api-id a1b2c3d4 \
    --stage-name dev
```
輸出：  

```
{
    "CreatedDate": "2020-04-06T23:23:46Z",
    "DefaultRouteSettings": {
        "DetailedMetricsEnabled": false
    },
    "LastUpdatedDate": "2020-04-06T23:23:46Z",
    "RouteSettings": {},
    "StageName": "dev",
    "StageVariables": {},
    "Tags": {}
}
```
如需詳細資訊，請參閱《*Amazon API Gateway 開發人員指南*》中的[使用 HTTP API 的階段](https://docs.aws.amazon.com/apigateway/latest/developerguide/http-api-stages.html)。  
+  如需 API 詳細資訊，請參閱《AWS CLI 命令參考》**中的 [CreateStage](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/apigatewayv2/create-stage.html)。

### `create-vpc-link`
<a name="apigatewayv2_CreateVpcLink_cli_topic"></a>

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

**AWS CLI**  
**為 HTTP API 建立 VPC 連結**  
下列 `create-vpc-link` 範例建立 HTTP API 的 VPC 連結。  

```
aws apigatewayv2 create-vpc-link \
    --name MyVpcLink \
    --subnet-ids subnet-aaaa subnet-bbbb \
    --security-group-ids sg1234 sg5678
```
輸出：  

```
{
    "CreatedDate": "2020-04-07T00:11:46Z",
    "Name": "MyVpcLink",
    "SecurityGroupIds": [
        "sg1234",
        "sg5678"
    ],
    "SubnetIds": [
        "subnet-aaaa",
        "subnet-bbbb"
    ],
    "Tags": {},
    "VpcLinkId": "abcd123",
    "VpcLinkStatus": "PENDING",
    "VpcLinkStatusMessage": "VPC link is provisioning ENIs",
    "VpcLinkVersion": "V2"
}
```
如需詳細資訊，請參閱《*Amazon API Gateway 開發人員指南*》中的[使用 HTTP API 的 VPC 連結](https://docs.aws.amazon.com/apigateway/latest/developerguide/http-api-vpc-links.html)。  
+  如需 API 詳細資訊，請參閱《AWS CLI 命令參考》**中的 [CreateVpcLink](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/apigatewayv2/create-vpc-link.html)。

### `delete-access-log-settings`
<a name="apigatewayv2_DeleteAccessLogSettings_cli_topic"></a>

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

**AWS CLI**  
**停用 API 的存取記錄**  
下列 `delete-access-log-settings` 範例刪除了 API `$default` 階段的存取日誌設定。要停用階段的存取日誌記錄，請刪除其存取日誌設定。  

```
aws apigatewayv2 delete-access-log-settings \
    --api-id a1b2c3d4 \
    --stage-name '$default'
```
此命令不會產生輸出。  
如需詳細資訊，請參閱《*Amazon API Gateway 開發人員指南*》中的[設定 HTTP API 的日誌記錄](https://docs.aws.amazon.com/apigateway/latest/developerguide/http-api-logging.html)。  
+  如需 API 詳細資訊，請參閱《AWS CLI 命令參考》**中的 [DeleteAccessLogSettings](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/apigatewayv2/delete-access-log-settings.html)。

### `delete-api-mapping`
<a name="apigatewayv2_DeleteApiMapping_cli_topic"></a>

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

**AWS CLI**  
**刪除 API 映射**  
下列 `delete-api-mapping` 範例會刪除 `api.example.com` 自訂網域名稱 API 映射。  

```
aws apigatewayv2 delete-api-mapping \
    --api-mapping-id a1b2c3 \
    --domain-name api.example.com
```
此命令不會產生輸出。  
如需詳細資訊，請參閱《*Amazon API Gateway 開發人員指南*》中的[在 API Gateway 中設定區域自訂網域名稱](https://docs.aws.amazon.com/apigateway/latest/developerguide/apigateway-regional-api-custom-domain-create.html)。  
+  如需 API 詳細資訊，請參閱《AWS CLI 命令參考》**中的 [DeleteApiMapping](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/apigatewayv2/delete-api-mapping.html)。

### `delete-api`
<a name="apigatewayv2_DeleteApi_cli_topic"></a>

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

**AWS CLI**  
**刪除 API**  
下列 `delete-api` 範例會刪除 API。  

```
aws apigatewayv2 delete-api \
    --api-id a1b2c3d4
```
此命令不會產生輸出。  
如需詳細資訊，請參閱《*Amazon API Gateway 開發人員指南*》中的[使用 HTTP API](https://docs.aws.amazon.com/apigateway/latest/developerguide/http-api.html) 和[使用 WebSocket API](https://docs.aws.amazon.com/apigateway/latest/developerguide/apigateway-websocket-api.html)。  
+  如需 API 詳細資訊，請參閱《AWS CLI 命令參考》**中的 [DeleteApi](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/apigatewayv2/delete-api.html)。

### `delete-authorizer`
<a name="apigatewayv2_DeleteAuthorizer_cli_topic"></a>

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

**AWS CLI**  
**刪除授權方**  
下列 `delete-authorizer` 範例會刪除授權方。  

```
aws apigatewayv2 delete-authorizer \
    --api-id a1b2c3d4 \
    --authorizer-id a1b2c3
```
此命令不會產生輸出。  
如需詳細資訊，請參閱《*Amazon API Gateway 開發人員指南*》中的[使用 JWT 授權方控制對 HTTP API 的存取](https://docs.aws.amazon.com/apigateway/latest/developerguide/http-api-jwt-authorizer.html)。  
+  如需 API 詳細資訊，請參閱《AWS CLI 命令參考》**中的 [DeleteAuthorizer](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/apigatewayv2/delete-authorizer.html)。

### `delete-cors-configuration`
<a name="apigatewayv2_DeleteCorsConfiguration_cli_topic"></a>

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

**AWS CLI**  
**刪除 HTTP API 的 CORS 組態**  
下列 `delete-cors-configuration` 範例會刪除其 CORS 組態，藉此停用 HTTP API 的 CORS。  

```
aws apigatewayv2 delete-cors-configuration \
    --api-id a1b2c3d4
```
此命令不會產生輸出。  
如需詳細資訊，請參閱《*Amazon API Gateway 開發人員指南*》中的[設定 HTTP API 的 CORS](https://docs.aws.amazon.com/apigateway/latest/developerguide/http-api-cors.html)。  
+  如需 API 詳細資訊，請參閱《AWS CLI 命令參考》**中的 [DeleteCorsConfiguration](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/apigatewayv2/delete-cors-configuration.html)。

### `delete-deployment`
<a name="apigatewayv2_DeleteDeployment_cli_topic"></a>

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

**AWS CLI**  
**刪除部署**  
下列 `delete-deployment` 範例刪除 API 的部署。  

```
aws apigatewayv2 delete-deployment \
    --api-id a1b2c3d4 \
    --deployment-id a1b2c3
```
此命令不會產生輸出。  
如需詳細資訊，請參閱《*Amazon API Gateway 開發人員指南*》中的 [API 部署](https://docs.aws.amazon.com/apigateway/latest/developerguide/api-gateway-basic-concept.html#apigateway-definition-api-deployment)。  
+  如需 API 詳細資訊，請參閱《AWS CLI 命令參考》**中的 [DeleteDeployment](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/apigatewayv2/delete-deployment.html)。

### `delete-domain-name`
<a name="apigatewayv2_DeleteDomainName_cli_topic"></a>

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

**AWS CLI**  
**刪除自訂網域名稱**  
下列 `delete-domain-name` 範例刪除了自訂網域名稱。  

```
aws apigatewayv2 delete-domain-name \
    --domain-name api.example.com
```
此命令不會產生輸出。  
如需詳細資訊，請參閱《*Amazon API Gateway 開發人員指南*》中的[在 API Gateway 中設定區域自訂網域名稱](https://docs.aws.amazon.com/apigateway/latest/developerguide/apigateway-regional-api-custom-domain-create.html)。  
+  如需 API 詳細資訊，請參閱《AWS CLI 命令參考》**中的 [DeleteDomainName](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/apigatewayv2/delete-domain-name.html)。

### `delete-integration`
<a name="apigatewayv2_DeleteIntegration_cli_topic"></a>

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

**AWS CLI**  
**刪除整合**  
下列 `delete-integration` 範例刪除 API 整合。  

```
aws apigatewayv2 delete-integration \
    --api-id a1b2c3d4 \
    --integration-id a1b2c3
```
此命令不會產生輸出。  
如需詳細資訊，請參閱《*Amazon API Gateway 開發人員指南*》中的[設定 HTTP API 的整合](https://docs.aws.amazon.com/apigateway/latest/developerguide/http-api-develop-integrations.html)和[設定 WebSocket API 整合](https://docs.aws.amazon.com/apigateway/latest/developerguide/apigateway-websocket-api-integrations.html)。  
+  如需 API 詳細資訊，請參閱《AWS CLI 命令參考》**中的 [DeleteIntegration](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/apigatewayv2/delete-integration.html)。

### `delete-route-settings`
<a name="apigatewayv2_DeleteRouteSettings_cli_topic"></a>

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

**AWS CLI**  
**刪除路由設定**  
下列 `delete-route-settings` 範例刪除指定路由的路由設定。  

```
aws apigatewayv2 delete-route-settings \
    --api-id a1b2c3d4 \
    --stage-name dev \
    --route-key 'GET /pets'
```
此命令不會產生輸出。  
如需詳細資訊，請參閱《*Amazon API Gateway 開發人員指南*》中的[使用 HTTP API 的路由](https://docs.aws.amazon.com/apigateway/latest/developerguide/http-api-develop-routes.html)。  
+  如需 API 詳細資訊，請參閱《AWS CLI 命令參考》**中的 [DeleteRouteSettings](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/apigatewayv2/delete-route-settings.html)。

### `delete-route`
<a name="apigatewayv2_DeleteRoute_cli_topic"></a>

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

**AWS CLI**  
**刪除路由**  
下列 `delete-route` 範例刪除 API 路由。  

```
aws apigatewayv2 delete-route \
    --api-id a1b2c3d4 \
    --route-id a1b2c3
```
此命令不會產生輸出。  
如需詳細資訊，請參閱《*Amazon API Gateway 開發人員指南*》中的[使用 HTTP API 的路由](https://docs.aws.amazon.com/apigateway/latest/developerguide/http-api-develop-routes.html)。  
+  如需 API 詳細資訊，請參閱《AWS CLI 命令參考》**中的 [DeleteRoute](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/apigatewayv2/delete-route.html)。

### `delete-routing-rule`
<a name="apigatewayv2_DeleteRoutingRule_cli_topic"></a>

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

**AWS CLI**  
**刪除路由規則**  
下列 `delete-routing-rule` 範例刪除自訂網域名稱的路由規則。  

```
aws apigatewayv2 delete-routing-rule \
    --domain-name 'regional.example.com' \
    --routing-rule-id aaa111
```
此命令不會產生輸出。  
如需詳細資訊，請參閱《*Amazon API Gateway 開發人員指南*》中的[將 API 階段連線至 REST API 自訂網域名稱的路由規則](https://docs.aws.amazon.com/apigateway/latest/developerguide/rest-api-routing-rules.html)。  
+  如需 API 詳細資訊，請參閱《AWS CLI 命令參考》**中的 [DeleteRoutingRule](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/apigatewayv2/delete-routing-rule.html)。

### `delete-stage`
<a name="apigatewayv2_DeleteStage_cli_topic"></a>

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

**AWS CLI**  
**刪除階段**  
下列 `delete-stage` 範例刪除 API 的 `test` 階段。  

```
aws apigatewayv2 delete-stage \
    --api-id a1b2c3d4 \
    --stage-name test
```
此命令不會產生輸出。  
如需詳細資訊，請參閱《*Amazon API Gateway 開發人員指南*》中的[使用 HTTP API 的階段](https://docs.aws.amazon.com/apigateway/latest/developerguide/http-api-stages.html)。  
+  如需 API 詳細資訊，請參閱《AWS CLI 命令參考》**中的 [DeleteStage](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/apigatewayv2/delete-stage.html)。

### `delete-vpc-link`
<a name="apigatewayv2_DeleteVpcLink_cli_topic"></a>

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

**AWS CLI**  
**刪除 HTTP API 的 VPC 連結**  
下列 `delete-vpc-link` 範例刪除 VPC 連結。  

```
aws apigatewayv2 delete-vpc-link \
    --vpc-link-id abcd123
```
此命令不會產生輸出。  
如需詳細資訊，請參閱《*Amazon API Gateway 開發人員指南*》中的[使用 HTTP API 的 VPC 連結](https://docs.aws.amazon.com/apigateway/latest/developerguide/http-api-vpc-links.html)。  
+  如需 API 詳細資訊，請參閱《AWS CLI 命令參考》**中的 [DeleteVpcLink](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/apigatewayv2/delete-vpc-link.html)。

### `export-api`
<a name="apigatewayv2_ExportApi_cli_topic"></a>

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

**AWS CLI**  
**匯出 HTTP API 的 OpenAPI 定義**  
下列 `export-api` 範例將名為 `prod` 的 API 階段的 OpenAPI 3.0 定義，匯出至名為 `stage-definition.yaml` 的 YAML 檔案。匯出的定義檔案預設會包含 API Gateway 延伸。  

```
aws apigatewayv2 export-api \
    --api-id a1b2c3d4 \
    --output-type YAML \
    --specification OAS30 \
    --stage-name prod \
    stage-definition.yaml
```
此命令不會產生輸出。  
如需詳細資訊，請參閱《*Amazon API Gateway 開發人員指南*》中的[匯出 API Gateway 的 HTTP API](https://docs.aws.amazon.com/apigateway/latest/developerguide/http-api-export.html)。  
+  如需 API 詳細資訊，請參閱《AWS CLI 命令參考》**中的 [ExportApi](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/apigatewayv2/export-api.html)。

### `get-api-mapping`
<a name="apigatewayv2_GetApiMapping_cli_topic"></a>

以下程式碼範例顯示如何使用 `get-api-mapping`。

**AWS CLI**  
**取得自訂網域名稱的 API 映射相關資訊**  
下列`get-api-mapping`範例顯示`api.example.com`自訂網域名稱的 API 映射相關資訊。  

```
aws apigatewayv2 get-api-mapping \
    --api-mapping-id a1b2c3 \
    --domain-name api.example.com
```
輸出：  

```
{
    "ApiId": "a1b2c3d4",
    "ApiMappingId": "a1b2c3d5",
    "ApiMappingKey": "myTestApi"
    "Stage": "test"
}
```
如需詳細資訊，請參閱《*Amazon API Gateway 開發人員指南*》中的[在 API Gateway 中設定區域自訂網域名稱](https://docs.aws.amazon.com/apigateway/latest/developerguide/apigateway-regional-api-custom-domain-create.html)。  
+  如需 API 詳細資訊，請參閱《AWS CLI 命令參考》**中的 [GetApiMapping](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/apigatewayv2/get-api-mapping.html)。

### `get-api-mappings`
<a name="apigatewayv2_GetApiMappings_cli_topic"></a>

以下程式碼範例顯示如何使用 `get-api-mappings`。

**AWS CLI**  
**取得自訂網域名稱的 API 映射**  
下列 `get-api-mappings` 範例顯示 `api.example.com` 自訂網域名稱的所有 API 映射清單。  

```
aws apigatewayv2 get-api-mappings \
    --domain-name api.example.com
```
輸出：  

```
{
    "Items": [
        {
            "ApiId": "a1b2c3d4",
            "ApiMappingId": "a1b2c3d5",
            "ApiMappingKey": "myTestApi"
            "Stage": "test"
        },
        {
            "ApiId": "a5b6c7d8",
            "ApiMappingId": "a1b2c3d6",
            "ApiMappingKey": "myDevApi"
            "Stage": "dev"
        },
    ]
}
```
如需詳細資訊，請參閱《*Amazon API Gateway 開發人員指南*》中的[在 API Gateway 中設定區域自訂網域名稱](https://docs.aws.amazon.com/apigateway/latest/developerguide/apigateway-regional-api-custom-domain-create.html)。  
+  如需 API 詳細資訊，請參閱《AWS CLI 命令參考》**中的 [GetApiMappings](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/apigatewayv2/get-api-mappings.html)。

### `get-api`
<a name="apigatewayv2_GetApi_cli_topic"></a>

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

**AWS CLI**  
**擷取 API 相關資訊**  
下列 `get-api` 範例顯示 API 的相關資訊。  

```
aws apigatewayv2 get-api \
    --api-id a1b2c3d4
```
輸出：  

```
{
    "ApiEndpoint": "https://a1b2c3d4.execute-api.us-west-2.amazonaws.com",
    "ApiId": "a1b2c3d4",
    "ApiKeySelectionExpression": "$request.header.x-api-key",
    "CreatedDate": "2020-03-28T00:32:37Z",
    "Name": "my-api",
    "ProtocolType": "HTTP",
    "RouteSelectionExpression": "$request.method $request.path",
    "Tags": {
        "department": "finance"
    }
}
```
+  如需 API 詳細資訊，請參閱《AWS CLI 命令參考》**中的 [GetApi](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/apigatewayv2/get-api.html)。

### `get-apis`
<a name="apigatewayv2_GetApis_cli_topic"></a>

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

**AWS CLI**  
**擷取 API 清單**  
下列 `get-apis` 範例列出目前使用者的所有 APIs。  

```
aws apigatewayv2 get-apis
```
輸出：  

```
{
    "Items": [
        {
            "ApiEndpoint": "wss://a1b2c3d4.execute-api.us-west-2.amazonaws.com",
            "ApiId": "a1b2c3d4",
            "ApiKeySelectionExpression": "$request.header.x-api-key",
            "CreatedDate": "2020-04-07T20:21:59Z",
            "Name": "my-websocket-api",
            "ProtocolType": "WEBSOCKET",
            "RouteSelectionExpression": "$request.body.message",
            "Tags": {}
        },
        {
            "ApiEndpoint": "https://a1b2c3d5.execute-api.us-west-2.amazonaws.com",
            "ApiId": "a1b2c3d5",
            "ApiKeySelectionExpression": "$request.header.x-api-key",
            "CreatedDate": "2020-04-07T20:23:50Z",
            "Name": "my-http-api",
            "ProtocolType": "HTTP",
            "RouteSelectionExpression": "$request.method $request.path",
            "Tags": {}
        }
    ]
}
```
如需詳細資訊，請參閱《*Amazon API Gateway 開發人員指南*》中的[使用 HTTP API](https://docs.aws.amazon.com/apigateway/latest/developerguide/http-api.html) 和[使用 WebSocket API](https://docs.aws.amazon.com/apigateway/latest/developerguide/apigateway-websocket-api.html)。  
+  如需 API 詳細資訊，請參閱《AWS CLI 命令參考》**中的 [GetApis](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/apigatewayv2/get-apis.html)。

### `get-authorizer`
<a name="apigatewayv2_GetAuthorizer_cli_topic"></a>

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

**AWS CLI**  
**擷取授權方的相關資訊**  
下列 `get-authorizer` 範例顯示有關授權方的詳細資訊。  

```
aws apigatewayv2 get-authorizer \
    --api-id a1b2c3d4 \
    --authorizer-id a1b2c3
```
輸出：  

```
{
    "AuthorizerId": "a1b2c3",
    "AuthorizerType": "JWT",
    "IdentitySource": [
        "$request.header.Authorization"
    ],
    "JwtConfiguration": {
        "Audience": [
            "123456abc"
        ],
        "Issuer": "https://cognito-idp.us-west-2.amazonaws.com/us-west-2_abc123"
    },
    "Name": "my-jwt-authorizer"
}
```
如需詳細資訊，請參閱《*Amazon API Gateway 開發人員指南*》中的[使用 JWT 授權方控制對 HTTP API 的存取](https://docs.aws.amazon.com/apigateway/latest/developerguide/http-api-jwt-authorizer.html)。  
+  如需 API 詳細資訊，請參閱《AWS CLI 命令參考》**中的 [GetAuthorizer](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/apigatewayv2/get-authorizer.html)。

### `get-authorizers`
<a name="apigatewayv2_GetAuthorizers_cli_topic"></a>

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

**AWS CLI**  
**擷取 API 的授權方清單**  
下列 `get-authorizers` 範例顯示 API 的所有授權方清單。  

```
aws apigatewayv2 get-authorizers \
    --api-id a1b2c3d4
```
輸出：  

```
{
    "Items": [
        {
            "AuthorizerId": "a1b2c3",
            "AuthorizerType": "JWT",
            "IdentitySource": [
                "$request.header.Authorization"
            ],
            "JwtConfiguration": {
                "Audience": [
                    "123456abc"
                ],
                "Issuer": "https://cognito-idp.us-west-2.amazonaws.com/us-west-2_abc123"
            },
            "Name": "my-jwt-authorizer"
        },
        {
            "AuthorizerId": "a1b2c4",
            "AuthorizerType": "JWT",
            "IdentitySource": [
                "$request.header.Authorization"
            ],
            "JwtConfiguration": {
                "Audience": [
                    "6789abcde"
                ],
                "Issuer": "https://cognito-idp.us-west-2.amazonaws.com/us-west-2_abc234"
            },
            "Name": "new-jwt-authorizer"
        }
    ]
}
```
如需詳細資訊，請參閱《*Amazon API Gateway 開發人員指南*》中的[使用 JWT 授權方控制對 HTTP API 的存取](https://docs.aws.amazon.com/apigateway/latest/developerguide/http-api-jwt-authorizer.html)。  
+  如需 API 詳細資訊，請參閱《AWS CLI 命令參考》**中的 [GetAuthorizers](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/apigatewayv2/get-authorizers.html)。

### `get-deployment`
<a name="apigatewayv2_GetDeployment_cli_topic"></a>

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

**AWS CLI**  
**擷取部署的相關資訊**  
下列 `get-deployment` 範例顯示部署的相關資訊。  

```
aws apigatewayv2 get-deployment \
    --api-id a1b2c3d4 \
    --deployment-id abcdef
```
輸出：  

```
{
    "AutoDeployed": true,
    "CreatedDate": "2020-04-07T23:58:40Z",
    "DeploymentId": "abcdef",
    "DeploymentStatus": "DEPLOYED",
    "Description": "Automatic deployment triggered by changes to the Api configuration"
}
```
如需詳細資訊，請參閱《*Amazon API Gateway 開發人員指南*》中的 [API 部署](https://docs.aws.amazon.com/apigateway/latest/developerguide/api-gateway-basic-concept.html#apigateway-definition-api-deployment)。  
+  如需 API 詳細資訊，請參閱《AWS CLI 命令參考》**中的 [GetDeployment](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/apigatewayv2/get-deployment.html)。

### `get-deployments`
<a name="apigatewayv2_GetDeployments_cli_topic"></a>

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

**AWS CLI**  
**擷取部署清單**  
下列 `get-deployments` 範例顯示所有 API 部署的清單。  

```
aws apigatewayv2 get-deployments \
    --api-id a1b2c3d4
```
輸出：  

```
{
    "Items": [
        {
            "AutoDeployed": true,
            "CreatedDate": "2020-04-07T23:58:40Z",
            "DeploymentId": "abcdef",
            "DeploymentStatus": "DEPLOYED",
            "Description": "Automatic deployment triggered by changes to the Api configuration"
        },
        {
            "AutoDeployed": true,
            "CreatedDate": "2020-04-06T00:33:00Z",
            "DeploymentId": "bcdefg",
            "DeploymentStatus": "DEPLOYED",
            "Description": "Automatic deployment triggered by changes to the Api configuration"
        }
    ]
}
```
如需詳細資訊，請參閱《*Amazon API Gateway 開發人員指南*》中的 [API 部署](https://docs.aws.amazon.com/apigateway/latest/developerguide/api-gateway-basic-concept.html#apigateway-definition-api-deployment)。  
+  如需 API 詳細資訊，請參閱《AWS CLI 命令參考》**中的 [GetDeployments](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/apigatewayv2/get-deployments.html)。

### `get-domain-name`
<a name="apigatewayv2_GetDomainName_cli_topic"></a>

以下程式碼範例顯示如何使用 `get-domain-name`。

**AWS CLI**  
**擷取自訂網域名稱的相關資訊**  
下列 `get-domain-name` 範例顯示自訂網域名稱的相關資訊。  

```
aws apigatewayv2 get-domain-name \
    --domain-name api.example.com
```
輸出：  

```
{
    "ApiMappingSelectionExpression": "$request.basepath",
    "DomainName": "api.example.com",
    "DomainNameConfigurations": [
        {
            "ApiGatewayDomainName": "d-1234.execute-api.us-west-2.amazonaws.com",
            "CertificateArn": "arn:aws:acm:us-west-2:123456789012:certificate/123456789012-1234-1234-1234-12345678",
            "EndpointType": "REGIONAL",
            "HostedZoneId": "123456789111",
            "SecurityPolicy": "TLS_1_2",
            "DomainNameStatus": "AVAILABLE"
        }
    ],
    "Tags": {}
}
```
如需詳細資訊，請參閱《*Amazon API Gateway 開發人員指南*》中的[在 API Gateway 中設定區域自訂網域名稱](https://docs.aws.amazon.com/apigateway/latest/developerguide/apigateway-regional-api-custom-domain-create.html)。  
+  如需 API 詳細資訊，請參閱《AWS CLI 命令參考》**中的 [GetDomainName](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/apigatewayv2/get-domain-name.html)。

### `get-domain-names`
<a name="apigatewayv2_GetDomainNames_cli_topic"></a>

以下程式碼範例顯示如何使用 `get-domain-names`。

**AWS CLI**  
**擷取自訂網域名稱的清單**  
下列 `get-domain-names` 範例顯示目前使用者的所有自訂網域名稱清單。  

```
aws apigatewayv2 get-domain-names
```
輸出：  

```
{
    "Items": [
        {
            "ApiMappingSelectionExpression": "$request.basepath",
            "DomainName": "api.example.com",
            "DomainNameConfigurations": [
                {
                    "ApiGatewayDomainName": "d-1234.execute-api.us-west-2.amazonaws.com",
                    "CertificateArn": "arn:aws:acm:us-west-2:123456789012:certificate/123456789012-1234-1234-1234-12345678",
                    "EndpointType": "REGIONAL",
                    "HostedZoneId": "123456789111",
                    "SecurityPolicy": "TLS_1_2",
                    "DomainNameStatus": "AVAILABLE"
                }
            ]
        },
        {
            "ApiMappingSelectionExpression": "$request.basepath",
            "DomainName": "newApi.example.com",
            "DomainNameConfigurations": [
                {
                    "ApiGatewayDomainName": "d-5678.execute-api.us-west-2.amazonaws.com",
                    "CertificateArn": "arn:aws:acm:us-west-2:123456789012:certificate/123456789012-1234-1234-1234-12345678",
                    "EndpointType": "REGIONAL",
                    "HostedZoneId": "123456789222",
                    "SecurityPolicy": "TLS_1_2",
                    "DomainNameStatus": "AVAILABLE"
                }
            ]
        }
    ]
}
```
如需詳細資訊，請參閱《*Amazon API Gateway 開發人員指南*》中的[在 API Gateway 中設定區域自訂網域名稱](https://docs.aws.amazon.com/apigateway/latest/developerguide/apigateway-regional-api-custom-domain-create.html)。  
+  如需 API 詳細資訊，請參閱《AWS CLI 命令參考》**中的 [GetDomainNames](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/apigatewayv2/get-domain-names.html)。

### `get-integration`
<a name="apigatewayv2_GetIntegration_cli_topic"></a>

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

**AWS CLI**  
**擷取有關整合的資訊**  
下列 `get-integration` 範例顯示整合的相關資訊。  

```
aws apigatewayv2 get-integration \
    --api-id a1b2c3d4 \
    --integration-id a1b2c3
```
輸出：  

```
{
    "ApiGatewayManaged": true,
    "ConnectionType": "INTERNET",
    "IntegrationId": "a1b2c3",
    "IntegrationMethod": "POST",
    "IntegrationType": "AWS_PROXY",
    "IntegrationUri": "arn:aws:lambda:us-west-2:12356789012:function:hello12",
    "PayloadFormatVersion": "2.0",
    "TimeoutInMillis": 30000
}
```
如需詳細資訊，請參閱《*Amazon API Gateway 開發人員指南*》中的[設定 HTTP API 的整合](https://docs.aws.amazon.com/apigateway/latest/developerguide/http-api-develop-integrations.html)和[設定 WebSocket API 整合](https://docs.aws.amazon.com/apigateway/latest/developerguide/apigateway-websocket-api-integrations.html)。  
+  如需 API 詳細資訊，請參閱《AWS CLI 命令參考》**中的 [GetIntegration](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/apigatewayv2/get-integration.html)。

### `get-integrations`
<a name="apigatewayv2_GetIntegrations_cli_topic"></a>

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

**AWS CLI**  
**擷取整合清單**  
下列 `get-integrations` 範例顯示所有 API 整合的清單。  

```
aws apigatewayv2 get-integrations \
    --api-id a1b2c3d4
```
輸出：  

```
{
    "Items": [
        {
            "ApiGatewayManaged": true,
            "ConnectionType": "INTERNET",
            "IntegrationId": "a1b2c3",
            "IntegrationMethod": "POST",
            "IntegrationType": "AWS_PROXY",
            "IntegrationUri": "arn:aws:lambda:us-west-2:123456789012:function:my-function",
            "PayloadFormatVersion": "2.0",
            "TimeoutInMillis": 30000
        },
        {
            "ConnectionType": "INTERNET",
            "IntegrationId": "a1b2c4",
            "IntegrationMethod": "ANY",
            "IntegrationType": "HTTP_PROXY",
            "IntegrationUri": "https://www.example.com",
            "PayloadFormatVersion": "1.0",
            "TimeoutInMillis": 30000
        }
    ]
}
```
如需詳細資訊，請參閱《*Amazon API Gateway 開發人員指南*》中的[設定 HTTP API 的整合](https://docs.aws.amazon.com/apigateway/latest/developerguide/http-api-develop-integrations.html)和[設定 WebSocket API 整合](https://docs.aws.amazon.com/apigateway/latest/developerguide/apigateway-websocket-api-integrations.html)。  
+  如需 API 詳細資訊，請參閱《AWS CLI 命令參考》**中的 [GetIntegrations](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/apigatewayv2/get-integrations.html)。

### `get-route`
<a name="apigatewayv2_GetRoute_cli_topic"></a>

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

**AWS CLI**  
**擷取路由相關資訊**  
下列 `get-route` 範例顯示路由的相關資訊。  

```
aws apigatewayv2 get-route \
    --api-id a1b2c3d4 \
    --route-id 72jz1wk
```
輸出：  

```
{
    "ApiKeyRequired": false,
    "AuthorizationType": "NONE",
    "RouteId": "72jz1wk",
    "RouteKey": "ANY /pets",
    "Target": "integrations/a1b2c3"
}
```
如需詳細資訊，請參閱《*Amazon API Gateway 開發人員指南*》中的[使用 HTTP API 的路由](https://docs.aws.amazon.com/apigateway/latest/developerguide/http-api-develop-routes.html)  
+  如需 API 詳細資訊，請參閱《AWS CLI 命令參考》**中的 [GetRoute](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/apigatewayv2/get-route.html)。

### `get-routes`
<a name="apigatewayv2_GetRoutes_cli_topic"></a>

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

**AWS CLI**  
**擷取路由清單**  
下列 `get-routes` 範例顯示所有 API 路由的清單。  

```
aws apigatewayv2 get-routes \
    --api-id a1b2c3d4
```
輸出：  

```
{
    "Items": [
        {
            "ApiKeyRequired": false,
            "AuthorizationType": "NONE",
            "RouteId": "72jz1wk",
            "RouteKey": "ANY /admin",
            "Target": "integrations/a1b2c3"
        },
        {
            "ApiGatewayManaged": true,
            "ApiKeyRequired": false,
            "AuthorizationType": "NONE",
            "RouteId": "go65gqi",
            "RouteKey": "$default",
            "Target": "integrations/a1b2c4"
        }
    ]
}
```
如需詳細資訊，請參閱《*Amazon API Gateway 開發人員指南*》中的[使用 HTTP API 的路由](https://docs.aws.amazon.com/apigateway/latest/developerguide/http-api-develop-routes.html)  
+  如需 API 詳細資訊，請參閱《AWS CLI 命令參考》**中的 [GetRoutes](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/apigatewayv2/get-routes.html)。

### `get-routing-rule`
<a name="apigatewayv2_GetRoutingRule_cli_topic"></a>

以下程式碼範例顯示如何使用 `get-routing-rule`。

**AWS CLI**  
**取得路由規則**  
下列 `get-routing-rule` 範例會取得網域名稱的路由規則。  

```
aws apigatewayv2 get-routing-rule \
    --domain-name 'regional.example.com' \
    --routing-rule-id aaa111
```
輸出：  

```
{
    "Actions": [
        {
            "InvokeApi": {
                "ApiId": "abcd1234",
                "Stage": "prod",
                "StripBasePath": false
            }
        }
    ],
    "Conditions": [
        {
            "MatchBasePaths": {
                "AnyOf": [
                    "PetStoreShopper"
                ]
            }
        }
    ],
    "Priority": 50,
    "RoutingRuleArn": "arn:aws:apigateway:us-east-2:123456789012:/domainnames/regional.example.com/routingrules/aaa111",
    "RoutingRuleId": "aaa111"
}
```
如需詳細資訊，請參閱《*Amazon API Gateway 開發人員指南*》中的[將 API 階段連線至 REST API 自訂網域名稱的路由規則](https://docs.aws.amazon.com/apigateway/latest/developerguide/rest-api-routing-rules.html)。  
+  如需 API 詳細資訊，請參閱《AWS CLI 命令參考》**中的 [GetRoutingRule](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/apigatewayv2/get-routing-rule.html)。

### `get-stage`
<a name="apigatewayv2_GetStage_cli_topic"></a>

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

**AWS CLI**  
**擷取階段的相關資訊**  
下列 `get-stage` 範例顯示 API 的 `prod` 階段的相關資訊。  

```
aws apigatewayv2 get-stage \
    --api-id a1b2c3d4 \
    --stage-name prod
```
輸出：  

```
{
    "CreatedDate": "2020-04-08T00:36:05Z",
    "DefaultRouteSettings": {
        "DetailedMetricsEnabled": false
    },
    "DeploymentId": "x1zwyv",
    "LastUpdatedDate": "2020-04-08T00:36:13Z",
    "RouteSettings": {},
    "StageName": "prod",
    "StageVariables": {
        "function": "my-prod-function"
    },
    "Tags": {}
}
```
如需詳細資訊，請參閱《*Amazon API Gateway 開發人員指南*》中的[使用 HTTP API 的階段](https://docs.aws.amazon.com/apigateway/latest/developerguide/http-api-stages.html)。  
+  如需 API 詳細資訊，請參閱《AWS CLI 命令參考》**中的 [GetStage](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/apigatewayv2/get-stage.html)。

### `get-stages`
<a name="apigatewayv2_GetStages_cli_topic"></a>

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

**AWS CLI**  
**擷取階段清單**  
下列 `get-stages` 範例列出 API 的所有階段。  

```
aws apigatewayv2 get-stages \
    --api-id a1b2c3d4
```
輸出：  

```
{
    "Items": [
        {
            "ApiGatewayManaged": true,
            "AutoDeploy": true,
            "CreatedDate": "2020-04-08T00:08:44Z",
            "DefaultRouteSettings": {
                "DetailedMetricsEnabled": false
            },
            "DeploymentId": "dty748",
            "LastDeploymentStatusMessage": "Successfully deployed stage with deployment ID 'dty748'",
            "LastUpdatedDate": "2020-04-08T00:09:49Z",
            "RouteSettings": {},
            "StageName": "$default",
            "StageVariables": {},
            "Tags": {}
        },
        {
            "AutoDeploy": true,
            "CreatedDate": "2020-04-08T00:35:06Z",
            "DefaultRouteSettings": {
                "DetailedMetricsEnabled": false
            },
            "LastUpdatedDate": "2020-04-08T00:35:48Z",
            "RouteSettings": {},
            "StageName": "dev",
            "StageVariables": {
                "function": "my-dev-function"
            },
            "Tags": {}
        },
        {
            "CreatedDate": "2020-04-08T00:36:05Z",
            "DefaultRouteSettings": {
                "DetailedMetricsEnabled": false
            },
            "DeploymentId": "x1zwyv",
            "LastUpdatedDate": "2020-04-08T00:36:13Z",
            "RouteSettings": {},
            "StageName": "prod",
            "StageVariables": {
                "function": "my-prod-function"
            },
            "Tags": {}
        }
    ]
}
```
如需詳細資訊，請參閱《*Amazon API Gateway 開發人員指南*》中的[使用 HTTP API 的階段](https://docs.aws.amazon.com/apigateway/latest/developerguide/http-api-stages.html)。  
+  如需 API 詳細資訊，請參閱《AWS CLI 命令參考》**中的 [GetStages](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/apigatewayv2/get-stages.html)。

### `get-tags`
<a name="apigatewayv2_GetTags_cli_topic"></a>

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

**AWS CLI**  
**擷取資源的標籤清單**  
下列 `get-tags` 範例列出 API 的所有標籤。  

```
aws apigatewayv2 get-tags \
    --resource-arn arn:aws:apigateway:us-west-2::/apis/a1b2c3d4
```
輸出：  

```
{
    "Tags": {
        "owner": "dev-team",
        "environment": "prod"
    }
}
```
如需詳細資訊，請參閱《*Amazon API Gateway 開發人員指南*》中的[標記 API Gateway 資源](https://docs.aws.amazon.com/apigateway/latest/developerguide/apigateway-tagging.html)。  
+  如需 API 詳細資訊，請參閱《AWS CLI 命令參考》**中的 [GetTags](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/apigatewayv2/get-tags.html)。

### `get-vpc-link`
<a name="apigatewayv2_GetVpcLink_cli_topic"></a>

以下程式碼範例顯示如何使用 `get-vpc-link`。

**AWS CLI**  
**擷取 VPC 連結的相關資訊**  
下列 `get-vpc-link` 範例顯示 VPC 連結的相關資訊。  

```
aws apigatewayv2 get-vpc-link \
    --vpc-link-id abcd123
```
輸出：  

```
{
    "CreatedDate": "2020-04-07T00:27:47Z",
    "Name": "MyVpcLink",
    "SecurityGroupIds": [
        "sg1234",
        "sg5678"
    ],
    "SubnetIds": [
        "subnet-aaaa",
        "subnet-bbbb"
    ],
    "Tags": {},
    "VpcLinkId": "abcd123",
    "VpcLinkStatus": "AVAILABLE",
    "VpcLinkStatusMessage": "VPC link is ready to route traffic",
    "VpcLinkVersion": "V2"
}
```
如需詳細資訊，請參閱《*Amazon API Gateway 開發人員指南*》中的[使用 HTTP API 的 VPC 連結](https://docs.aws.amazon.com/apigateway/latest/developerguide/http-api-vpc-links.html)。  
+  如需 API 詳細資訊，請參閱《AWS CLI 命令參考》**中的 [GetVpcLink](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/apigatewayv2/get-vpc-link.html)。

### `get-vpc-links`
<a name="apigatewayv2_GetVpcLinks_cli_topic"></a>

以下程式碼範例顯示如何使用 `get-vpc-links`。

**AWS CLI**  
**擷取 VPC 連結的清單**  
下列 `get-vpc-links` 範例顯示目前使用者的所有 VPC 連結清單。  

```
aws apigatewayv2 get-vpc-links
```
輸出：  

```
{
    "Items": [
        {
            "CreatedDate": "2020-04-07T00:27:47Z",
            "Name": "MyVpcLink",
            "SecurityGroupIds": [
                "sg1234",
                "sg5678"
            ],
            "SubnetIds": [
                "subnet-aaaa",
                "subnet-bbbb"
            ],
            "Tags": {},
            "VpcLinkId": "abcd123",
            "VpcLinkStatus": "AVAILABLE",
            "VpcLinkStatusMessage": "VPC link is ready to route traffic",
            "VpcLinkVersion": "V2"
        }
        {
            "CreatedDate": "2020-04-07T00:27:47Z",
            "Name": "MyOtherVpcLink",
            "SecurityGroupIds": [
                "sg1234",
                "sg5678"
            ],
            "SubnetIds": [
                "subnet-aaaa",
                "subnet-bbbb"
            ],
            "Tags": {},
            "VpcLinkId": "abcd456",
            "VpcLinkStatus": "AVAILABLE",
            "VpcLinkStatusMessage": "VPC link is ready to route traffic",
            "VpcLinkVersion": "V2"
        }
    ]
}
```
如需詳細資訊，請參閱《*Amazon API Gateway 開發人員指南*》中的[使用 HTTP API 的 VPC 連結](https://docs.aws.amazon.com/apigateway/latest/developerguide/http-api-vpc-links.html)。  
+  如需 API 詳細資訊，請參閱《AWS CLI 命令參考》**中的 [GetVpcLinks](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/apigatewayv2/get-vpc-links.html)。

### `import-api`
<a name="apigatewayv2_ImportApi_cli_topic"></a>

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

**AWS CLI**  
**匯入 HTTP API**  
下列 `import-api` 範例從名為 `api-definition.yaml` 的 OpenAPI 3.0 定義檔案建立 HTTP API。  

```
aws apigatewayv2 import-api \
    --body file://api-definition.yaml
```
`api-definition.yaml` 的內容：  

```
openapi: 3.0.1
info:
    title: My Lambda API
    version: v1.0
paths:
    /hello:
        x-amazon-apigateway-any-method:
            x-amazon-apigateway-integration:
                payloadFormatVersion: 2.0
                type: aws_proxy
                httpMethod: POST
                uri: arn:aws:apigateway:us-west-2:lambda:path/2015-03-31/functions/arn:aws:lambda:us-west-2:123456789012:function:hello/invocations
                connectionType: INTERNET
```
輸出：  

```
{
    "ApiEndpoint": "https://a1b2c3d4.execute-api.us-west-2.amazonaws.com",
    "ApiId": "a1b2c3d4",
    "ApiKeySelectionExpression": "$request.header.x-api-key",
    "CreatedDate": "2020-04-08T17:19:38+00:00",
    "Name": "My Lambda API",
    "ProtocolType": "HTTP",
    "RouteSelectionExpression": "$request.method $request.path",
    "Tags": {},
    "Version": "v1.0"
}
```
如需詳細資訊，請參閱《*Amazon API Gateway 開發人員指南*》中的[使用 HTTP API 的 OpenAPI 定義](https://docs.aws.amazon.com/apigateway/latest/developerguide/http-api-open-api.html)。  
+  如需 API 詳細資訊，請參閱《AWS CLI 命令參考》**中的 [ImportApi](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/apigatewayv2/import-api.html)。

### `list-routing-rules`
<a name="apigatewayv2_ListRoutingRules_cli_topic"></a>

以下程式碼範例顯示如何使用 `list-routing-rules`。

**AWS CLI**  
**列出路由規則**  
下列 `list-routing-rules` 範例列出網域名稱的路由規則。  

```
aws apigatewayv2 list-routing-rules \
    --domain-name 'regional.example.com'
```
輸出：  

```
{
    "RoutingRules": [
        {
            "Actions": [
                {
                    "InvokeApi": {
                        "ApiId": "abcd1234",
                        "Stage": "prod",
                        "StripBasePath": false
                    }
                }
            ],
            "Conditions": [
                {
                    "MatchBasePaths": {
                        "AnyOf": [
                            "PetStoreShopper"
                        ]
                    }
                }
            ],
            "Priority": 150,
            "RoutingRuleArn": "arn:aws:apigateway:us-east-1:123456789012:/domainnames/regional.example.com/routingrules/aaa111",
            "RoutingRuleId": "aaa111"
        }
    ]
}
```
如需詳細資訊，請參閱《*Amazon API Gateway 開發人員指南*》中的[將 API 階段連線至 REST API 自訂網域名稱的路由規則](https://docs.aws.amazon.com/apigateway/latest/developerguide/rest-api-routing-rules.html)。  
+  如需 API 詳細資訊，請參閱《AWS CLI 命令參考》**中的 [ListRoutingRules](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/apigatewayv2/list-routing-rules.html)。

### `put-routing-rule`
<a name="apigatewayv2_PutRoutingRule_cli_topic"></a>

以下程式碼範例顯示如何使用 `put-routing-rule`。

**AWS CLI**  
**更新路由規則**  
下列 `put-routing-rule` 範例會更新路由規則的優先順序。  

```
aws apigatewayv2 put-routing-rule \
    --domain-name 'regional.example.com' \
    --priority 150 \
    --conditions '[ \
        { \
            "MatchBasePaths": { \
                "AnyOf": [ \
                    "PetStoreShopper" \
                ] \
            } \
        } \
    ]' \
    --actions '[ \
        { \
            "InvokeApi": { \
                "ApiId": "abcd1234", \
                "Stage": "prod" \
            } \
        } \
    ]'
```
輸出：  

```
{
    "Actions": [
        {
            "InvokeApi": {
                "ApiId": "abcd1234",
                "Stage": "prod",
                "StripBasePath": false
            }
        }
    ],
    "Conditions": [
        {
            "MatchBasePaths": {
                "AnyOf": [
                    "PetStoreShopper"
                ]
            }
        }
    ],
    "Priority": 150,
    "RoutingRuleArn": "arn:aws:apigateway:us-east-2:123456789012:/domainnames/regional.example.com/routingrules/aaa111",
    "RoutingRuleId": "aaa111"
}
```
如需詳細資訊，請參閱《*Amazon API Gateway 開發人員指南*》中的[將 API 階段連線至 REST API 自訂網域名稱的路由規則](https://docs.aws.amazon.com/apigateway/latest/developerguide/rest-api-routing-rules.html)。  
+  如需 API 詳細資訊，請參閱《AWS CLI 命令參考》**中的 [PutRoutingRule](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/apigatewayv2/put-routing-rule.html)。

### `reimport-api`
<a name="apigatewayv2_ReimportApi_cli_topic"></a>

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

**AWS CLI**  
**重新匯入 HTTP API**  
下列 `reimport-api` 範例會更新現有的 HTTP API，以使用 `api-definition.yaml` 中指定的 OpenAPI 3.0 定義。  

```
aws apigatewayv2 reimport-api \
    --body file://api-definition.yaml \
    --api-id a1b2c3d4
```
`api-definition.yaml` 的內容：  

```
openapi: 3.0.1
info:
    title: My Lambda API
    version: v1.0
paths:
    /hello:
        x-amazon-apigateway-any-method:
            x-amazon-apigateway-integration:
                payloadFormatVersion: 2.0
                type: aws_proxy
                httpMethod: POST
                uri: arn:aws:apigateway:us-west-2:lambda:path/2015-03-31/functions/arn:aws:lambda:us-west-2:12356789012:function:hello/invocations
                connectionType: INTERNET
```
輸出：  

```
{
    "ApiEndpoint": "https://a1b2c3d4.execute-api.us-west-2.amazonaws.com",
    "ApiId": "a1b2c3d4",
    "ApiKeySelectionExpression": "$request.header.x-api-key",
    "CreatedDate": "2020-04-08T17:19:38+00:00",
    "Name": "My Lambda API",
    "ProtocolType": "HTTP",
    "RouteSelectionExpression": "$request.method $request.path",
    "Tags": {},
    "Version": "v1.0"
}
```
如需詳細資訊，請參閱《*Amazon API Gateway 開發人員指南*》中的[使用 HTTP API 的 OpenAPI 定義](https://docs.aws.amazon.com/apigateway/latest/developerguide/http-api-open-api.html)。  
+  如需 API 詳細資訊，請參閱《AWS CLI 命令參考》**中的 [ReimportApi](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/apigatewayv2/reimport-api.html)。

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

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

**AWS CLI**  
**標記資源**  
下列 `tag-resource` 範例將索引鍵名稱為 `Department` 且值為 `Accounting` 的標籤，新增至指定的 API。  

```
aws apigatewayv2 tag-resource \
    --resource-arn arn:aws:apigateway:us-west-2::/apis/a1b2c3d4 \
    --tags Department=Accounting
```
此命令不會產生輸出。  
如需詳細資訊，請參閱《*Amazon API Gateway 開發人員指南*》中的[標記 API Gateway 資源](https://docs.aws.amazon.com/apigateway/latest/developerguide/apigateway-tagging.html)。  
+  如需 API 詳細資訊，請參閱《AWS CLI 命令參考》**中的 [TagResource](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/apigatewayv2/tag-resource.html)。

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

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

**AWS CLI**  
**從資源移除標籤**  
下列 `untag-resource` 範例會從指定的 API 移除具有索引鍵名稱 `Project` 和 `Owner` 的標籤。  

```
aws apigatewayv2 untag-resource \
    --resource-arn arn:aws:apigateway:us-west-2::/apis/a1b2c3d4 \
    --tag-keys Project Owner
```
此命令不會產生輸出。  
如需詳細資訊，請參閱《*Amazon API Gateway 開發人員指南*》中的[標記 API Gateway 資源](https://docs.aws.amazon.com/apigateway/latest/developerguide/apigateway-tagging.html)。  
+  如需 API 詳細資訊，請參閱《AWS CLI 命令參考》**中的 [UntagResource](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/apigatewayv2/untag-resource.html)。

### `update-api-mapping`
<a name="apigatewayv2_UpdateApiMapping_cli_topic"></a>

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

**AWS CLI**  
**更新 API 映射**  
下列 `update-api-mapping` 範例會變更自訂網域名稱的 API 映射。因此，使用指定 API 和階段之自訂網域名稱的基底 URL，會變成 `https://api.example.com/dev`。  

```
aws apigatewayv2 update-api-mapping \
    --api-id a1b2c3d4 \
    --stage dev \
    --domain-name api.example.com \
    --api-mapping-id 0qzs2sy7bh \
    --api-mapping-key dev
```
輸出：  

```
{
    "ApiId": "a1b2c3d4",
    "ApiMappingId": "0qzs2sy7bh",
    "ApiMappingKey": "dev"
    "Stage": "dev"
}
```
如需詳細資訊，請參閱《*Amazon API Gateway 開發人員指南*》中的[在 API Gateway 中設定區域自訂網域名稱](https://docs.aws.amazon.com/apigateway/latest/developerguide/apigateway-regional-api-custom-domain-create.html)。  
+  如需 API 詳細資訊，請參閱《AWS CLI 命令參考》**中的 [UpdateApiMapping](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/apigatewayv2/update-api-mapping.html)。

### `update-api`
<a name="apigatewayv2_UpdateApi_cli_topic"></a>

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

**AWS CLI**  
**為 HTTP API 啟用 CORS**  
下列 `update-api` 範例更新指定之 API 的 CORS 組態，允許來自 `https://www.example.com` 的請求。  

```
aws apigatewayv2 update-api \
    --api-id a1b2c3d4 \
    --cors-configuration AllowOrigins=https://www.example.com
```
輸出：  

```
{
    "ApiEndpoint": "https://a1b2c3d4.execute-api.us-west-2.amazonaws.com",
    "ApiId": "a1b2c3d4",
    "ApiKeySelectionExpression": "$request.header.x-api-key",
    "CorsConfiguration": {
        "AllowCredentials": false,
        "AllowHeaders": [
            "header1",
            "header2"
        ],
        "AllowMethods": [
            "GET",
            "OPTIONS"
        ],
        "AllowOrigins": [
            "https://www.example.com"
        ]
    },
    "CreatedDate": "2020-04-08T18:39:37+00:00",
    "Name": "my-http-api",
    "ProtocolType": "HTTP",
    "RouteSelectionExpression": "$request.method $request.path",
    "Tags": {},
    "Version": "v1.0"
}
```
如需詳細資訊，請參閱《*Amazon API Gateway 開發人員指南*》中的[設定 HTTP API 的 CORS](https://docs.aws.amazon.com/apigateway/latest/developerguide/http-api-cors.html)。  
+  如需 API 詳細資訊，請參閱《AWS CLI 命令參考》**中的 [UpdateApi](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/apigatewayv2/update-api.html)。

### `update-authorizer`
<a name="apigatewayv2_UpdateAuthorizer_cli_topic"></a>

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

**AWS CLI**  
**更新授權方**  
下列 `update-authorizer` 範例將 JWT 授權方的身分來源變更為名為 `Authorization` 的標頭。  

```
aws apigatewayv2 update-authorizer \
    --api-id a1b2c3d4 \
    --authorizer-id a1b2c3 \
    --identity-source '$request.header.Authorization'
```
輸出：  

```
{
    "AuthorizerId": "a1b2c3",
    "AuthorizerType": "JWT",
    "IdentitySource": [
        "$request.header.Authorization"
    ],
    "JwtConfiguration": {
        "Audience": [
            "123456abc"
        ],
        "Issuer": "https://cognito-idp.us-west-2.amazonaws.com/us-west-2_abc123"
    },
    "Name": "my-jwt-authorizer"
}
```
如需詳細資訊，請參閱《*Amazon API Gateway 開發人員指南*》中的[使用 JWT 授權方控制對 HTTP API 的存取](https://docs.aws.amazon.com/apigateway/latest/developerguide/http-api-jwt-authorizer.html)。  
+  如需 API 詳細資訊，請參閱《AWS CLI 命令參考》**中的 [UpdateAuthorizer](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/apigatewayv2/update-authorizer.html)。

### `update-deployment`
<a name="apigatewayv2_UpdateDeployment_cli_topic"></a>

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

**AWS CLI**  
**變更部署的描述**  
下列 `update-deployment` 範例會更新部署的描述。  

```
aws apigatewayv2 update-deployment \
    --api-id a1b2c3d4 \
    --deployment-id abcdef \
    --description 'Manual deployment to fix integration test failures.'
```
輸出：  

```
{
    "AutoDeployed": false,
    "CreatedDate": "2020-02-05T16:21:48+00:00",
    "DeploymentId": "abcdef",
    "DeploymentStatus": "DEPLOYED",
    "Description": "Manual deployment to fix integration test failures."
}
```
如需詳細資訊，請參閱《*Amazon API Gateway 開發人員指南*》中的[在 Amazon API Gateway 中開發 HTTP API](https://docs.aws.amazon.com/apigateway/latest/developerguide/http-api-develop.html)。  
+  如需 API 詳細資訊，請參閱《AWS CLI 命令參考》**中的 [UpdateDeployment](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/apigatewayv2/update-deployment.html)。

### `update-domain-name`
<a name="apigatewayv2_UpdateDomainName_cli_topic"></a>

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

**AWS CLI**  
**更新自訂網域名稱**  
下列 `update-domain-name` 範例指定 `api.example.com` 自訂網域名稱的新 ACM 憑證。  

```
aws apigatewayv2 update-domain-name \
    --domain-name api.example.com \
    --domain-name-configurations CertificateArn=arn:aws:acm:us-west-2:123456789012:certificate/123456789012-1234-1234-1234-12345678
```
輸出：  

```
{
    "ApiMappingSelectionExpression": "$request.basepath",
    "DomainName": "regional.example.com",
    "DomainNameConfigurations": [
        {
            "ApiGatewayDomainName": "d-id.execute-api.us-west-2.amazonaws.com",
            "CertificateArn": "arn:aws:acm:us-west-2:123456789012:certificate/123456789012-1234-1234-1234-12345678",
            "EndpointType": "REGIONAL",
            "HostedZoneId": "123456789111",
            "SecurityPolicy": "TLS_1_2",
            "DomainNameStatus": "AVAILABLE"
        }
    ]
}
```
如需詳細資訊，請參閱《*Amazon API Gateway 開發人員指南*》中的[在 API Gateway 中設定區域自訂網域名稱](https://docs.aws.amazon.com/apigateway/latest/developerguide/apigateway-regional-api-custom-domain-create.html)。  
+  如需 API 詳細資訊，請參閱《AWS CLI 命令參考》**中的 [UpdateDomainName](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/apigatewayv2/update-domain-name.html)。

### `update-integration`
<a name="apigatewayv2_UpdateIntegration_cli_topic"></a>

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

**AWS CLI**  
**更新 Lambda 整合**  
下列`update-integration`範例會更新現有的 AWS Lambda 整合，以使用指定的 Lambda 函數。  

```
aws apigatewayv2 update-integration \
    --api-id a1b2c3d4 \
    --integration-id a1b2c3 \
    --integration-uri arn:aws:apigateway:us-west-2:lambda:path/2015-03-31/functions/arn:aws:lambda:us-west-2:123456789012:function:my-new-function/invocations
```
輸出：  

```
{
    "ConnectionType": "INTERNET",
    "IntegrationId": "a1b2c3",
    "IntegrationMethod": "POST",
    "IntegrationType": "AWS_PROXY",
    "IntegrationUri": "arn:aws:apigateway:us-west-2:lambda:path/2015-03-31/functions/arn:aws:lambda:us-west-2:123456789012:function:my-new-function/invocations",
    "PayloadFormatVersion": "2.0",
    "TimeoutInMillis": 5000
}
```
如需詳細資訊，請參閱《*Amazon API Gateway 開發人員指南*》中的[設定 HTTP API 的整合](https://docs.aws.amazon.com/apigateway/latest/developerguide/http-api-develop-integrations.html)和[設定 WebSocket API 整合](https://docs.aws.amazon.com/apigateway/latest/developerguide/apigateway-websocket-api-integrations.html)。  
+  如需 API 詳細資訊，請參閱《AWS CLI 命令參考》**中的 [UpdateIntegration](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/apigatewayv2/update-integration.html)。

### `update-route`
<a name="apigatewayv2_UpdateRoute_cli_topic"></a>

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

**AWS CLI**  
**範例 1：更新路由的整合**  
下列 `update-route` 範例更新指定路由的整合。  

```
aws apigatewayv2 update-route \
    --api-id a1b2c3d4 \
    --route-id a1b2c3 \
    --target integrations/a1b2c6
```
輸出：  

```
{
    "ApiKeyRequired": false,
    "AuthorizationType": "NONE",
    "RouteId": "a1b2c3",
    "RouteKey": "ANY /pets",
    "Target": "integrations/a1b2c6"
}
```
**範例 2：將授權方新增至路由**  
以下 `update-route` 範例使用指定的路由來使用 JWT 授權方。  

```
aws apigatewayv2 update-route \
    --api-id a1b2c3d4  \
    --route-id a1b2c3  \
    --authorization-type JWT \
    --authorizer-id a1b2c5 \
    --authorization-scopes user.id user.email
```
輸出：  

```
{
    "ApiKeyRequired": false,
    "AuthorizationScopes": [
        "user.id",
        "user.email"
    ],
    "AuthorizationType": "JWT",
    "AuthorizerId": "a1b2c5",
    "OperationName": "GET HTTP",
    "RequestParameters": {},
    "RouteId": "a1b2c3",
    "RouteKey": "GET /pets",
    "Target": "integrations/a1b2c6"
}
```
如需詳細資訊，請參閱《*Amazon API Gateway 開發人員指南*》中的[使用 JWT 授權方控制對 HTTP API 的存取](https://docs.aws.amazon.com/apigateway/latest/developerguide/http-api-jwt-authorizer.html)。  
+  如需 API 詳細資訊，請參閱《AWS CLI 命令參考》**中的 [UpdateRoute](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/apigatewayv2/update-route.html)。

### `update-stage`
<a name="apigatewayv2_UpdateStage_cli_topic"></a>

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

**AWS CLI**  
**設定自訂限流**  
下列 `update-stage` 範例針對指定的 API 階段和路由設定自訂限流。  

```
aws apigatewayv2 update-stage \
    --api-id a1b2c3d4 \
    --stage-name dev \
    --route-settings '{"GET /pets":{"ThrottlingBurstLimit":100,"ThrottlingRateLimit":2000}}'
```
輸出：  

```
{
    "CreatedDate": "2020-04-05T16:21:16+00:00",
    "DefaultRouteSettings": {
        "DetailedMetricsEnabled": false
    },
    "DeploymentId": "shktxb",
    "LastUpdatedDate": "2020-04-08T22:23:17+00:00",
    "RouteSettings": {
        "GET /pets": {
            "ThrottlingBurstLimit": 100,
            "ThrottlingRateLimit": 2000.0
        }
    },
    "StageName": "dev",
    "StageVariables": {},
    "Tags": {}
}
```
如需詳細資訊，請參閱《Amazon API Gateway 開發人員指南》**中的[保護 HTTP API](https://docs.aws.amazon.com/apigateway/latest/developerguide/http-api-protect.html)。  
+  如需 API 詳細資訊，請參閱《AWS CLI 命令參考》**中的 [UpdateStage](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/apigatewayv2/update-stage.html)。

### `update-vpc-link`
<a name="apigatewayv2_UpdateVpcLink_cli_topic"></a>

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

**AWS CLI**  
**更新 VPC 連結**  
下列 `update-vpc-link` 範例會更新 VPC 連結的名稱。建立 VPC 連結後，您無法變更其安全群組或子網路。  

```
aws apigatewayv2 update-vpc-link \
    --vpc-link-id abcd123 \
    --name MyUpdatedVpcLink
```
輸出：  

```
{
    "CreatedDate": "2020-04-07T00:27:47Z",
    "Name": "MyUpdatedVpcLink",
    "SecurityGroupIds": [
        "sg1234",
        "sg5678"
    ],
    "SubnetIds": [
        "subnet-aaaa",
        "subnet-bbbb"
    ],
    "Tags": {},
    "VpcLinkId": "abcd123",
    "VpcLinkStatus": "AVAILABLE",
    "VpcLinkStatusMessage": "VPC link is ready to route traffic",
    "VpcLinkVersion": "V2"
}
```
如需詳細資訊，請參閱《*Amazon API Gateway 開發人員指南*》中的[使用 HTTP API 的 VPC 連結](https://docs.aws.amazon.com/apigateway/latest/developerguide/http-api-vpc-links.html)。  
+  如需 API 詳細資訊，請參閱《AWS CLI 命令參考》**中的 [UpdateVpcLink](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/apigatewayv2/update-vpc-link.html)。