The image is the disk an instance boots from: an operating system plus whatever was baked in. Images are called AMIs, Amazon Machine Images, and have ids like ami-0c7217cdde317cfec.
Two facts make ids awkward:
- The same image has a different id in every region.
- AWS publishes a new build every few weeks, with a new id.
So nobody writes them down. AWS publishes the current id of each of its images under a fixed name in Parameter Store, a small key-value store inside Systems Manager (ssm).
Amazon Linux 2023 is the operating system this course uses.
Reading it into a variable
AMI=$(aws ssm get-parameter --name /aws/service/ami-amazon-linux-latest/al2023-ami-kernel-default-x86_64 --query Parameter.Value --output text)get-parameter reads one parameter by name. The query keeps only its value, text prints it bare, and AMI=$(…) keeps it in a shell variable. Without AMI=$( and ) around it, the same command prints the id instead.
echo $AMIami-0c7217cdde317cfecThe variable lasts until the shell ends, and the next lesson's launch command uses it. In another region, add --region to the same command and you get that region's id for the same image.