

• AWS Systems Manager CloudWatch 控制面板在 2026 年 4 月 30 日之后将不再可用。客户可以像现在一样继续使用 Amazon CloudWatch 控制台来查看、创建和管理其 Amazon CloudWatch 控制面板。有关更多信息，请参阅 [Amazon CloudWatch 控制面板文档](https://docs.aws.amazon.com/AmazonCloudWatch/latest/monitoring/CloudWatch_Dashboards.html)。

# 使用 Parameter Store 中的共享参数
<a name="parameter-store-shared-parameters"></a>

共享高级参数可简化多账户环境中的配置数据管理操作。您可以集中存储和管理参数，与需要引用这些参数的其他 AWS 账户 共享参数。

Parameter Store 与 AWS Resource Access Manager（AWS RAM）集成，可实现高级参数共享。AWS RAM 是一项服务，让您能够与其他 AWS 账户 共享资源，或者通过 AWS Organizations 共享资源。

通过使用 AWS RAM，您可以创建资源共享以共享您拥有的资源。资源共享指定要共享的资源、要授予的权限以及与之共享资源的使用者。使用者可包括：
+ AWS Organizations 中其组织内部或外部的特定 AWS 账户。
+ AWS Organizations 中的所有者组织内部的组织单位
+ 它在 AWS Organizations 中的整个组织

有关 AWS RAM 的更多信息，请参阅 *[AWS RAM 用户指南](https://docs.aws.amazon.com/ram/latest/userguide/)*。

本主题说明如何共享您拥有的参数以及如何使用共享给您的参数。

**Topics**
+ [共享参数的先决条件](#prereqs)
+ [共享参数](#share)
+ [停止共享共享参数](#unshare)
+ [标识共享参数](#identify)
+ [访问共享参数](#accessing)
+ [共享参数的权限集](#sharing-permissions)
+ [共享参数的最大吞吐量](#throughput)
+ [共享参数的定价](#pricing)
+ [已关闭 AWS 账户 的跨账户访问权限](#closed-accounts)

## 共享参数的先决条件
<a name="prereqs"></a>

要共享账户中的参数，就必须先满足以下先决条件：
+ 要共享参数，您必须在 AWS 账户 中拥有该参数。您无法共享已与您共享的参数。
+ 要共享参数，该参数就必须在高级参数层中。有关参数层的信息，请参阅 [管理参数层](parameter-store-advanced-parameters.md)。有关将现有标准参数更改为高级参数的信息，请参阅 [将标准参数更改为高级参数](parameter-store-advanced-parameters.md#parameter-store-advanced-parameters-enabling)。
+ 要共享 `SecureString` 参数，必须使用客户托管密钥对其进行加密，并且必须通过 AWS Key Management Service 单独共享该密钥。无法共享 AWS 托管式密钥。使用默认 AWS 托管式密钥 加密的参数可以更新为改用客户托管密钥。有关 AWS KMS 密钥的定义，请参阅《AWS Key Management Service Developer Guide**》中的 [AWS KMS concepts](https://docs.aws.amazon.com/kms/latest/developerguide/concepts.html#key-mgmt)。
+ 要与组织或 AWS Organizations 内的组织单位共享参数，您必须允许与 AWS Organizations 共享。有关更多信息，请参阅《AWS RAM 用户指南》**中的[在 AWS Organizations 中启用资源共享](https://docs.aws.amazon.com/ram/latest/userguide/getting-started-sharing.html#getting-started-sharing-orgs)。

## 共享参数
<a name="share"></a>

要共享参数，您必须将其添加到资源共享。资源共享是一项 AWS RAM 资源，可让您跨 AWS 账户共享资源。资源共享指定要共享的资源以及与之共享资源的使用者。

在与其他 AWS 账户 共享自己拥有的参数时，您可以从两个 AWS 托管权限中进行选择，授予使用者相应权限。有关更多信息，请参阅 [共享参数的权限集](#sharing-permissions)。

如果您属于 AWS Organizations 内的某个组织，并启用了组织内共享，则您可以授予组织中的使用者从 AWS RAM 控制台访问共享参数的权限。否则，使用者会收到加入资源共享的邀请，并在接受邀请后获得对共享参数的访问权限。

您可以使用 AWS RAM 控制台或 AWS CLI 共享自己拥有的参数。

**注意**  
虽然可以使用 Systems Manager [PutResourcePolicy](https://docs.aws.amazon.com/systems-manager/latest/APIReference/API_PutResourcePolicy.html) API 操作共享参数，但建议使用 AWS Resource Access Manager（AWS RAM）。这是因为使用 `PutResourcePolicy` 需要执行额外步骤，即使用 AWS RAM [PromoteResourceShareCreatedFromPolicy](https://docs.aws.amazon.com/ram/latest/APIReference/API_PromoteResourceShareCreatedFromPolicy.html) API 操作将参数提升为标准资源共享。否则，Systems Manager [DescribeParameters](https://docs.aws.amazon.com/systems-manager/latest/APIReference/API_DescribeParameters.html) API 操作不会使用 `--shared` 选项返回该参数。

**使用 AWS RAM 控制台共享拥有的参数**  
请参阅《AWS RAM 用户指南》**中的[在 AWS RAM 中创建资源共享](https://docs.aws.amazon.com/ram/latest/userguide/working-with-sharing.html#working-with-sharing-create)。

完成该过程时进行以下选择：
+ 在“步骤 1”页面中，对于**资源**，选择 `Parameter Store Advanced Parameter`，然后选中要共享的高级参数层中每个参数的框。
+ 在“步骤 2”页面中，对于**托管式权限**，选择要授予使用者的权限，如本主题后面部分的 [共享参数的权限集](#sharing-permissions) 中所述。

根据参数共享目标选择其他选项。

**使用 AWS CLI 共享拥有的参数**  
使用 [https://docs.aws.amazon.com/cli/latest/reference/ram/create-resource-share.html](https://docs.aws.amazon.com/cli/latest/reference/ram/create-resource-share.html) 命令向新的资源共享添加参数。

使用 [https://docs.aws.amazon.com/cli/latest/reference/ram/associate-resource-share.html](https://docs.aws.amazon.com/cli/latest/reference/ram/associate-resource-share.html) 命令向现有资源共享添加参数。

以下示例创建了一个新的资源共享，以便与组织和个人账户中的使用者共享参数。

```
aws ram create-resource-share \
    --name "MyParameter" \
    --resource-arns "arn:aws:ssm:us-east-2:123456789012:parameter/MyParameter" \
    --principals "arn:aws:organizations::123456789012:ou/o-63bEXAMPLE/ou-46xi-rEXAMPLE" "987654321098"
```

## 停止共享共享参数
<a name="unshare"></a>

停止共享共享参数后，使用者账户无法再访问该参数。

要停止共享拥有的参数，必须从资源共享中将其移除。您可以使用 Systems Manager 控制台、AWS RAM 控制台或 AWS CLI 完成此操作。

**使用 AWS RAM 控制台停止共享拥有的参数**  
请参阅《AWS RAM User Guide》**中的 [Update a resource share in AWS RAM](https://docs.aws.amazon.com/ram/latest/userguide/working-with-sharing-update.html)。

**使用 AWS CLI 停止共享拥有的参数**  
使用 [disassociate-resource-share](https://docs.aws.amazon.com/cli/latest/reference/ram/disassociate-resource-share.html) 命令。

## 标识共享参数
<a name="identify"></a>

拥有者和使用者可以使用 AWS CLI 标识共享参数。

**使用 AWS CLI 标识共享参数**  
要使用 AWS CLI 标识共享参数，可以选用 Systems Manager `[https://docs.aws.amazon.com/cli/latest/reference/ssm/describe-parameters.html](https://docs.aws.amazon.com/cli/latest/reference/ssm/describe-parameters.html)` 命令或 AWS RAM `[list-resources](https://docs.aws.amazon.com/cli/latest/reference/ram/list-resources.html)` 命令。

在将 `--shared` 选项与 `describe-parameters` 一起使用后，该命令会返回与您共享的参数。

以下是示例：

```
aws ssm describe-parameters --shared
```

## 访问共享参数
<a name="accessing"></a>

使用者可以使用 AWS 命令行工具和 AWS SDK 访问共享参数。对于使用者账户，与该类账户共享的参数未包含在**我的参数**页面中。

**CLI 示例：使用 AWS CLI 访问共享参数的详细信息**  
要使用 AWS CLI 访问共享参数的详细信息，可以使用 [https://docs.aws.amazon.com/cli/latest/reference/ssm/get-parameter.html](https://docs.aws.amazon.com/cli/latest/reference/ssm/get-parameter.html) 或 [https://docs.aws.amazon.com/cli/latest/reference/ssm/get-parameters.html](https://docs.aws.amazon.com/cli/latest/reference/ssm/get-parameters.html) 命令。必须将完整参数 ARN 指定为 `--name`，才能从其他账户检索参数。

示例如下：

```
aws ssm get-parameter \
    --name arn:aws:ssm:us-east-2:123456789012:parameter/MySharedParameter
```

**共享参数支持和不支持的集成**  
目前可在以下集成场景中使用共享参数：
+ AWS CloudFormation [模板参数](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/parameters-section-structure.html#aws-ssm-parameter-types)
+ [AWS 参数和密钥 Lambda 扩展](ps-integration-lambda-extensions.md)
+ [Amazon Elastic Compute Cloud（EC2）启动模板](https://docs.aws.amazon.com/autoscaling/ec2/userguide/using-systems-manager-parameters.html)
+ 使用 [EC2 RunInstances 命令](https://docs.aws.amazon.com/AWSEC2/latest/APIReference/API_RunInstances.html)从 Amazon Machine Image（AMI）创建实例的 `ImageID` 值
+ 针对 Automation（Systems Manager 中的一项工具）[在运行手册中检索参数值](https://repost.aws/knowledge-center/systems-manager-parameter-store)

以下场景和集成服务目前不支持使用共享参数：
+ Run Command（Systems Manager 中的一项工具）中[命令中的参数](sysman-param-runcommand.md)
+ AWS CloudFormation [动态引用](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/dynamic-references.html)
+ AWS CodeBuild 中[环境变量的值](https://docs.aws.amazon.com/codebuild/latest/userguide/build-spec-ref.html#build-spec.env.parameter-store)
+ AWS App Runner 中[环境变量的值](https://docs.aws.amazon.com/apprunner/latest/dg/env-variable.html)
+ Amazon Elastic Container Service 中[密钥的值](https://docs.aws.amazon.com/AmazonECS/latest/userguide/secrets-envvar-ssm-paramstore.html)

## 共享参数的权限集
<a name="sharing-permissions"></a>

使用者账户收到您与其共享参数的只读访问权限。使用者无法更新或删除该类参数。使用者无法与第三个账户共享该类参数。

在 AWS Resource Access Manager 中创建用于共享参数的资源共享时，可以从两个 AWS 托管式权限集中进行选择，以授予此只读访问权限：

**AWSRAMDefaultPermissionSSMParameterReadOnly**  
允许的操作：`DescribeParameters`、`GetParameter`、`GetParameters`

**AWSRAMPermissionSSMParameterReadOnlyWithHistory**  
允许的操作：`DescribeParameters`、`GetParameter`、`GetParameters`、`GetParameterHistory`

按照《AWS RAM 用户指南》**中[在 AWS RAM 中创建资源共享](https://docs.aws.amazon.com/ram/latest/userguide/working-with-sharing.html#working-with-sharing-create)的步骤进行操作时，选择 `Parameter Store Advanced Parameters` 作为资源类型，并根据您是否希望用户查看参数历史记录选择其中一种托管式权限。

**注意**  
如果以编程方式（例如使用 AWS Lambda）检索共享参数，则可能需要向任何调用 AWS Resource Access Manager API 操作的 IAM 角色添加 `ssm:GetResourcePolicies` 和 `ssm:PutResourcePolicy` 权限。

## 共享参数的最大吞吐量
<a name="throughput"></a>

Systems Manager 限制了 [https://docs.aws.amazon.com/systems-manager/latest/APIReference/API_GetParameter.html](https://docs.aws.amazon.com/systems-manager/latest/APIReference/API_GetParameter.html) 和 [https://docs.aws.amazon.com/systems-manager/latest/APIReference/API_GetParameters.html](https://docs.aws.amazon.com/systems-manager/latest/APIReference/API_GetParameters.html) 操作的最大吞吐量（每秒事务数）。吞吐量在个人账户级别强制实施。因此，使用共享参数的每个账户都可以使用允许的最大吞吐量，不会受到其他账户的影响。有关参数最大吞吐量的更多信息，请参阅以下主题：
+ [提高 Parameter Store 吞吐量](https://docs.aws.amazon.com/systems-manager/latest/userguide/parameter-store-throughput.html)
+ 《Amazon Web Services 一般参考》**中的 [Systems Manager service quotas](https://docs.aws.amazon.com/general/latest/gr/ssm.html#limits_ssm)。

## 共享参数的定价
<a name="pricing"></a>

只有高级参数层中支持跨账户共享。对于高级参数，每个高级参数的*存储*和 *API 使用量*按当前价格计费。高级参数的拥有账户需要支付此类参数的存储费用。对共享的高级参数进行 API 调用的使用账户，则需支付此类参数的使用费。

例如，账户 A 创建了高级参数 `MyAdvancedParameter`，则该账户每月需支付 0.05 美元来存储该参数。

然后，账户 A 与账户 B 和账户 C 共享 `MyAdvancedParameter`。在一个月内，这三个账户都会调用 `MyAdvancedParameter`。下表说明了各账户因调用次数产生的费用。

**注意**  
下表列示的费用仅供说明之用。要验证当前定价，请参阅 [Parameter Store 的 AWS Systems Manager 定价](https://aws.amazon.com/systems-manager/pricing/#Parameter_Store)。


| Account | 调用次数 | 收费 | 
| --- | --- | --- | 
| 账户 A（拥有账户） | 一万次调用 |  [\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/zh_cn/systems-manager/latest/userguide/parameter-store-shared-parameters.html)  | 
| 账户 B（使用账户） | 两万次调用 |  [\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/zh_cn/systems-manager/latest/userguide/parameter-store-shared-parameters.html)  | 
| 账户 C（使用账户） | 三万次调用 |  [\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/zh_cn/systems-manager/latest/userguide/parameter-store-shared-parameters.html)  | 

## 已关闭 AWS 账户 的跨账户访问权限
<a name="closed-accounts"></a>

如果拥有共享参数的 AWS 账户 已关闭，则所有使用账户都会失去对共享参数的访问权限。如果拥有账户在账户关闭后的 90 天内重新打开，则使用账户会重新获得对先前共享参数的访问权限。有关在关闭后期间重新打开账户的更多信息，请参阅《AWS 账户管理 Reference Guide》**中的 [Accessing your AWS 账户 after you close it](https://docs.aws.amazon.com/accounts/latest/reference/manage-acct-closing.html#accessing-after-closure)。