To debug your script, you can edit the first lines to be:
#!/bin/bash -ex
exec > >(tee /var/log/user-data.log|logger -t user-data -s 2>/dev/console) 2>&1
After the instance is run, check the log file at /var/log/user-data.log
to see what errors, if any has occurred.