gpt4 book ai didi

python - 无效的实例 ID : An error occurred (InvalidInstanceId) when calling the SendCommand operation

转载 作者:太空狗 更新时间:2023-10-29 20:13:24 25 4
gpt4 key购买 nike

以下是我从 python 运行以在 aws ec2 实例中执行命令的代码

import boto3
ec2 = boto3.client('ssm',region_name='us-east-1',aws_access_key_id='xxxxxxxxxxxxxxx',aws_secret_access_key='xxxxxxxxx')
a = ec2.send_command(InstanceIds=ids, DocumentName='AWS-RunShellScript', Comment='abcdabcd', Parameters={"commands":["ifconfig"]})

但它给出了以下错误

InvalidInstanceId: An error occurred (InvalidInstanceId) when calling the SendCommand operation: 

最佳答案

以下情况可能会导致此错误消息:

  • 实例 ID 无效(在评论中您已验证它不是)
  • 实例位于不同的区域(在评论中您已验证它不是)
  • 实例当前未处于Running状态
  • 实例没有 AWS SSM agent安装并运行。

您需要登录 AWS EC2/SSM 控制台并确保您尝试管理的实例显示在SYSTEMS MANAGER SHARED RESOURCES - Managed Instances 列表,并且它们显示 Ping 状态 在线。如果不是,您需要在尝试向相关实例发送命令之前解决该问题。

关于python - 无效的实例 ID : An error occurred (InvalidInstanceId) when calling the SendCommand operation,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47034797/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com