{"id":1104,"hash":"3860649ca5574689887554488dc6d8d47ea6948ab705990f8de314acecc951ae","pattern":"InvalidInstanceId: An error occurred (InvalidInstanceId) when calling the SendCommand operation","full_message":"The below is the code which i am running from python to execute commands in aws ec2 instance\n\nimport boto3\nec2 = boto3.client('ssm',region_name='us-east-1',aws_access_key_id='xxxxxxxxxxxxxxx',aws_secret_access_key='xxxxxxxxx')\na = ec2.send_command(InstanceIds=ids, DocumentName='AWS-RunShellScript', Comment='abcdabcd', Parameters={\"commands\":[\"ifconfig\"]})\n\nBut it is giving the below error\n\nInvalidInstanceId: An error occurred (InvalidInstanceId) when calling the SendCommand operation:","ecosystem":"pypi","package_name":"amazon-web-services","package_version":null,"solution":"The following scenarios can result in this error message:\n\nInstance id is invalid (in the comments you have verified it isn't)\nInstance is in a different region (in the comments you have verified it isn't)\nInstance is not currently in the Running state\nInstance does not have the AWS SSM agent installed and running.\ninstance does not have the correct iam permissions to register with ssm\n\nYou 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.\n\nYou should use one of the following two policies to make sure your aws ec2 instance can register itself with ssm:\n\nAmazonSSMManagedInstanceCore\nAmazonSSMFullAccess","confidence":0.95,"source":"stackoverflow","source_url":"https://stackoverflow.com/questions/47034797/invalidinstanceid-an-error-occurred-invalidinstanceid-when-calling-the-sendco","votes":33,"created_at":"2026-04-19T04:52:20.956927+00:00","updated_at":"2026-04-19T04:52:20.956927+00:00"}