Hi David. In this tutorial, I deploy the app on an EC2 instance. Before the deployment of the app, I have to create the EC2 instance. AWS has many types of instances with different processing capacities, memory, etc, hence I have to tell AWS what type of instance I want to create. The way to do it is to specify an image id (ami-0d5eff06f840b45e9), because every type has its own id.
When the CloudFormation receives the template it will create the EC2 instance of the type I've specified (ami-0d5eff06f840b45e9).
Every EC2 instance has a configuration section called UserData, mostly used to run some bash script on the instance start-up.
In this section, I've placed a script that installs a docker, docker-compose, and creates a docker-compose file on the newly created EC2 instance. In the docker-compose file, I've specified the image for my app (URI), the one that I've pushed to the ECR. At the end of the script, there is the command that spins the containers using the created docker-compose file.
So to summarize we have one virtual machine image (ami-... on line 22 of a template) to create the EC2 instance, AWS provides these images. And another image (line 53 of a template) is a Docker image used to create the container for the app.