Amazon Machine Image - AMI:
---------------------------
--> We can create our own AMI also.
--> Create an EC2 instance, then install & configure everything as per the
requirement. then create AMI from the prepared EC2 instance.
--> Newly Created AMI will be our OWN AMI, which contains everything whstever is
exist on the Source EC2 instance (from the EC2 instance which we create the AMI)
--> Whenever we use the newly created AMI to launch a new EC2 instance, then the
new Instance will be created with all the componenets inclued in the AMI by
default.
1. Create an AMI "MyFirstWebsite" in which a basic website to be included.
a) Create an Amazon Linux2 EC2 instance ( allow ssh, http & https)
- Create a new security group with http & https allowed
b) Login to the Linux EC2 Instance & host a website
# Install all pending updates
sudo yum update
# Install the httpd webserver
sudo yum install httpd
# Check the status of the httpd service and start if reqired
service httpd status
sudo service httpd start
# Configure the httpd service to be started automatically
sudo chkconfig httpd on
# create a webpage "index.html" in /var/www/html/
# navigate to the directory /var/www/html
cd /var/www/html
# create the "index.html" file
sudo vi index.html
# enter into Insert mode
press i
Type "Welcome to Naresh i Technologies!!"
# come out of the insert mode
press 'esc'
type :wq
c) access the website using the publicIP & confirm the website hosted
3.83.176.43
2. Create an AMI "MyFirstWebsite" from the above EC2 instance.
3. Create new EC2 instance using the custom AMI "MyFirstWebsite"
4. Access the public IP in the browser to check the website is running
54.204.149.12
--> We cannot use the AMIs across different regions. Instead we can copy the AMI to
the required region and then create new EC2 instance.
5. Copy the AMI from N.Virginia to Mumbai Region.
Mumbai AMI ID : ami-0319c13b6fe218c8b
N.Virginia AMI ID : ami-0a1d9443aacf75853
Note: All Custom AMIs are private by default.
6. Convert the custom AMI (N.Virginia) into Public AMI, so that anybodey can use
our AMI across all the AWS Accounts in N.Virginia Region only.
8. Share the custom AMI which is in Mumbai region with a specific AWS account only.
9. Cleanup the Custom AMI.
- Deregister the AMI
- Delete the Snapshot associated with the AMI