Services Covered
EC2
EBS
Lab description
This lab walks you through creation of an snapshot of EC2 instance and how to launch a new EC2 instance using the AMI of that snapshot.
Learning Objectives
- Create 2 EC2 Instances
- Create a Snapshot
- Create an AMI Image and launch an instance out of it
Lab date
30-10-2021
Prerequisites
- AWS account
Lab steps
- Launch EC2 Instance. Use the following User data:
#!/bin/bash sudo su yum update -y yum install httpd -y echo "<html><h1> Welcome to Whizlabs Server 1 </h1><html>" >> /var/www/html/index.html systemctl start httpd systemctl enable httpd
Attach a Security Group allowing inbound traffic for SSH and HTTP from anywhere.
- Test the Apache server by navigating to the instances Public IP.
- Create a Snapshot of EC2 Instance. Under Elastic block Store navigate to Snapshots and create volume snapshot of your instance volume.
- Create AMI with Snapshot. Select the created snapshot, clock on Actions and select Create Image.
- Next create an EC2 Instance using newly create AMI. Navigate to AMIs and launch new instance of type t2.micro and add User data
#!/bin/bash -ex sudo service httpd restart
Attach the previously created security group.
- When the new instances status is running navigate to its Public IP and you should get the same response as from server 1 (notice different IP address):