

# 编辑账户中扩展的配置数据
<a name="registry-set-configuration"></a>

本主题提供有关编辑特定区域内账户中扩展配置数据的指导。扩展可包含应用于给定账户和区域所有扩展实例的配置属性。扩展作者会在扩展的配置定义中定义这些属性。如果扩展的配置定义中有任何必需的属性，则必须先指定这些属性，然后才能在您的账户和区域中使用扩展。

有关在开发扩展时如何定义配置定义的更多信息，请参阅以下文档。
+ [挂钩配置架构语法参考](https://docs.aws.amazon.com/cloudformation-cli/latest/hooks-userguide/hook-configuration-schema.html)
+ [定义扩展的账户级配置](https://docs.aws.amazon.com/cloudformation-cli/latest/userguide/resource-type-model.html#resource-type-howto-configuration)

**Topics**
+ [

## 使用动态引用所需的权限
](#registry-set-configuration-considerations)
+ [

## 编辑扩展的配置数据（控制台）
](#registry-set-configuration-procedure-console)
+ [

## 编辑扩展的配置数据（AWS CLI）
](#registry-set-configuration-procedure-cli)

## 使用动态引用所需的权限
<a name="registry-set-configuration-considerations"></a>

如果配置数据包含对存储在 AWS Systems Manager 或 AWS Secrets Manager 中的值的动态引用，则用于预置类型的任何角色（例如，在创建或更新堆栈时）必须具有检索该值的适当权限。具体来说：
+ 如果配置数据包含存储在 AWS Systems Manager Parameter Store 中的参数，则用于预置该类型的用户或角色必须有权调用 [https://docs.aws.amazon.com/systems-manager/latest/APIReference/API_GetParameter.html](https://docs.aws.amazon.com/systems-manager/latest/APIReference/API_GetParameter.html)。
+ 如果配置数据包含存储在 AWS Secrets Manager 中的密钥，则用于预置该类型的用户或角色必须有权调用 [https://docs.aws.amazon.com/secretsmanager/latest/apireference/API_GetSecretValue.html](https://docs.aws.amazon.com/secretsmanager/latest/apireference/API_GetSecretValue.html)。

有关更多信息，请参阅 [使用动态引用获取存储在其他服务中的值](dynamic-references.md)。

## 编辑扩展的配置数据（控制台）
<a name="registry-set-configuration-procedure-console"></a>

请按照本部分中的步骤，使用控制台来执行以下操作：
+ 查看扩展的当前配置数据
+ 更新账户的扩展配置数据

**查看扩展的当前配置数据**

1. 登录到 AWS 管理控制台 并打开 CloudFormation 控制台 [https://console.aws.amazon.com/cloudformation](https://console.aws.amazon.com/cloudformation/)。

1. 在屏幕顶部的导航栏中，选择您的 AWS 区域。

1. 从导航窗格的**注册表**下，选择**已激活的扩展程序**。

1. 找到您要查看的扩展。有关更多信息，请参阅 [查看 CloudFormation 注册表中可用和已激活的扩展](registry-view.md)。

1. 选择扩展以查看扩展详细信息。

1. 在扩展详细信息页面上，选择 **Configuration**（配置）选项卡。

1. 展开 **Configuration schema**（配置架构）选项卡以查看为扩展定义的配置架构。

1. 展开 **Configuration**（配置）选项卡以查看为此扩展设置的当前配置。

**更新扩展的配置数据**

1. 在扩展详细信息页面上，从**配置**选项卡中选择**编辑配置**。

   或者，从**操作**中选择**编辑**，然后选择**编辑配置**。

   CloudFormation 将显示 **Configure extension**（配置扩展）页面。确保打开 **View configuration schema**（查看配置架构）以查看扩展的当前配置定义架构。

1. 在 **Configuration JSON**（配置 JSON）文本框中，输入一个 JSON 字符串，该字符串表示要为此扩展设置的配置架构。它必须根据 **Configuration schema**（配置架构）中定义的架构进行验证。

1. 选择**配置扩展程序**。

## 编辑扩展的配置数据（AWS CLI）
<a name="registry-set-configuration-procedure-cli"></a>

请按照本部分中的步骤，使用 AWS CLI 来执行以下操作：
+ 查看扩展的当前配置数据
+ 更新账户的扩展配置数据

**查看扩展的当前配置数据**
+ 使用 [https://docs.aws.amazon.com/cli/latest/reference/cloudformation/describe-type.html](https://docs.aws.amazon.com/cli/latest/reference/cloudformation/describe-type.html) 命令返回有关扩展的详细信息。输出的 `ConfigurationSchema` 元素包含给定区域中扩展的当前配置定义。

  或者，使用 [https://docs.aws.amazon.com/cli/latest/reference/cloudformation/batch-describe-type-configurations.html](https://docs.aws.amazon.com/cli/latest/reference/cloudformation/batch-describe-type-configurations.html) 命令返回有关多个扩展的配置数据。

**更新扩展的配置数据**
+ 使用 [https://docs.aws.amazon.com/cli/latest/reference/cloudformation/set-type-configuration.html](https://docs.aws.amazon.com/cli/latest/reference/cloudformation/set-type-configuration.html) 命令指定配置数据。为 `--configuration` 传递的 JSON 必须根据扩展的配置架构进行验证。

  在以下示例中，**set-type-configuration** 命令指定了 `--configuration` 选项的配置数据 *`"{"CredentialKey": "testUserCredential"}"`*。

  ```
  aws cloudformation set-type-configuration --type RESOURCE \
    --type-name My::Resource::Example \
    --configuration-alias default \
    --configuration "{"CredentialKey": "testUserCredential"}" \
    --region us-west-2
  ```