Sunday, March 13, 2022

Ec2 - Launch Template

 A launch template, in that it specifies instance configuration information. 

  • Amazon Machine Image (AMI)
  • Instance type
  • Key pair
  • Security groups
  • Other parameters used to launch EC2 instances. 

Step 1: Create EC2 instance 
  •             OS: Ubuntu 18.05
  •             Instance type: t2.micro
  •             Security Group: WebServer(port 22,80 are opened)
  •             userdata:
sudo su
sudo apt update
sudo apt install apache2 -y
sudo echo "<h1>Testing the Launch Template app </h1>" > /var/www/html/index.html
Step 2: Verify Instance get created with Apache installed and in the running state
            sudo su
            systemctl status apache2
            Take Public IP address of Ec2 instance and check on browser.

Step 3: Create an AMI from EC2 instance.
             Select Ec2 instance
             Action-->Image and Tempates ---> Image
             Image :- apacheimg
Step 4: Verify Image get created
Step 5: Create a Template from this image
            Instances---> Launch Template
            Click on Create Template
            Launch Template Name: ApacheTemplate
            Template Version: Prod
            Applicaiton and OS Images AMIs: apacheimg
            Instance type: t2.micro
            key pair: vdevops
            Security Group: Webserver
 Click on Create launch Tempate

Step 6: Create Ec2 instance from Template
            Select the template ApacheTemplate 
            Action--> Launch Instance from template
            Review the template settings
            Launch Instance
Step 7: Verify the Instance is created and apache is installed with a modified index.html file



Post a Comment