AWS CSAA EC2

AWS Console

Create a website with user data

  1. Launch an EC2 instance
    1. Select Amazon Linux
    2. Select t2.micro
    3. Assign public IP
    4. Fill User Data
      #!/bin/bash
      yum update -y
      yum install httpd -y
      service httpd start
      chkconfig httpd on
      cd /var/www/html
      hostname=$(curl -s http://169.254.169.254/latest/meta-data/public-hostname)
      echo "<html><h1>Hello Students Welcome To My Webpage on ${hostname}</h1></html>" > index.html
      
    5. Storage default
    6. Tag Name: Website
    7. Select Security group with http enabled from everywhere
    8. Launch instance
  2. Wait
  3. Open the Public DNS name from AWS Console
  4. What if user-data is not working?
    1. Open ssh connection to ec2
      cat /var/log/cloud-init.log
      cat /var/log/cloud-init-output.log
      

Comments