

# 使用共享前缀列表
<a name="work-with-shared-prefixes"></a>

Amazon 前缀列表提供了一种便捷的方式来管理和引用各种 Amazon 服务使用的 IP 地址范围。除了 Amazon 托管前缀列表，您还可以创建自己的客户管理的前缀列表并与其他 Amazon 账户共享。

共享前缀列表对于具有复杂联网要求的组织或需要在多个 Amazon 工作负载之间协调 IP 地址使用的组织特别有用。通过共享前缀列表，您可以确保一致的 IP 地址管理，简化协作者的联网配置。

本节旨在介绍如何共享前缀列表，以及如何识别和使用已与自己账户共享的前缀列表。

**Topics**
+ [共享前缀列表](#sharing-share)
+ [将共享前缀列表取消共享](#sharing-unshare)
+ [识别共享前缀列表](#sharing-identify)
+ [识别对共享前缀列表的引用](#sharing-identify-references)

## 共享前缀列表
<a name="sharing-share"></a>

要共享前缀列表，您必须将它添加到资源共享。如果您没有资源共享，则必须首先使用 [Amazon RAM 控制台](https://console.amazonaws.cn/ram)创建一个。

如果您是 Amazon Organizations 中某企业的一部分并且已在您的企业中启用共享，企业中的使用者将自动获得对共享前缀列表的访问权限。否则，使用者将会收到加入资源共享的邀请，并在接受邀请后获得对共享前缀列表的访问权限。

您可以使用 Amazon RAM 控制台或 Amazon CLI 创建资源共享并共享您拥有的前缀列表。

**重要**  
要共享前缀列表，您必须拥有它。您无法共享已与您共享的前缀列表。您不能共享Amazon托管的前缀列表。
要与您的企业或 Amazon Organizations 内的企业部门共享前缀列表，您必须允许与 Amazon Organizations 共享。有关更多信息，请参阅《*Amazon RAM 用户指南*》中的[允许与 Amazon Organizations 共享](https://docs.amazonaws.cn/ram/latest/userguide/getting-started-sharing.html#getting-started-sharing-orgs)。

**使用 Amazon RAM 控制台创建资源共享并共享前缀列表**  
按照 *Amazon RAM 用户指南*中[创建资源共享](https://docs.amazonaws.cn/ram/latest/userguide/getting-started-sharing.html#getting-started-sharing-create)的步骤操作。对于**选择资源类型**，选择**前缀列表**，然后选中您的前缀列表的复选框。

**使用 Amazon RAM 控制台将前缀列表添加到现有资源共享**  
要将您拥有的托管前缀添加到现有资源共享，请按照 *Amazon RAM 用户指南*中[更新资源共享](https://docs.amazonaws.cn/ram/latest/userguide/working-with-sharing.html#working-with-sharing-update)的步骤操作。对于**选择资源类型**，选择**前缀列表**，然后选中您的前缀列表的复选框。

**使用 Amazon CLI 共享您拥有的前缀列表**  
使用以下命令创建和更新资源共享：
+ [create-resource-share](https://docs.amazonaws.cn/cli/latest/reference/ram/create-resource-share.html) 
+ [associate-resource-share](https://docs.amazonaws.cn/cli/latest/reference/ram/associate-resource-share.html) 
+ [update-resource-share](https://docs.amazonaws.cn/cli/latest/reference/ram/update-resource-share.html) 

## 将共享前缀列表取消共享
<a name="sharing-unshare"></a>

取消共享前缀列表后，使用者不再可以在其账户中查看前缀列表或条目，也无法在其资源中引用前缀列表。如果已在使用者的资源中引用前缀列表，则这些引用将继续正常运行，并且您可以继续[查看这些引用](#sharing-identify-references)。如果将前缀列表更新为新版本，则引用将使用最新版本。

要取消共享您拥有的已共享前缀列表，必须使用 Amazon RAM 从资源共享中将其删除。

**使用 Amazon RAM 控制台取消共享您拥有的共享前缀列表**  
请参阅 *Amazon RAM 用户指南*中的[更新资源共享](https://docs.amazonaws.cn/ram/latest/userguide/working-with-sharing.html#working-with-sharing-update)。

**使用 Amazon CLI 取消共享您拥有的共享前缀列表**  
使用 [disassociate-resource-share](https://docs.amazonaws.cn/cli/latest/reference/ram/disassociate-resource-share.html) 命令。

## 识别共享前缀列表
<a name="sharing-identify"></a>

拥有者和使用者可以使用 Amazon VPC 控制台和 Amazon CLI 识别共享前缀列表。

**使用 Amazon VPC 控制台识别共享前缀列表**

1. 通过以下网址打开 Amazon VPC 控制台：[https://console.aws.amazon.com/vpc/](https://console.amazonaws.cn/vpc/)。

1. 在导航窗格中，选择**托管前缀列表**。

1. 此页面显示您拥有的前缀列表以及与您共享的前缀列表。**拥有者 ID** 列显示前缀列表拥有者的 Amazon 账户 ID。

1. 要查看前缀列表的资源共享信息，请选择该前缀列表，然后选择下部窗格中的**共享**。

**使用 Amazon CLI 识别共享的前缀列表**  
使用 [describe-managed-prefix-lists](https://docs.amazonaws.cn/cli/latest/reference/ec2/describe-managed-prefix-lists.html) 命令。该命令返回您拥有的前缀列表以及与您共享的前缀列表。`OwnerId` 显示前缀列表拥有者的 Amazon 账户 ID。

## 识别对共享前缀列表的引用
<a name="sharing-identify-references"></a>

所有者可以识别使用者拥有的引用共享前缀列表的资源。

**使用 Amazon VPC 控制台识别对共享前缀列表的引用**

1. 通过以下网址打开 Amazon VPC 控制台：[https://console.aws.amazon.com/vpc/](https://console.amazonaws.cn/vpc/)。

1. 在导航窗格中，选择**托管前缀列表**。

1. 选择前缀列表，然后选择下部窗格中的**关联**。

1. 引用前缀列表的资源的 ID 列在**资源 ID** 列中。资源的拥有者列在**资源拥有者**列中。

**使用 Amazon CLI 识别对共享前缀列表的引用**  
使用 [get-managed-prefix-list-associations](https://docs.amazonaws.cn/cli/latest/reference/ec2/get-managed-prefix-list-associations.html) 命令。