2

I'm pretty new to AWS and EC2 but I want to run instances with a user script after it's booted from another instance. I have installed ec2 tools and ran the command as it's explained in various examples like here http://www.turnkeylinux.org/blog/ec2-userdata and Eric Hammond's tutorials. however when I actually use the command: "ec2-run-instances --key my-key --user-data-file myscript my-ami" it only runs the new instance but doesn't execute the script myscript contains: #!/bin/bash echo "hello" > ~/output.txt

I'm running ubuntu server 12.04 AMIs. the target AMIs are duplicates of the initiating instance.

if I run curl http:// 169.254.169.254/latest/user-data the imported script is there.

4
  • Make sure your sample script is two lines. It won't execute as you have described it in a single line. Commented Oct 1, 2012 at 15:06
  • Make sure you are looking for the output in /root as the user data script is run as root. Commented Oct 1, 2012 at 15:07
  • Make sure you can execute the sample user data script on an official Ubuntu AMI before you try the same command on your own AMI. Commented Oct 1, 2012 at 15:08
  • The script actually DID run and the output was in /root. Thanks Mr. H. Commented Oct 2, 2012 at 9:41

1 Answer 1

0

[copying answer from comments to answer entry]

Make sure you are looking for the output in /root as the user data script is run as the root user on first boot.

Other things to consider for others having similar issues:

  • Make sure your sample script is two lines. It won't execute as you have described it in a single line.

  • Make sure you can execute the sample user data script on an official Ubuntu AMI before you try the same command on your own AMI

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.