

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

# 使用具有存取許可的線上儲存共享資源
<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)。