AMI Hands onΒΆ
In order to play with AMI we are going to create a new EC2 instance. Will all the default settings except for the User data
field.
In it we are going to input the following:
#!/bin/bash
yum update -y
yum install -y httpd
systemctl start httpd
systemctl enable httd
Once the instance is up and running, we can open it's public IP in a browser.
Now we are going to create an AMI from it.
We'll have to wait some time until the AMI becomes available. We can check that in EC2 -> Images -> AMIs
.
Now we can go to Launch instances -> My AMIs
and select our AMI. Then in the user data we input this:
#!/bin/bash
echo "<h1>Hello World from $(hostname -f)</h1>" > /var/www/html/index.html
And once it's up, we can visit in the browser and see the custom hello text.