

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

# 在 中刪除資源共享 AWS RAM
<a name="working-with-sharing-delete"></a>

您可以隨時刪除資源共享。當您刪除資源共用時，與資源共用相關聯的所有主體都會失去共用資源的存取權。刪除資源共用不會刪除共用的資源。

**刪除 AWS 資源**  
如果您需要刪除包含在 AWS 資源共享中的資源， AWS 建議您先確保從包含資源共享中移除資源，或刪除資源共享。

刪除的資源共享在刪除後會短暫保留在 AWS RAM 主控台中，但其狀態會變更為 `Deleted`。

------
#### [ Console ]

**刪除資源共享**

1. 在 **[主控台中開啟由我共用：資源共用](https://console.aws.amazon.com/ram/home#OwnedResourceShares:)**頁面。 AWS RAM 

1. 由於 AWS RAM 資源共用存在於特定 中 AWS 區域， AWS 區域 請從主控台右上角的下拉式清單中選擇適當的 。若要查看包含全域資源的資源共用，您必須將 AWS 區域 設定為美國東部 （維吉尼亞北部）、 (`us-east-1`)。如需共用全域資源的詳細資訊，請參閱 [與全域資源相比，共用區域資源](working-with-regional-vs-global.md)。

1. 選取您要刪除的資源共用。
**警告**  
 請務必選取正確的資源共用。刪除資源共享之後，就無法復原該資源共享。

1. 選擇**刪除**，然後在確認訊息中，選擇**刪除**。

1. 刪除的資源共享會在兩小時後消失。在此之前，它會在主控台中保持可見狀態為已刪除。

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

**刪除資源共享**  
您可以使用 [delete-resource-share](https://docs.aws.amazon.com/cli/latest/reference/ram/delete-resource-share.html) 命令來刪除您不再需要的資源共用。

下列範例會先使用 [get-resource-shares](https://docs.aws.amazon.com/cli/latest/reference/ram/get-resource-shares.html) 命令來取得您要刪除之資源共享的 Amazon Resource Name (ARN)。然後，它會使用 [delete-resource-share](https://docs.aws.amazon.com/cli/latest/reference/ram/delete-resource-share.html) 來刪除指定的資源共用。

```
$  aws ram get-resource-shares \
    --region us-east-1 \
    --resource-owner SELF
{
    "resourceShares": [
        {
            "resourceShareArn": "arn:aws:ram:us-east-1:123456789012:resource-share/2ebe77d7-4156-4a93-87a4-228568d04425",
            "name": "MySubnetShare",
            "owningAccountId": "123456789012",
            "allowExternalPrincipals": true,
            "status": "ACTIVE",
            "creationTime": "2021-09-10T15:38:54.449000-07:00",
            "lastUpdatedTime": "2021-09-10T15:38:54.449000-07:00",
            "featureSet": "STANDARD"
        }
    ]
}
$ aws ram delete-resource-share \
    --region us-east-1 \
    --resource-share-arn arn:aws:ram:us-east-1:123456789012:resource-share/2ebe77d7-4156-4a93-87a4-228568d04425
{
    "returnValue": true
}
```

------