

# 在 AWS Config 中记录资源类型
<a name="registry-config-record"></a>

您可以指定 AWS Config 自动跟踪您的私有资源类型，并将对这些资源的更改作为*配置项*记录。这使您能够查看这些私有资源类型的配置历史记录，此外还可以编写 AWS Config 规则 规则以验证配置最佳实践。挂钩扩展需要 AWS Config。

要让 AWS Config 自动跟踪您的私有资源类型，请执行以下操作：
+ 通过 CloudFormation 管理资源。这包括通过 CloudFormation 执行所有资源创建、更新和删除操作。
**注意**  
如果您使用 IAM 角色执行堆栈操作，则该 IAM 角色必须有权调用以下 AWS Config 操作：  
[PutResourceConfig](https://docs.aws.amazon.com/config/latest/APIReference/API_PutResourceConfig.html)
[DeleteResourceConfig](https://docs.aws.amazon.com/config/latest/APIReference/API_DeleteResourceConfig.html)
+ 配置 AWS Config 以记录所有资源类型。有关更多信息，请参阅《AWS Config Developer Guide》**中的 [Recording Configurations for Third-Party Resources using the AWS CLI](https://docs.aws.amazon.com/config/latest/developerguide/customresources.html)。
**注意**  
如果私有资源包含同时定义为必需*且*只写的属性，AWS Config 不支持记录这些私有资源。  
根据设计，定义为只写的资源属性不会在用于创建 AWS Config 配置项的架构中返回。因此，包含定义为只写和必需的属性将导致配置项创建失败，因为必需的属性不存在。要查看用于创建配置项的架构，您可以查看 [https://docs.aws.amazon.com/AWSCloudFormation/latest/APIReference/API_DescribeType.html](https://docs.aws.amazon.com/AWSCloudFormation/latest/APIReference/API_DescribeType.html) 操作的 `schema` 属性。

有关配置项的更多信息，请参阅《AWS Config 开发人员指南》中的[配置项](https://docs.aws.amazon.com/config/latest/developerguide/config-concepts.html#config-items)。

## 防止在配置项目中记录敏感属性
<a name="registry-config-record-sensitive"></a>

您的资源类型可能包含您视为敏感信息（如密码、密钥或其他敏感数据）的属性，您不希望在配置项目中记录这些属性。要防止在配置项目中记录属性，您可以将该属性包括在资源类型架构的 `writeOnlyproperties` 列表中。作为 `writeOnlyproperties` 列出的资源属性可由用户指定，但不会由 `read` 或 `list` 请求返回。

有关更多信息，请参阅《CloudFormation CLI User Guide》**中的 [https://docs.aws.amazon.com/cloudformation-cli/latest/userguide/resource-type-schema.html#schema-properties-writeonlyproperties](https://docs.aws.amazon.com/cloudformation-cli/latest/userguide/resource-type-schema.html#schema-properties-writeonlyproperties)。