Showing posts with label template. Show all posts
Showing posts with label template. Show all posts

Sunday, March 20, 2022

AWS Compute - Create a Launch Template for EC2 Instances


AWS - Create a Launch Template for EC2 Instances

A launch template function is that it specifies the instance's configuration information, such as:
  1. Amazon Machine Image (AMI)
  2. Instance type
  3. Key pair
  4. Security groups
  5. Other parameters used to launch EC2 instances.

Ways to create a Template and launching it

Step 1: Create an EC2 instance.

OS: Ubuntu 18.05
Instance type: t2.micro
Security Group: WebServer(port 22,80 are opened)
userdata:
#!/bin/bash
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: irfan/apacheimg

Step 4: Verify Image get created
Images ---> AMIs

Step 5: Create a Template from this image
Instances ---> Launch Template
Click on Create Template
Launch Template Name: ApacheTemplate
Template Version: Prod
Application and OS Images AMIs: irfan/apacheimg
Instance type: t2.micro
key pair: Irfan-RSA
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

Fluentd

Open-source log data collector > why logs? - for compliance (auditing, company, business) - for security (transparency, monitoring, admin...