Question

I am trying to spawn an instance with user_data text. I see that the script is there in place, but foes not seem to get executed. I did have a look at other threads here and have already ticked the following items on the checklist:

  1. Verified that the user-data shows up when I wget http://169.254.169.254/latest/user-data
  2. The AMI that I am using is Amazon Linux and not Ubuntu (ami : ami-ccf297fc)
  3. I see that the shell script in user data executes well, when done manually. when I do a

    sh user-data
    

    after the wget, it executes smoothly without any issues

  4. I verified that the user-data script starts with #!/bin/bash
  5. I tired with and without base64 encoding the user-data

Let me know if any other details are required.

Also, is it okay to do a sudo poweroff on the init script itself? Could that be a problem? I just need the machine to process some data, put the processed version in s3 and get turned off. Is there a better way to do it?

Was it helpful?

Solution

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.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top