社区所有版块导航
Python
python开源   Django   Python   DjangoApp   pycharm  
DATA
docker   Elasticsearch  
aigc
aigc   chatgpt  
WEB开发
linux   MongoDB   Redis   DATABASE   NGINX   其他Web框架   web工具   zookeeper   tornado   NoSql   Bootstrap   js   peewee   Git   bottle   IE   MQ   Jquery  
机器学习
机器学习算法  
Python88.com
反馈   公告   社区推广  
产品
短视频  
印度
印度  
Py学习  »  Python

如何使用python boto3检查具有特定标记值的所有服务器的ssm连接状态

Binu • 3 年前 • 1648 次点击  

我想检查所有带有特定标签的服务器的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”类> "}

Python社区是高质量的Python/Django开发社区
本文地址:http://www.python88.com/topic/129319
 
1648 次点击  
文章 [ 1 ]  |  最新文章 3 年前