aws ec2 describe-instancesFoundational EC2 inventory command.
AWS CLI EC2 commands for instances, AMIs, key pairs, VPC networking, security groups, EBS volumes, and snapshots.
Launch, inspect, and manage EC2 instances.
aws ec2 describe-instancesFoundational EC2 inventory command.
aws ec2 describe-instances --query 'Reservations[].Instances[].{Id:InstanceId,State:State.Name,Type:InstanceType,Name:Tags[?Key==`Name`]|[0].Value,PrivateIp:PrivateIpAddress}' --output tableJMESPath makes large instance inventories easier to read.
aws ec2 run-instances --image-id ami-0123456789abcdef0 --instance-type t3.micro --subnet-id subnet-0123456789abcdef0 --security-group-ids sg-0123456789abcdef0 --count 1Specify AMI, instance type, network placement, and security groups.
aws ec2 start-instances --instance-ids i-0123456789abcdef0Transitions the instance back to running.
aws ec2 stop-instances --instance-ids i-0123456789abcdef0Useful for cost savings in non-production environments.
aws ec2 reboot-instances --instance-ids i-0123456789abcdef0Reboots the instance without changing the root volume contents.
aws ec2 terminate-instances --instance-ids i-0123456789abcdef0This is destructive and cannot be undone.
aws ec2 wait instance-running --instance-ids i-0123456789abcdef0Useful after launch scripts.
Image and SSH key workflows.
aws ec2 describe-images --owners self amazonUseful when selecting machine images for launches.
aws ec2 create-image --instance-id i-0123456789abcdef0 --name web-ami-2026-03-05Useful for golden-image or backup workflows.
aws ec2 describe-key-pairsUseful when verifying SSH key names before launch.
aws ec2 create-key-pair --key-name my-key --query 'KeyMaterial' --output text > my-key.pemProtect the generated private key file and set strict permissions.
aws ec2 delete-key-pair --key-name my-keyDoes not delete any local private key file you may have saved separately.
Core EC2 networking inventory and updates.
aws ec2 describe-vpcsFoundational networking inventory command.
aws ec2 describe-subnetsUseful for selecting subnet placement during launches.
aws ec2 describe-security-groupsUse queries to narrow to specific ports or group IDs.
aws ec2 authorize-security-group-ingress --group-id sg-0123456789abcdef0 --protocol tcp --port 443 --cidr 0.0.0.0/0Adds a new inbound rule to the specified group.
aws ec2 revoke-security-group-ingress --group-id sg-0123456789abcdef0 --protocol tcp --port 443 --cidr 0.0.0.0/0Removes a matching rule from the group.
aws ec2 create-tags --resources i-0123456789abcdef0 vol-0123456789abcdef0 --tags Key=Env,Value=prod Key=App,Value=apiUse consistent tag sets for cost, ownership, and automation.
Manage block storage resources.
aws ec2 describe-volumesUseful for capacity and orphaned volume checks.
aws ec2 create-volume --availability-zone us-west-2a --size 50 --volume-type gp3Block storage volumes are AZ-scoped.
aws ec2 attach-volume --volume-id vol-0123456789abcdef0 --instance-id i-0123456789abcdef0 --device /dev/xvdfThe operating system still needs filesystem and mount configuration if appropriate.
aws ec2 create-snapshot --volume-id vol-0123456789abcdef0 --description 'nightly backup'Snapshots can be used for backup, restore, and AMI workflows.
aws ec2 describe-snapshots --owner-ids selfUseful for backup inventory and cleanup tasks.
aws ec2 delete-snapshot --snapshot-id snap-0123456789abcdef0Be careful to preserve restore points required by retention policy.