If you try to SSH into the EC2 instance through SSM parameter or if you want to setup a RDS tunnel, you might get the following error: An error occurred (InvalidInstanceId) when calling the SendCommand operation: Instances not in a valid state for account
. So, it comes down to some of the scenarios described in the Solution section below.
Prerequisites
- AWS Account
- EC2 Access
Solution
The above error might be related to some of the following scenarios:
- Wrong Instance ID.
- If the Instance is in a different Region. To export your instance region execute:
export AWS_DEFAULT_REGION=us-west-1
- If the Instance is not in a Running State.
- If the Instance doesn’t have
ssm
agent up and running.
Conclusion
In case you have some other suggestions don’t hesitate to raise them below. Feel free to leave a comment below and if you find this tutorial useful, follow our official channel on Telegram.