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

The following scenarios can result in this error message:

  • 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.

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.


Make sure your instance has SSM setup. For Linux, you need to use Amazon Linux AMI or install manually.

Run:

aws ssm describe-instance-information --output text

to see the SSM agent version from your instances. So make sure your instance is on that list.

See also: SSM send command to EC2 instance Failed.