Skip to main content
In this guide, you’ll learn how to launch and inspect EC2 instances using the AWS Command Line Interface (CLI). We’ll cover:
  1. Prerequisites
  2. Exploring EC2 commands
  3. Finding a suitable AMI
  4. Launching an instance
  5. Inspecting instance details
Make sure you have the AWS CLI installed and configured with valid credentials. Set your default region with aws configure or by exporting the AWS_DEFAULT_REGION environment variable.

Table of Contents

1. Exploring EC2 Commands

To discover all EC2 subcommands, options, and examples:
For details on a specific operation—such as launching instances:
These built-in help pages include required parameters, optional flags, and sample usage.

2. Finding a Suitable AMI

An Amazon Machine Image (AMI) is required to launch an EC2 instance. To list AMIs you own and public AMIs provided by Amazon:
Example JSON output:
Key fields:

3. Launching an EC2 Instance

With your chosen AMI ID, launch a t2.micro instance:
Running EC2 instances incurs AWS charges. Always terminate resources you no longer need:
Example JSON response:

4. Inspecting Instance Details

To view the full set of metadata, including networking and state:
Partial JSON output:
Important fields to track:

Watch Video

Practice Lab