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.
- AWS Account
- EC2 Access
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:
- If the Instance is not in a Running State.
- If the Instance doesn’t have
ssmagent up and running.
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.