While creating new AWS EC2 instance using EC2 command line API, i am passing some user data to new instance.
Now how i came to know whether that user data executed or no
Have your user data create a file in your ec2's /tmp directory to see if it works:
bob.txt:
#!/bin/sh echo 'Woot!' > /home/ec2-user/user-script-output.txt
Then launch with:
ec2-run-instances -f bob.txt -t t1.micro -g ServerPolicy ami-05cf5c6d -v