0

Right now I have a setup with a load balancer that starts new instances of a server (debian) if needed be on the Amazon EC2 cloud. On this setup I have a script that needs to be running on only one of these servers.

Having multiple snapshots could very easily end up being a pain when it comes to updating the system, so my question is how would I go about making a startup script that only runs on the first of the servers?

Is it possible to pull information from Amazon from the command line that could be used to determine this?

1 Answer 1

1

Use the user-data then check the user-data as part of your start-up. Either run or don't run your script based on the contents of the user-data.

The user data can be set as part of the launch wizard in the AWS Management Console, or from the command line tools.

You can read the user-data from http://169.254.169.254/latest/user-data.

Full details about EC2 instance metadata can be found at http://docs.aws.amazon.com/AWSEC2/latest/UserGuide/AESDG-chapter-instancedata.html

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .