我想检查所有带有特定标签的服务器的ssm连接状态。我正在使用boto3模块获取连接状态,如下所示。
# import statements not mentioned
filter= [{'Name':'tag:Name', 'Values': ['Linux']}]
def script(event, context):
for each_ins in ec2_client.describe_instances(Filters=filter)['Reservations']:
for inst_id in each_ins['Instances']:
try:
response = ssm_client.get_connection_status(Target=[inst_id['InstanceId']])
pprint(inst_id['InstanceId'] + 'response')
except Exception as e:
print(e)
然而,get_connection_status函数只接受字符串,不接受列表。因此,我得到以下错误。我怎样才能摆脱这个?
{“ExecutionLog”:“参数验证失败:
参数目标的类型无效,值:['i-123xxxxxxxxx',类型:<类“列表”>,有效类型:<“str”类>
"}