Python AWS SSM检入ec2实例

Python AWS SSM检入ec2实例,python,amazon-web-services,boto3,Python,Amazon Web Services,Boto3,我想得到一个没有安装SSM的ec2实例列表 我尝试使用bot3.description\u instance\u信息,但出现了一个错误 下面是我的代码 import boto3 client = boto3.client('ssm') response = client.describe_instance_information( InstanceInformationFilterList=[ { 'key': 'i-0187655667

我想得到一个没有安装SSM的ec2实例列表

我尝试使用bot3.description\u instance\u信息,但出现了一个错误

下面是我的代码

import boto3


client = boto3.client('ssm')


response = client.describe_instance_information(
    InstanceInformationFilterList=[
        {
            'key': 'i-0187655667fghj',
            'valueSet': [
                'AgentVersion',
                'InstanceIds'
            ]
        }
    ]
)


print(response)
错误:

Traceback (most recent call last):
  File "ssm.py", line 13, in <module>
    'InstanceIds'
  File "/Library/Python/2.7/site-packages/botocore/client.py", line 357, in _api_call
    return self._make_api_call(operation_name, kwargs)
  File "/Library/Python/2.7/site-packages/botocore/client.py", line 661, in _make_api_call
    raise error_class(parsed_response, operation_name)

botocore.exceptions.ClientError: An error occurred (ValidationException) when calling the DescribeInstanceInformation operation: 1 validation error detected: Value 'i-0187655667fghj' at 'instanceInformationFilterList.1.member.key' failed to satisfy constraint: Member must satisfy enum value set: [ActivationIds, InstanceIds, PingStatus, PlatformTypes, ResourceType, IamRole, AssociationStatus, AgentVersion]
回溯(最近一次呼叫最后一次):
文件“ssm.py”,第13行,在
“实例ID”
文件“/Library/Python/2.7/site packages/botocore/client.py”,第357行,在api调用中
返回self.\u make\u api\u调用(操作名称,kwargs)
文件“/Library/Python/2.7/site packages/botocore/client.py”,第661行,在make\u api\u调用中
引发错误\u类(解析的\u响应、操作\u名称)
botocore.exceptions.ClientError:调用DescribeInstanceInformation操作时发生错误(ValidationException):检测到1个验证错误:“InstanceInformation FilterList.1.member.key”处的值“i-0187655667fghj”未能满足约束:成员必须满足枚举值集:[ActivationID、InstanceID、PingStatus、平台类型、资源类型、IamRole、AssociationStatus、代理版本]

进程结束,退出代码为1

您是否正确阅读了文档?因为它接受了实例ID

{
            'key': 'InstanceIds'|'AgentVersion'|'PingStatus'|'PlatformTypes'|'ActivationIds'|'IamRole'|'ResourceType'|'AssociationStatus',
            'valueSet': [
                'string',
            ]
        }
所以你必须通过身份证

import boto3


client = boto3.client('ssm')


response = client.describe_instance_information(
    InstanceInformationFilterList=[
        {
            'key': 'InstanceIds',
            'valueSet': [
                'i-0187655667fghj'
            ]
        }
    ]
)


print(response)
实例信息过滤器列表

这是旧方法。建议您不要使用此方法。 相反,请使用InstanceInformationFilter操作 InstanceInformationFilter操作使您能够返回实例 使用指定为键值映射的标记获取信息

如果您确实使用此方法,则不能使用 InstanceInformation筛选器操作。使用此方法和 InstanceInformationFilter操作导致异常错误

Type: Array of InstanceInformationFilter objects

Array Members: Minimum number of 0 items.

Required: No