When the Amazon EC2 instance is launched, there is an option of passing user data for the instance that performs automated configuration tasks and also it runs the scripts after the instance starts. There are 2 types of user data in Amazon EC2 ie., cloud-init directives and shell scripts.
Also, learn more about AWS, and become a master by enrolling in Intellipaat's AWS Certification Course!
For more information, check out this AWS Tutorial.