Skip to main content

Posts

Showing posts with the label instanceType

List AWS EC2 instance details with Name tag value

In this blog, we will look at how to execute Python script to get the AWS EC2 details like Name tag valie of the instance, Instance ID, Platform, Instance Type, State and its private IPv4 address. You will require Python 3.8 or above to run the the script successfully. Setting up Boto3 Session and client import boto3 # setup profile and region profile = "default" region = "us-east-1" session = boto3 . Session ( profile_name = profile , region_name = region ) ec2_client = session . client ( 'ec2' ) response = ec2_client .describe_instances() ec2_list = response [ 'Reservations' ] # Gather information about EC2 ec2_name = session . resource ( 'ec2' ) instances = ec2_name .instances.all() # This will help to retrieve Tags information Now, let's print the header row. # print header print ( 'Name, Instance ID, Platform, Instance Type, State, Private IPv4' ) Following code will run and collect the information about EC2.   for