-1

Is there any way to run user defined script in already launched EC2 Instance? I have already tried by first calling modifyInstanceAttribute() to modify the user data and then starting the instance,but it is not working.

Please suggest.

1 Answers1

1

By default, user data is run only once during instance initialization. If you want to run it all the time, during instance reboot, you should change cloudinit configuration.

Check this question: How do I make cloud-init startup scripts run every time my EC2 instance boots?

Community
  • 1
  • 1
Mihai
  • 2,125
  • 2
  • 14
  • 16
  • Actually I have not worked on cloud-init.I am giving the script file content in user data section while launching the instance. Can you please help me regarding how to use cloud-init for running scripts. – user3107169 Dec 16 '13 at 12:46
  • User data is run by cloud-init. Basically AWS is sending user-data to cloud-init (if we are talking about Linux machines) or 'I forgot it's name', for Windows. For more info on this you can check AWS docs: http://docs.aws.amazon.com/AWSEC2/latest/UserGuide/AESDG-chapter-instancedata.html#instancedata-user-data-retrieval and cloud-init docs: https://help.ubuntu.com/community/CloudInit. – Mihai Dec 16 '13 at 13:00