

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

# 與 共用線上功能群組 AWS Resource Access Manager
<a name="feature-store-cross-account-access-online-store"></a>

透過 AWS Resource Access Manager (AWS RAM)，您可以與其他 安全地共用 Amazon SageMaker Feature Store 線上功能群組 AWS 帳戶。您的團隊成員可以探索和存取跨多個帳戶的特徵群組、提升資料一致性、簡化共同作業，並減少重複工作量。

資源擁有者帳戶可以透過 AWS 帳戶 授予使用 的許可，與其他個人共用資源 AWS RAM。資源取用者帳戶是 AWS 帳戶 與之共用資源的 ，受限於從資源擁有者帳戶授予的許可。如果您是組織，建議您利用 AWS Organizations與個人 AWS 帳戶、組織中的所有帳戶或組織單位 (OU) 共用資源，而不必將許可套用至每個帳戶。如需教學影片和有關 AWS RAM 概念和優點的詳細資訊，請參閱 AWS RAM 《 使用者指南》中的[什麼是 AWS Resource Access Manager？](https://docs.aws.amazon.com/ram/latest/userguide/what-is.html)。

請注意，每個 AWS 帳戶的每個 API 的每秒交易數 (TPS) 有一個軟性上限。TPS 上限會套用至資源擁有者帳戶內資源上的*所有*交易，因此來自資源消費者帳戶的交易也會計入此上限。如需有關服務配額以及如何請求提高配額的更多資訊，請參閱 [AWS 服務配額](https://docs.aws.amazon.com/general/latest/gr/aws_service_limits.html)。

本節說明資源擁有者帳戶如何選擇特徵群組，並將存取權限 (唯讀、讀寫和管理員) 授予資源消費者帳戶，以及具有存取權限的資源消費者帳戶如何使用這些特徵群組。存取許可不允許資源消費者帳戶搜尋和探索特徵群組。若要允許資源消費者帳戶從資源擁有者帳戶搜尋和探索特徵群組，資源擁有者帳戶必須將探索能力許可授予資源消費者帳戶，資源消費者帳戶可探索資源擁有者帳戶中的所有特徵群組。如需有關授予探索能力許可的更多相關資訊，請參閱[啟用跨帳戶探索能力](feature-store-cross-account-discoverability.md)。

下列主題說明如何使用 AWS RAM 主控台共用特徵商店線上商店資源。如需 AWS 使用主控台或 AWS Command Line Interface (AWS CLI) 在 中共用資源和授予許可的相關資訊， AWS RAM 請參閱[共用資源 AWS](https://docs.aws.amazon.com/ram/latest/userguide/getting-started-sharing.html)。

**Topics**
+ [共用您的特徵群組實體](feature-store-cross-account-access-online-store-share-feature-group.md)
+ [使用具有存取許可的線上儲存共享資源](feature-store-cross-account-access-online-store-use.md)

# 共用您的特徵群組實體
<a name="feature-store-cross-account-access-online-store-share-feature-group"></a>

身為資源擁有者帳戶，您可以在 AWS Resource Access Manager () 中建立資源共用，以使用 Amazon SageMaker Feature Store 的功能群組資源類型來共用功能群組實體AWS RAM。

使用下列說明以及 AWS RAM 《 使用者指南》中的[共用您的 AWS 資源](https://docs.aws.amazon.com/ram/latest/userguide/getting-started-sharing.html#getting-started-sharing-create)說明。

使用 AWS RAM 主控台共用功能群組資源類型時，您需要做出下列選擇。

1. **指定資源共享詳細資訊**：
   + 資源類型：選擇 **SageMaker AI 特徵群組**。
   + ARN：選擇具有下列格式的特徵群組 ARN：`arn:aws:sagemaker:us-east-1:111122223333:feature-group/your-feature-group-name`。

     `us-east-1` 是資源的區域，`111122223333` 是資源擁有者帳戶 ID，`your-feature-group-name` 是共用的特徵群組。
   + 資源 ID：選擇要授予存取許可的特徵群組 `your-feature-group-name`。

1. **關聯受管許可**：
   + 受管許可：選擇存取許可。如需有關存取許可的更多相關資訊，請參閱[啟用跨帳戶存取權](feature-store-cross-account-access.md)。

1. **授予存取權給主體**：
   + 選擇主體類型 (AWS 帳戶、組織、組織單位、IAM 角色或 IAM 使用者)，然後輸入適當的 ID 或 ARN。

1. **檢閱和建立**：
   + 檢閱，然後選擇**建立資源共用**。

授予任何存取客戶並不會授予資源消費者帳戶探索能力許可，因此具有存取許可的資源消費者帳戶無法搜尋和探索這些特徵群組。若要允許資源消費者帳戶從資源擁有者帳戶搜尋和探索特徵群組，資源擁有者帳戶必須將探索能力許可授予資源消費者帳戶，資源消費者帳戶可探索資源擁有者帳戶中的*所有*特徵群組。如需有關授予探索能力許可的更多相關資訊，請參閱[啟用跨帳戶探索能力](feature-store-cross-account-discoverability.md)。

如果僅授予資源消費者帳戶存取許可，則仍可在 AWS RAM上檢視特徵群組實體。若要檢視 上的資源 AWS RAM，請參閱 AWS RAM 《 使用者指南》中的[存取 AWS 與您共用的資源](https://docs.aws.amazon.com/ram/latest/userguide/working-with-shared.html)。

資源共用和主體或資源消費者帳戶可能需要幾分鐘的時間才能完成關聯。設定資源共用和主體關聯後，指定的資源消費者帳戶會收到加入該資源共用的邀請。資源取用者帳戶可以在 AWS RAM 主控台中開啟[與我共用：資源共用](https://console.aws.amazon.com/ram/home#SharedResourceShares)頁面，以檢視並接受邀請。在這些情況下，邀請將不會送出：
+ 如果您是 中組織的一部分， AWS Organizations 並在組織中啟用共用，則組織中的主體會自動存取共用資源，而無需邀請。
+ 如果您與擁有資源 AWS 帳戶 的 共用，則該帳戶中的主體會自動存取共用資源，而無需邀請。

如需有關在 中接受和使用資源共用的詳細資訊 AWS RAM，請參閱 AWS RAM 《 使用者指南》中的[使用共用 AWS 資源](https://docs.aws.amazon.com/ram/latest/userguide/getting-started-shared.html)。

## 使用 共用線上商店功能群組 適用於 Python (Boto3) 的 AWS SDK
<a name="feature-store-cross-account-access-online-store-python-sdk-example"></a>

您可以使用 適用於 Python (Boto3) 的 AWS SDK AWS RAM APIs來建立資源共享。下列程式碼是資源擁有者帳戶 ID `111122223333` 建立名為 `'test-cross-account-fg'` 的資源共用的範例，該資源擁有者帳戶在授予 `AWSRAMPermissionSageMakerFeatureGroupReadOnly` 許可的同時與資源消費者帳號 ID `444455556666` 共用名為 `'my-feature-group'` 的特徵群組。如需有關存取許可的更多相關資訊，請參閱[啟用跨帳戶存取權](feature-store-cross-account-access.md)。若要使用適用於 AWS RAM APIs Python 開發套件，您需要使用執行角色連接 AWS RAM 完整存取受管政策。如需詳細資訊，請參閱 [create\$1resource\$1share](https://boto3.amazonaws.com/v1/documentation/api/latest/reference/services/ram/client/create_resource_share.html) AWS RAM API。

```
import boto3

# Choose feature group name
feature_group_name = 'my-feature-group' # Change to your feature group name 

# Share 'my-feature-group' with other account
ram_client = boto3.client("ram")
response = ram_client.create_resource_share(
    name='test-cross-account-fg', # Change to your custom resource share name
    resourceArns=[
        'arn:aws:sagemaker:us-east-1:111122223333:feature-group/' + feature_group_name, # Change 111122223333 to the resource owner account ID
    ],
    principals=[
        '444455556666', # Change 444455556666 to the resource consumer account ID
    ],
    permissionArns = ["arn:aws:ram::aws:permission/AWSRAMPermissionSageMakerFeatureGroupReadOnly"]
)
```

主體是安全系統中的執行者。在基於資源的政策中，允許的主體為 IAM 使用者、IAM 角色、根帳戶或其他 AWS 服務。

# 使用具有存取許可的線上儲存共享資源
<a name="feature-store-cross-account-access-online-store-use"></a>

資源擁有者帳戶必須授予許可給資源消費者帳戶，才能允許共享資源的探索能力、唯讀、寫入或管理員權限。在以下各節中，我們提供如何接受存取共享資源邀請的指示，並提供如何檢視共用特徵群組並與之互動的範例。

**接受使用 AWS RAM存取共享資源的邀請**

作為資源消費者帳戶，您會收到加入資源共用的邀請，一旦資源擁有者帳戶授予許可。若要接受任何共用資源的邀請，請在 AWS RAM 主控台中開啟[與我共用：資源共用](https://console.aws.amazon.com/ram/home#SharedResourceShares)頁面，以檢視和回應邀請。在這些情況下，邀請將不會送出：
+ 如果您是 中組織的一部分， AWS Organizations 並在組織中啟用共用，則組織中的主體會自動存取共用資源，而無需邀請。
+ 如果您與擁有資源 AWS 帳戶 的 共用，則該帳戶中的主體會自動存取共用資源，而無需邀請。

如需有關在 中接受和使用資源共用的詳細資訊 AWS RAM，請參閱 AWS RAM 《 使用者指南》中的[使用共用 AWS 資源](https://docs.aws.amazon.com/ram/latest/userguide/getting-started-shared.html)。

## 在 AWS RAM 主控台上檢視共用資源
<a name="feature-store-cross-account-access-online-store-use-view"></a>

授予任何存取客戶並不會授予資源消費者帳戶探索能力許可，因此具有存取許可的資源消費者帳戶無法搜尋和探索這些特徵群組。若要允許資源消費者帳戶從資源擁有者帳戶搜尋和探索特徵群組，資源擁有者帳戶必須將探索能力許可授予資源消費者帳戶，資源消費者帳戶可探索資源擁有者帳戶中的所有特徵群組。如需有關授予探索能力許可的更多相關資訊，請參閱[啟用跨帳戶探索能力](feature-store-cross-account-discoverability.md)。

若要在 AWS RAM 主控台上檢視共用資源，請在 AWS RAM 主控台中開啟[與我共用：資源共用](https://console.aws.amazon.com/ram/home#SharedResourceShares)頁面。

## 具有共用特徵群組的讀取和寫入動作範例
<a name="feature-store-cross-account-access-online-store-use-read-write-actions"></a>

資源擁有者帳戶將適當的許可授予您的資源消費者帳戶後，您可以使用特徵商店 SDK 對共享資源執行動作。您可以提供資源 ARN 作為 `FeatureGroupName` 來完成此動作。若要取得特徵群組 ARN，您可以使用 適用於 Python (Boto3) 的 AWS SDK [https://boto3.amazonaws.com/v1/documentation/api/1.26.98/reference/services/sagemaker/client/describe_feature_group.html#describe-feature-group](https://boto3.amazonaws.com/v1/documentation/api/1.26.98/reference/services/sagemaker/client/describe_feature_group.html#describe-feature-group)函數或使用主控台 UI。如需如何使用主控台 UI 檢視特徵群組詳細資訊的相關資訊，請參閱[從主控台檢視特徵群組詳細資訊](feature-store-use-with-studio.md#feature-store-view-feature-group-detail-studio)。

以下範例將 `PutRecord` 與 `GetRecord` 和共用特徵群組實體搭配使用。請參閱 和 適用於 Python (Boto3) 的 AWS SDK 文件中的請求[https://boto3.amazonaws.com/v1/documentation/api/1.26.98/reference/services/firehose/client/put_record.html#put-record](https://boto3.amazonaws.com/v1/documentation/api/1.26.98/reference/services/firehose/client/put_record.html#put-record)和回應語法[https://boto3.amazonaws.com/v1/documentation/api/1.26.98/reference/services/sagemaker-featurestore-runtime/client/get_record.html#get-record](https://boto3.amazonaws.com/v1/documentation/api/1.26.98/reference/services/sagemaker-featurestore-runtime/client/get_record.html#get-record)。

```
import boto3

sagemaker_featurestore_runtime = boto3.client('sagemaker-featurestore-runtime')

# Put record into feature group named 'test-fg' within the resource owner account ID 111122223333
featurestore_runtime.put_record(
    FeatureGroupName="arn:aws:sagemaker:us-east-1:111122223333:feature-group/test-fg", 
    Record=[value.to_dict() for value in record] # You will need to define record prior to calling PutRecord
)
```

```
import boto3

sagemaker_featurestore_runtime = boto3.client('sagemaker-featurestore-runtime')

# Choose record identifier
record_identifier_value = str(2990130)

# Get record from feature group named 'test-fg' within the resource owner account ID 111122223333
featurestore_runtime.get_record(
    FeatureGroupName="arn:aws:sagemaker:us-east-1:111122223333:feature-group/test-fg", 
    RecordIdentifierValueAsString=record_identifier_value
)
```

如需入關將許可授予特徵群組實體的更多相關資訊，請參閱[共用您的特徵群組實體](feature-store-cross-account-access-online-store-share-feature-group.md)。