From the course: Python: Pen Testing AWS

Unlock the full course today

Join today to access over 22,600 courses taught by industry experts or purchase this course individually.

Listing all EC2 instances

Listing all EC2 instances - Python Tutorial

From the course: Python: Pen Testing AWS

Start my 1-month free trial

Listing all EC2 instances

- [Instructor] It's useful to be able to get a quick reference list of all our EC2 instances. We can get a summary through AWS's config service, but let's see what we can do with the EC2 service in Python. To support this scripting, I've deployed the CloudGoat Code Build Secret Scenario and saved the credentials as scenario3. The method we'll be focusing on is the describe-instances. And we can see the format of this if we call it using the Command Line Interface. We'll use our scenario3 profile to do this. AWS EC2 describe-instances, and we'll put the profile as scenario3, and I'll set the region as us-east-1. Okay, so here we get the details of our reservations and instances in that region. In this case, we have the keyname, cg-ec2-key-pair and it's a t2.micro. I won't examine this output in detail, but if you're not familiar with EC2 JSON structures, you might want to pause here and spend a bit of time looking at it.…

Contents