如何获取 AWS config 聚合资源

How to get AWS config aggregate resources

我无法使用 Python3 和 boto3 获取 AWS Config 聚合发现的资源。

Python=3.7 Boto3=1.9.42 使用 AWS SAM 在本地测试 Lambda 函数,但是当我 运行 AWS 中的 Lambda 时,我遇到了同样的问题。

    client = master_session.client('config', region_name=my_region)

    response = client.list_aggregate_discovered_resources(
        ConfigurationAggregatorName=aggregator,
        ResourceType="AWS::EC2::Instance")

Returns 错误:

{
  "errorType": "AttributeError",
  "errorMessage": "'ConfigService' object has no attribute 'list_aggregate_discovered_resources'",
  "stackTrace": [
    "  File \"/var/task/app.py\", line 41, in lambda_handler\n    r = client.list_aggregate_discovered_resources(\n",
    "  File \"/var/runtime/botocore/client.py\", line 563, in __getattr__\n    self.__class__.__name__, item)\n"
  ]
}

不过,我可以使用此客户端 运行 其他请求。

这个有效:

response = client.describe_configuration_aggregators()
print("Response: {}".format(response))

您可以从下面的参考中看到 boto3 1.9.42 不支持属性 list_aggregated_discovered_resources

ConfigService - Boto3 1.9.42

如果要使用该属性,则需要最新版本的 boto3。