

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

# API 提供者：使用 停止共用私有自訂網域名稱 AWS RAM
<a name="apigateway-private-custom-domains-provider-stop-sharing"></a>

若要停止分享您的私有自訂網域名稱，請先取消資源分享的關聯，以停止 API 取用者建立更多網域名稱存取關聯。然後，您拒絕網域名稱存取關聯，並從 `execute-api` 服務的 `policy` 中移除 API 取用者的 VPC 端點。API 取用者接著可以刪除其網域名稱存取關聯。

## 停止分享您的私有自訂網域名稱
<a name="apigateway-private-custom-domains-provider-dissociate-ram"></a>

首先，您使用 停止資源共享 AWS RAM。

------
#### [ AWS 管理主控台 ]

若要使用 AWS 管理主控台，請參閱[在 中更新資源共用 AWS RAM](https://docs.aws.amazon.com/ram/latest/userguide/working-with-sharing-update.html)。

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

下列 [disassociate-resource-share](https://docs.aws.amazon.com/cli/latest/reference/ram/disassociate-resource-share.html) 會取消您的私有自訂網域名稱的資源分享的關聯。

```
aws ram disassociate-resource-share \
    --region us-west-2 \
    --resource-arns arn:aws:apigateway:us-west-2:111122223333:/domainnames/private.example.com+abcd1234 \
    --principals 222222222222
```

------

## 拒絕網域名稱存取關聯
<a name="apigateway-private-custom-domains-provider-reject"></a>

停止使用 共用資源後 AWS RAM，您會拒絕另一個帳戶中的 VPC 端點與私有自訂網域名稱之間的網域名稱存取關聯。

**注意**  
您無法拒絕自己帳戶中的網域名稱存取關聯。若要停止資源分享，請刪除網域名稱存取關聯。如需詳細資訊，請參閱[刪除網域名稱存取關聯](apigateway-private-custom-domains-tutorial.md#apigateway-private-custom-domains-cleanup)。

當您拒絕網域名稱與 VPC 端點的存取關聯時，如果 API 取用者嘗試呼叫您的私有自訂網域名稱，API Gateway 會拒絕呼叫，並傳回 `403` 狀態碼。

------
#### [ AWS 管理主控台 ]

**拒絕網域名稱存取關聯**

1. 在以下網址登入 API Gateway 主控台：[https://console.aws.amazon.com/apigateway](https://console.aws.amazon.com/apigateway)。

1. 在主要導覽窗格中，選擇**自訂網域名稱**。

1. 選擇您與其他 共用的私有自訂網域名稱 AWS 帳戶。

1. 在**資源分享**上，選擇您要拒絕的網域名稱存取關聯。

1. 選擇**拒絕關聯**。

1. 確認您的選擇，然後選擇**拒絕**。

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

下列 `reject-domain-name-access-association` 命令會拒絕 VPC 端點與私有自訂網域名稱之間的網域名稱存取關聯：

```
aws apigateway reject-domain-name-access-association \
    --domain-name-access-association-arn arn:aws:apigateway:us-west-2:444455556666:/domainnameaccessassociations/domainname/private.example.com+abcd1234/vpcesource/vpce-abcd1234efg \
    --domain-name-arn arn:aws:apigateway:us-west-2:111122223333:/domainnames/private.example.com+abcd1234
```

------

## 拒絕 API 提供者存取，以調用您的私有自訂網域名稱
<a name="apigateway-private-custom-domains-provider-deny-access"></a>

拒絕網域名稱存取關聯後，您可以從 `execute-api` 服務的 `policy` 中移除 API 取用者 VPC 端點。

------
#### [ AWS 管理主控台 ]

**從資源政策中移除 API 取用者的 VPC 端點**

1. 在以下網址登入 API Gateway 主控台：[https://console.aws.amazon.com/apigateway](https://console.aws.amazon.com/apigateway)。

1. 在主要導覽窗格中，選擇**自訂網域名稱**。

1. 選擇您與其他 共用的私有自訂網域名稱 AWS 帳戶。

1. 在**資源政策**標籤上，選擇**編輯**。

1. 從政策中移除 VPC 端點。

1. 選擇**儲存變更**。

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

下列 [update-domain-name](https://docs.aws.amazon.com/cli/latest/reference/apigateway/update-domain-name.html) 命令使用修補程式作業來更新私有自訂網域名稱之 `execute-api` 服務的 `policy`。此新的 `policy` 會移除 [允許其他帳戶調用您的私有自訂網域名稱](apigateway-private-custom-domains-provider-share.md#apigateway-private-custom-domains-provider-policy-update) 中新增的其他 VPC 端點 ID：

```
aws apigateway update-domain-name
    --domain-name private.example.com \
    --domain-name-id abcd1234 \
    --patch-operations op=replace,path=/policy,value='"{\"Version\": \"2012-10-17\",		 	 	 \"Statement\": [{\"Effect\": \"Allow\",\"Principal\": \"*\",\"Action\": \"execute-api:Invoke\",\"Resource\":[\"execute-api:/*\"]},{\"Effect\": \"Deny\",\"Principal\": \"*\",\"Action\": \"execute-api:Invoke\",\"Resource\":[\"execute-api:/*\"],\"Condition\":{\"StringNotEquals\":{\"aws:SourceVpce\": \"vpce-abcd1234efg\"}}}]}"
```

------

API 取用者接著應該刪除網域名稱存取關聯。您無法為他們刪除存取關聯。如需詳細資訊，請參閱[API 取用者：刪除與私有自訂網域名稱的網域名稱存取關聯](apigateway-private-custom-domains-consumer-delete-domain-name-access-association.md)。