Search code examples
bashamazon-web-servicesamazon-ec2startup

Aws Ec2 run script program at startup


There is a method to setup an EC2 machine to execute Kafka starting script on startup? I use also java Aws SDK, so I accept both solution for a program java that run command on EC2 instance and solutions for a bash script mode that run kafka script at startup.


Solution

  • A script can be passed in the User Data property.

    If you are using the Amazon Linux AMI, and the first line of the script begins with #!, then the script will be executed the first time that the instance is started.

    For details, see: Running Commands on Your Linux Instance at Launch