Day 40 AWS EC2 Automation


No alt text provided for this image


Automation in EC2:

Amazon EC2 or Amazon Elastic Compute Cloud can give you secure, reliable, high-performance, and cost-effective computing infrastructure to meet demanding business needs.

Launch template in AWS EC2:

  • You can make a launch template with the configuration information you need to start an instance. You can save launch parameters in launch templates so you don't have to type them in every time you start a new instance.
  • For example, a launch template can have the AMI ID, instance type, and network settings that you usually use to launch instances.
  • You can tell the Amazon EC2 console to use a certain launch template when you start an instance.

Instance Types:

Amazon EC2 has a large number of instance types that are optimized for different uses. The different combinations of CPU, memory, storage and networking capacity in instance types give you the freedom to choose the right mix of resources for your apps. Each instance type comes with one or more instance sizes, so you can adjust your resources to meet the needs of the workload you want to run.

AMI:

An Amazon Machine Image (AMI) is an image that AWS supports and keeps up to date. It contains the information needed to start an instance. When you launch an instance, you must choose an AMI. When you need multiple instances with the same configuration, you can launch them from a single AMI.

Task1:

Create a launch template with Amazon Linux 2 AMI and t2.micro instance type with Jenkins and Docker setup.

Open the Amazon EC2 console.

In the left navigation pane, choose "Launch Templates".

Choose "Create launch template".

No alt text provided for this image

In the "Create a launch template" page, enter a name for the launch template

No alt text provided for this image

For "Amazon Machine Image (AMI)", choose "ubuntu "

No alt text provided for this image

For "Instance type", choose "t2.micro"

No alt text provided for this image

create a key-pair and security group and got to next advance details

No alt text provided for this image

In the "Advanced Details" section, paste the user data script for installing Jenkins and Docker in the "User data" field.

No alt text provided for this image

Choose "Create launch template". below you can see template is created.

No alt text provided for this image

Create 3 Instances using Launch Template, there must be an option that shows number of instances to be launched ,can you find it?

To launch three instances using the launch template

In the Amazon EC2 console, choose "Launch instance from templates" in the left navigation pane.

No alt text provided for this image

Select the launch template that you just created.

No alt text provided for this image

Specify the number of instances you want to launch in the "Number of instances" field on right side. Choose the other configuration settings as desired, such as VPC, subnet, security group, and so on.

Choose "Launch instances" to launch the instances.

No alt text provided for this image

You can see three instances created from template.

No alt text provided for this image

You can go one step ahead and create an auto-scaling group

In the left navigation pane, choose "Auto Scaling Groups".

Choose "Create Auto Scaling Group".

No alt text provided for this image

In the "Create Auto Scaling Group" page, enter a name for the auto-scaling group.

For "Launch Template", choose the launch template we created earlier.

No alt text provided for this image

For "Network", choose the VPC and subnet you want the instances to launch in.

No alt text provided for this image

For "Load balancing", choose any option as per your requirement.

No alt text provided for this image

In the "Group Size" page, enter the desired capacity for the auto-scaling group, such as 2.

No alt text provided for this image

For "Scaling policies", you can choose to set up scaling policies based on various metrics such as CPU utilization, network in/out, and others. Choose the policy target tracking policy.

No alt text provided for this image
No alt text provided for this image

Choose "Create Auto Scaling Group" to create the auto-scaling group.

No alt text provided for this image

Autoscaling group is created.

No alt text provided for this image

After a few moments, the auto-scaling group will launch the desired number of instances based on the launch template and the configuration you specified. below two new instances launched by auto-scaling group.

No alt text provided for this image

Thanks for reading:-

要查看或添加评论,请登录

Kashi Diggi的更多文章

社区洞察

其他会员也浏览了