AWS Lab1 – EC2, AMI, Instance Meta Data, User Data

Objectives: In this post, I would show you how to create your Own AMI and use “Metadata” and “User Data” to run scripts

  1. Launch EC2 Instance
  2. Install and configure apache
  3. Create AMI from the EC2 Instance
  4. Launch new EC2 Instance from the AMI and use User Data
    #!/bin/bash
    sudo echo “<html><h1>My Public IP is: $(curl -s http://169.254.169.254/latest/meta-data/public-ipv4/)</h1></html>” >> /var/www/html/index.html
    sudo echo “<html><h1>My Private IP is: $(curl -s http://169.254.169.254/latest/meta-data/local-ipv4/)</h1></html>” >> /var/www/html/index.html

Launch EC2 Instance





curl http://169.254.169.254/latest/meta-data/public-ipv4
curl http://169.254.169.254/latest/meta-data/local-ipv4


Install and Configure Apache





Create AMI





Launch Instance from Custom AMI


#!/bin/bash

sudo echo “<html><h1>My IP is: $(curl -s http://169.254.169.254/latest/meta-data/public-ipv4/)</h1></html>” >> /var/www/html/index.html

sudo echo “<html><h1>My IP is: $(curl -s http://169.254.169.254/latest/meta-data/local-ipv4/)</h1></html>” >> /var/www/html/index.html





AWS Lab2 – VPC, Subnets and NAT
Route 53
No tags for this post.

Leave a Comment