With an image in $AMI and a size chosen, one command starts a machine.
Launching
aws ec2 run-instances --image-id $AMI --instance-type t3.micro \
--tag-specifications 'ResourceType=instance,Tags=[{Key=Name,Value=web}]'run-instances needs the image and the type. --tag-specifications gives the instance a Name tag at birth, because its id will be random and the name is how you will find it; the single quotes keep the shell away from the brackets. The reply is the instance as it exists at that instant:
"InstanceId": "i-0a1b2c3d4e5f67890",
"State": { "Name": "pending" },
"PrivateIpAddress": "172.31.5.12",
"PublicIpAddress": "54.23.117.9"The call returns at once. Pending means accepted and booting; running follows within a minute.
Where it landed
The command named no network, and the instance still got two addresses. Every region comes with a default VPC: a ready-made private network, 172.31.0.0/16, with one subnet per availability zone. Its subnets hand every new instance a private IP from that range, used inside the network, and a public IP such as 54.23.117.9, used from the internet. That default network is where this chapter's instances live; Chapter 4 builds a proper one with private parts.
The public address is borrowed from a pool, and lesson 7 explains when it changes.
Watching it
aws ec2 describe-instances --filters Name=tag:Name,Values=web \
--query "Reservations[].Instances[].[InstanceId,State.Name,PublicIpAddress]" --output table--filters narrows describe-instances on the server; tag:Name is the filter for a Name tag, and instance-state-name is another common one. Instances sit inside reservations, so the query path starts with Reservations[].Instances[].
Tags afterwards
aws ec2 create-tags --resources i-0a1b2c3d4e5f67890 --tags Key=Env,Value=lab Key=Owner,Value=danaTags are free and searchable, and Chapter 10 splits the bill by them. Name, Env and Owner on everything is a habit worth starting with the first instance.