Once you have created and validated your template, the packer build command does the following for you:
- Creates a one-time key pair for SSH access to the instance
- Creates a dedicated security group to control access to the instance
- Launches an instance
- Waits until SSH is ready to receive connections
- Runs the provisioner steps on the instance
- Stops the instance
- Generates an AMI from the stopped instance
- Terminates the instance
Check the Packer documentation for more provisioners and functionality at https://www.packer.io/docs/.