- Prerequisites
- Exploring EC2 commands
- Finding a suitable AMI
- Launching an instance
- 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
| Step | Description | Sample Command |
|---|---|---|
| 1. Explore EC2 commands | View available EC2 operations and options | aws ec2 help |
| 2. Find an AMI | List AMIs you own or public AMIs by Amazon | aws ec2 describe-images --owners self amazon |
| 3. Launch an instance | Start a new instance with AMI ID and type | aws ec2 run-instances … |
| 4. Inspect instance details | Retrieve instance metadata and status | aws ec2 describe-instances |
1. Exploring EC2 Commands
To discover all EC2 subcommands, options, and examples: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:| Field | Description |
|---|---|
| ImageId | AMI identifier (used by run-instances) |
| Name | Human-readable name of the AMI |
| Architecture | CPU architecture (e.g., x86_64, arm64) |
| PlatformDetails | OS platform (Linux/UNIX, Windows) |
| BlockDeviceMappings | Root volume size and type |
3. Launching an EC2 Instance
With your chosen AMI ID, launch at2.micro instance:
Running EC2 instances incurs AWS charges. Always terminate resources you no longer need:
4. Inspecting Instance Details
To view the full set of metadata, including networking and state:| Field | Description |
|---|---|
| InstanceId | Unique identifier of the instance |
| PrivateIpAddress | Internal IP within the VPC |
| PublicDnsName | Public DNS assigned (if any) |
| State.Name | Current state (pending, running) |
| LaunchTime | Timestamp of instance launch |