As per my experience with Userdata and AMIs, Userdata will be executed by ec2-user, and i am assuming to run/install software, Ec2-user mush have sudo permissions.
If you your AMI is created from AWS AMIs, Ec2-user has full permissions including sudo. so User data will be executed
If your AMI is a snapshot of the machine ( lift and Shifted from On-Prem), Ec2-user will not be available, So make sure Ec2-user is setup with sudo permissions.
Hope this resolve the issue.
Also Please let me know if any of you were able to resolve the issue, if yes, could you please suggest me how this issue was resolved.
-Shiva