InvalidInstanceId:调用 SendCommand 操作时发生错误(InvalidInstanceId) [英] InvalidInstanceId: An error occurred (InvalidInstanceId) when calling the SendCommand operation

查看:34
本文介绍了InvalidInstanceId:调用 SendCommand 操作时发生错误(InvalidInstanceId)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

The below is the code which i am running from python to execute commands in aws ec2 instance

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: 

推荐答案

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

The following scenarios can result in this error message:

  • 实例 ID 无效(在您已确认无效的评论中)
  • 实例位于不同的区域(在您已确认不在的评论中)
  • 实例当前未处于运行状态
  • 实例没有 AWS SSM 代理 已安装并正在运行.
  • Instance id is invalid (in the comments you have verified it isn't)
  • Instance is in a different region (in the comments you have verified it isn't)
  • Instance is not currently in the Running state
  • Instance does not have the AWS SSM agent installed and running.

您需要登录 AWS EC2/SSM 控制台并确保您尝试管理的实例显示在 SYSTEMS MANAGER 共享资源 - 托管实例> 列表,并且它们显示在线Ping状态.如果没有,您需要在尝试向相关实例发送命令之前修复该问题.

You need to login to the AWS EC2/SSM console and make sure the instance(s) you are trying manage show up in the SYSTEMS MANAGER SHARED RESOURCES - Managed Instances list, and that they show a Ping status of Online. If not, you need to fix that before trying to send commands to the instance(s) in question.

这篇关于InvalidInstanceId:调用 SendCommand 操作时发生错误(InvalidInstanceId)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆