Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

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?

share|improve this question

1 Answer 1

up vote 1 down vote accepted

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

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.