为 Amazon Config 创建聚合器 - Amazon Config
Amazon Web Services 文档中描述的 Amazon Web Services 服务或功能可能因区域而异。要查看适用于中国区域的差异,请参阅 中国的 Amazon Web Services 服务入门 (PDF)

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

为 Amazon Config 创建聚合器

您可以使用 Amazon Config 控制台或 Amazon CLI 创建聚合器。您可以从 Amazon Config 中选择添加单个账户 ID添加我的组织来聚合数据。对于,Amazon CLI有两种不同的程序。

Creating Aggregators (Console)

聚合器页面上,通过指定要从中聚合数据的源账户 ID 或组织和区域来创建聚合器。

  1. 登录到,Amazon Web Services 管理控制台然后通过以下网址打开 Amazon Config 控制台:https://console.aws.amazon.com/config/home

  2. 导航到聚合器页面,然后选择创建聚合器

  3. 允许数据复制,授予 Amazon Config 权限,使其可将数据从源账户复制到聚合器账户中。

    选择允许 Amazon Config 将数据从源账户复制到聚合器账户。您须选中此复选框,才能继续添加聚合器

  4. 对于聚合器名称,键入聚合器的名称。

    聚合器名称必须是唯一的名称,最多有 64 个字母数字字符。此名称可以包含连字符和下划线。

  5. 对于选择源账户,选择添加单个账户 ID添加我的组织来聚合数据。

    注意

    使用添加单个账户 ID 来选择源账户时,需要获得授权。

    • 如果您选择 Add individual account IDs,则可以为聚合器账户添加个人账户 ID。

      1. 选择 Add source accounts 以添加账户 ID。

      2. 选择添加 Amazon Web Services 账户 ID 以手动添加逗号分隔的 Amazon Web Services 账户 ID。如果您想要从当前账户中聚合数据,请键入账户的账户 ID。

        选择上传文件以上传逗号分隔的 Amazon Web Services 账户 ID 文件(.txt or .csv)。

      3. 选择 Add source accounts 以确认您的选择。

    • 如果您选择 Add my organization,则可以将您组织中的所有账户添加到聚合器账户。

      注意

      您必须登录到管理账户或注册的委派管理员,并且所有功能都必须在组织中处于启用状态。如果调用者是管理账户,Amazon Config 会调用 EnableAwsServiceAccess API 以启用 Amazon Config 和 Amazon Organizations 之间的集成。如果调用者是注册的委派管理员,Amazon Config 会调用 ListDelegatedAdministrators API 来验证调用者是否是有效的委派管理员。

      在委派管理员创建聚合器之前,请确保管理账户为委派管理员注册了 Amazon Config 服务主体名称(config.amazonaws.com)。要注册委派管理员,请参阅 注册 Amazon Config 的委托管理员

      您必须分配 IAM 角色以允许 Amazon Config 为您的组织调用只读 API。

      1. 选择从您的账户选择一个角色,以选择现有 IAM 角色。

        注意

        在 IAM 控制台中,将 AWSConfigRoleForOrganizations 托管策略附加到您的 IAM 角色。附加此策略将允许 Amazon Config 调用 Amazon Organizations、DescribeOrganizationListAWSServiceAccessForOrganizationListAccounts API。默认情况下,config.amazonaws.com 会被自动指定为可信实体。

      2. 或者,选择创建角色,然后键入 IAM 角色名称以创建 IAM 角色。

  6. 对于 Regions,选择您要为其聚合数据的区域。

    • 选择一个区域或多个区域或所有。Amazon Web Services 区域

    • 选择包括未来的,Amazon Web Services 区域以从启用了多账户多区域数据聚合的所有未来 Amazon Web Services 区域中聚合数据。

  7. 选择 Save(保存)。Amazon Config 将显示聚合器。

Creating Aggregators using Individual Accounts (Amazon CLI)
  1. 打开命令提示符或终端窗口。

  2. 输入以下命令以创建一个名为 MyAggregator 的聚合器。

    aws configservice put-configuration-aggregator --configuration-aggregator-name MyAggregator --account-aggregation-sources "[{\"AccountIds\": [\"AccountID1\",\"AccountID2\",\"AccountID3\"],\"AllAwsRegions\": true}]"

    对于,account-aggregation-sources输入以下内容之一。

    • 以逗号分隔的您要为其聚合数据的 Amazon Web Services 账户 ID 的列表。用方括号将账户 ID 括起来,并确保对引号进行转义(例如,"[{\"AccountIds\": [\"AccountID1\",\"AccountID2\",\"AccountID3\"],\"AllAwsRegions\": true}]")。

    • 您还可以上传以逗号分隔的 Amazon Web Services 账户 ID 的 JSON 文件。上传文件使用以下语法:--account-aggregation-sources MyFilePath/MyFile.json

      JSON 文件必须为以下格式:

    [ { "AccountIds": [ "AccountID1", "AccountID2", "AccountID3" ], "AllAwsRegions": true } ]
  3. 按 Enter 执行命令。

    您应该可以看到类似于如下所示的输出内容:

    { "ConfigurationAggregator": { "ConfigurationAggregatorArn": "arn:aws:config:Region:AccountID:config-aggregator/config-aggregator-floqpus3", "CreationTime": 1517942461.442, "ConfigurationAggregatorName": "MyAggregator", "AccountAggregationSources": [ { "AllAwsRegions": true, "AccountIds": [ "AccountID1", "AccountID2", "AccountID3" ] } ], "LastUpdatedTime": 1517942461.442 } }
Creating Aggregators using Amazon Organizations (Amazon CLI)

在开始本过程之前,您必须先登录到管理账户或注册的委派管理员,并且所有功能都必须在组织中处于启用状态。

注意

在委派管理员创建聚合器之前,请确保管理账户使用以下两个 Amazon Config 服务主体名称(config.amazonaws.comconfig-multiaccountsetup.amazonaws.com)注册了委派管理员。要注册委派管理员,请参阅 注册 Amazon Config 的委托管理员

  1. 打开命令提示符或终端窗口。

  2. 如果尚未为 Amazon Config 聚合器创建 IAM 角色,请输入以下命令:

    aws iam create-role --role-name OrgConfigRole --assume-role-policy-document "{\"Version\":\"2012-10-17\", \"Statement\":[{\"Sid\":\"\",\"Effect\":\"Allow\",\"Principal\":{\"Service\":\"config.amazonaws.com\"},\"Action\":\"sts:AssumeRole\"}]}" --description "Role for organizational AWS Config aggregator"
    注意

    从此 IAM 角色复制 Amazon 资源名称(ARN),以便在您创建 Amazon Config 聚合器时使用。您可以在响应对象上找到 ARN。

  3. 如果尚未为您的 IAM 角色附加策略,请附加 AWSConfigRoleForOrganizations 托管策略或输入以下命令:

    aws iam create-policy --policy-name OrgConfigPolicy --policy-document '{"Version":"2012-10-17", "Statement":[{"Effect":"Allow","Action":["organizations:ListAccounts","organizations:DescribeOrganization","organizations:ListAWSServiceAccessForOrganization","organizations:ListDelegatedAdministrators"],"Resource":"*"}]}'
  4. 输入以下命令以创建一个名为 MyAggregator 的聚合器。

    aws configservice put-configuration-aggregator --configuration-aggregator-name MyAggregator --organization-aggregation-source "{\"RoleArn\": \"Complete-Arn\",\"AllAwsRegions\": true}"
  5. 按 Enter 执行命令。

    您应该可以看到类似于如下所示的输出内容:

    { "ConfigurationAggregator": { "ConfigurationAggregatorArn": "arn:aws:config:Region:AccountID:config-aggregator/config-aggregator-floqpus3", "CreationTime": 1517942461.442, "ConfigurationAggregatorName": "MyAggregator", "OrganizationAggregationSource": { "AllAwsRegions": true, "RoleArn": "arn:aws:iam::account-of-role-to-assume:role/name-of-role" }, "LastUpdatedTime": 1517942461.442 } }