Reputation: 139
I'm trying to make a Launch Configuration for my AWS Cloud Environment.
I wan't to install httpd and start it up on the fly, when the autoscaling group spins up a new EC2 instance.
I can SSH into the instance manually and install httpd with: sudo yum update -y sudo yum install httpd -y sudo service httpd start
But I can't make it happen, with the Launch Configuration under Advance Details -> User Data sudo yum update -y sudo yum install httpd -y sudo service httpd start
Any ideas why it's not the same?
Update
After adding #!/bin/bash
as @Mark-B suggested, then service is kindda installed. It gives the following error when restarting the service. Maybe it could be a hint for you, to figure out what is wrong?
Upvotes: 0
Views: 826
Reputation: 200562
User-data can be used for more than running startup scripts. To indicate to the cloud-init process that the user-data is a script, you need to add this as the first line of your user-data:
#!/bin/bash
Upvotes: 2