How to Get Instance Details By Using Boto3

Share via:

Dear Readers,

In this article, we will see the following How to Get Instance Details By Using Boto3.

Steps to Follow :
  1. Logging to AWS Account
  2. Launch Linux Server
  3. Connect to Linux EC2 Instance by Using Putty
  4. Install Python Package
  5. Install Boto3 Package
  6. Connect to AWS CLI
  7. Script for getting all the instances information
  8. Script for getting Instance ID
  9. Script for getting Instance ID,Instance Type
  10. Script for getting Instance ID,Instance Type and Instance State
  11. Script for getting Instance ID,Instance Type,Instance State and Instance Name
1. Logging to AWS Account

First, we need to AWS Console page by using below link.

https://aws.amazon.com/console/

Click on sign in to Console button.

Logging to aws account

Login using username & password and click on sign in.

Enter to AWS Management Console

We can see the AWS Management Console Dashboard.

Go to Services, under the compute module click EC2 service to open.

2. Launch Linux EC2 Instance

Go to Services, under the compute module click EC2 service to open.

We can launch Windows Server by using below link.

How to Launch Linux EC2 Instance

We can see the windows server has been launched successfully.

3. Connect to Linux EC2 Instance Using Putty

We can connect putty by using below link.

Connect to EC2 Instance Using Putty

Go inside the Linux Server Terminal.

6. Connect to AWS CLI

If we want to connect to AWS CLI,we need access key and secret key for that we generate credentials from IAM.

Generate Access Key ID and Secret Access Key

Go to IAM Dashboard and click on My access key.

Click on Create New Access Key.

We can see the Generated Access Key ID and Secret Access Key.

These keys are necessary to access the CLI.

Go to Linux Server Terminal and specify required credentials, region and output format for accessing to CLI

Make directory pythonscripts

Go inside the directory 

7. Script for getting all the instances information 

Make a file “describe.py” and write python script for getting instances information.

Note: ESC and wq! to quit.

Run Python Script

We can see all the information about instance in Mumbai region.

8. Script for getting Instance ID

Modify file “describe.py” and write script for instance ID.

Run Python Script

We can see the instance ID

9. Script for getting Instance ID,Instance Type

Modify file “describe.py” and write script for getting Instance ID,Instance Type.

Run Python Script

We can see the instance ID & Instance Type

10. Script for getting Instance ID,Instance Type and Instance State

Modify file “describe.py” and write script for getting Instance ID,Instance Type and Instance State.

Run Python Script

We can see the instance ID & Instance Type&Instance state

11. Script for getting Instance ID,Instance Type,Instance State and Instance Name

Modify file “describe.py” and write script for getting Instance ID,Instance Type,Instance State and Instance Name.

Run Python Script

We can see the Instance id,Instance type, Instance State, Instance Name.

 

Thank you for giving your valuable time to read the above information.
Follow us on 
Website  www.ktexperts.com
Facebook Page KTexperts
Linkedin Page : KT EXPERTS

Follow Me
Ramesh’s Linkedin : Ramesh Atchala

 

Share via:
Note: Please test scripts in Non Prod before trying in Production.
1 Star2 Stars3 Stars4 Stars5 Stars (No Ratings Yet)
Loading...

Add Comment