1

I am setting up new EC2 instances, and I want to be able to see hello world, the AZ and the IP address displayed. It only shows the apache start page.

I have preloaded the code listed below in the user startup section of EC2, in the advanced details, user data, and have "added as text" clicked and selected.

I copied this text off of a training video from udemy, Ultimate AWS Certified Solutions Architect Associate 2019 by Stephane Maarek, Lesson 60, rt53 EC2 setup at approx the 1:11 mark.

#!/bin/bash
  yum update -y
  yum install -y httpd
  systemctl start httpd.service
  systemctl enable httpd.service
  EC2_AVAIL_ZONE=$(curl -s http://169.254.169.254/latest/meta-data/placement/availability-zone)
  echo "<h1>Hello World From Rokkitt at $(hostname -f) in AZ $EC2_AVAIL_ZONE </h1> > /var/www/html/index.html

I am just getting the apache start page, not the hello world and user meta data info. thank you, I am just starting so I apologize for any mistakes

jww
  • 97,681
  • 90
  • 411
  • 885
1082E1984
  • 67
  • 1
  • 4
  • The first step would be to SSH into the server and verify that `/var/www/html/index.html` was created. If it wasn't then your script didn't run or had an error, and you might want to check for error logs. – Mark B Jul 07 '19 at 17:49

2 Answers2

2

You aren’t closing your double quotes when echoing html into the index.html. Try the below.

#!/bin/bash
  yum update -y
  yum install -y httpd
  systemctl start httpd.service
  systemctl enable httpd.service
  EC2_AVAIL_ZONE=$(curl -s http://169.254.169.254/latest/meta-data/placement/availability-zone)
  echo "<h1>Hello World From Rokkitt at at $(hostname -f) in AZ $EC2_AVAIL_ZONE </h1>" > /var/www/html/index.html
Preet Sangha
  • 64,563
  • 18
  • 145
  • 216
NHol
  • 2,045
  • 14
  • 28
1

ok, thank you ...

after carefully looking, I missed the closing quote as stated above. thanks! also, I spent time making sure the index.html file was present with the cat command with the string /var/www/html/index.html and it showed me the contents of that file. thank you again!

also, I set up my nacl and security group and internet gateway IGW to allow icmp traffic so I could ping the instance as well.

thanks!

1082

1082E1984
  • 67
  • 1
  • 4