

本文属于机器翻译版本。若本译文内容与英语原文存在差异，则一律以英文原文为准。

# 使用具有访问权限的在线存储共享资源
<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 请在控制台中打开 “[与我共享：资源](https://console.aws.amazon.com/ram/home#SharedResourceShares)共享” 页面。 AWS RAM 

## 共享特征组的读写操作示例
<a name="feature-store-cross-account-access-online-store-use-read-write-actions"></a>

资源拥有者账户向您的资源使用者账户授予相应权限后，您就可以使用 Feature Store 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)。