Amazon Web Services 文档中描述的 Amazon Web Services 服务或功能可能因区域而异。要查看适用于中国区域的差异,请参阅
中国的 Amazon Web Services 服务入门
(PDF)。
更改 REST API 的 IP 地址类型
您可以通过更新 API 的配置来更改 IP 地址类型。您可以使用 Amazon Web Services Management Console、Amazon CLI、Amazon CloudFormation 或 Amazon SDK 更新 API 的配置。如果您更改 API 的 IP 地址类型,您不需要重新部署 API 即可使更改生效。在更改 IP 地址类型之前,请确认任何控制 API 访问权限的策略均已更新以考虑 IPv6 调用。
- Amazon Web Services Management Console
-
- Amazon CLI
-
以下 update-rest-api 命令将 API 更新为具有双堆栈 IP 地址类型:
aws apigateway update-rest-api \
--rest-api-id abcd1234 \
--patch-operations "op='replace',path='/endpointConfiguration/ipAddressType',value='dualstack'"
输出将与以下内容类似:
{
"id": "abcd1234",
"name": "MyAPI",
"description": "My API with a dualstack IP address type",
"createdDate": "2025-02-04T11:47:06-08:00",
"apiKeySource": "HEADER",
"endpointConfiguration": {
"types": [
"REGIONAL"
],
"ipAddressType": "dualstack"
},
"tags": {},
"disableExecuteApiEndpoint": false,
"rootResourceId": "efg456"
}