It is possible to bootstrap an EC2 instance by running a shell script on launch. The shell script that you want to run when a new EC2 instance is created should be placed in the userdata section. Userdata section can be found in the advanced options while configuring the new EC2 instance. The userdata that is provided on EC2 creation console is copied to the below mentioned folder
/var/lib/cloud/instance/scripts
Also, the log file for the userdata execution can be found here :
/var/log/cloud-init.log
Please note that the you might have to wait for a while for the userdata to completely finish executing. The wait time depends on the userdata that you provide. After logging in to the EC2 instance, you can verify the status of the userdata execution by tailing the log file mentioned above using the below command.
tail -f /var/log/cloud-init.log