Find Account and Region details for an AWS EC2 Instance

One of my DBA friend was troubleshooting some issue on a SQL database server hosted on AWS EC2 Windows Instance. He was able to take remote desktop connection of EC2 instance. But as part of troubleshooting, he needed to see various details for that EC2 instance on AWS portal.

He was able to login on AWS Portal as well but was not able to see any running EC2 instance as seen in below screenshot.

Later I was also involved into this. After sometime of combined effort ,we were able to get all the required details on AWS portal for that EC2 Instance.

So what were the Learnings?

  1. When we login to AWS Portal ,that login is associated with one Account ID.

This is important to note that one customer might have multiple accounts so we need to login to correct account.

2. Even in each account, resources might have been launched in various regions. So in addition to Account ID , we need to have region of that particular EC2 instance.

If we do not have above details, we might end up putting lot of manual efforts logging through different accounts and selecting various regions to find running EC2 instances in each account.

But you do not need to waste your efforts. Just run below URL into any browser from your EC2 instance.

http://169.254.169.254/latest/dynamic/instance-identity/document

The output will surely make you happy, see below:

So now we got the required details – Account ID & Region for an EC2 instance.

Login to correct Account and select correct region from drop-down. It will show you number of running EC2 instances and other resources.

Click on Running Instances, it will take us to list of all the available instance. Select the desired EC2 instance and we get the detailed EC2 instance summary.

I hope this small post will help AWS and DBA beginners to save their valuable time. Please share your inputs and feedback in comments.

Happy Learning !