How to Create Launch Configuration for autoscaling on Amazon Web Service(AWS).
A launch configuration is a template that an EC2 Auto Scaling group uses to launch EC2 instances. When you create a launch configuration, you specify information for the instances such as the ID of the Amazon Machine Image (AMI), the instance type, a key pair, one or more security groups, and a block device mapping.
- Login to aws portal.
- Click on Services.
- Under Compute select EC2.
- Click on Launch Configurations.
- Click on Create Launch configuration.
- Provide launch configuration name.
- Select AMI(Amazon Machine Image) like : Ubuntu 18.04 or centos 8 .
- Click on Choose Instance type.
- Select number of vCPUs & memory as per requirement.
- Enable Monitoring for instance logs within Cloudwatch.
- Click on Advance details.
- Leave the all configuration.
- User Data can be used to perform common automated configuration tasks and even run scripts after the instance starts. You can pass two types of user data to Amazon EC2: shell scripts and cloud-init directives.
- Assign IP address type: auto-assign or custom .
- Provide Storage(volume) for instance.
- We can increase or decrease volume as per requirement.
- Create or Select existing security group.
- We can Add more rules like:- SSH ,HTTP or HTTPS .
- Create or Select Existing Key Pair.
- Then click on Create Launch Configuration.
- After sometime Launch Configuration is ready.
Create Launch Configuration using Shell
- Setup aws-cli on your system so click on link https://www.hackerxone.com/blog/how-install-configure-aws-cli-ubuntu-1804
- Run the following command:
1: To create a launch configuration.
aws autoscaling create-launch-configuration –launch-configuration-name launch_config_name –image-id image_ami –instance-type instance_type
2: To create a launch configuration.
aws autoscaling create-launch-configuration –launch-configuration-name launch-config_name –key-name key-pair_name –instance-id instance_id –security-groups security_group_id –instance-type m1.small –user-data path_of_the_file