Search code examples
amazon-ec2amazon-web-servicesec2-amiautoscaling

automatically start apache on instance launch - aws autoscaling


I have an ec2 instance serving a webpage with apache. I created an autoscaling group using an AMI of this instance in the launch config. Once CPU went over 80% and the autoscale policy ran, a new instance was created. But the CPU of my original instance continued to rise and the CPU of my new instance remained at 0%.

The new instance was not serving the web page. I am guessing this is because apache was not started with the launch of the image. I tried to ssh into the new instance to run "service httpd start" but I got the following error:

ssh: Could not resolve hostname http://ec2-xxx-xx-xxx-xxx.compute-1.amazonaws.com:
nodename nor servname provided, or not known

Why could I not ssh in? How do I configure autoscaling to automatically start apache on launch?


Solution

  • It would appear that you are attempting to ssh to a host with http:// in the hostname. Remove that and ssh should work.

    Assuming that you created an AMI to use in AutoScaling, you would need to ensure that you chkconfig httpd on in the source instance before creating a new AMI for AutoScaling.