🔅 Create a key pair
🔅 Create a security group
🔅 Launch an instance using the above created key pair and security group.
🔅 Create an EBS volume of 1 GB.
🔅 The final step is to attach the above created EBS volume to the instance you created in the previous steps.
First of all, Why do we prefer Command Line Interface (CLI) instead of Graphical User Interface (GUI)?
Let’s consider a scenario. Suppose we want two launch two different instances (example, one of RedHat Linux and another Ubuntu). We cannot launch both these instances concurrently. We have to do it manually.
Or let’s image another scenario. We want to launch two instances of the same OS (suppose RedHat Linux) but in two different regions. There is no facility by which we can do this using GUI.
So, here Command Line Interface (CLI) comes to the rescue.
First of all, to use CLI, we need to install AWS CLI for our own Operating System (Linux, Windows, Mac). Then, we can use it on Command Prompt or Terminal.
Confirm if AWS CLI is installed using :
You will see some small kind of documentation come up!
Now, let’s create and configure an AWS Instance using CLI.
- Configure AWS with the Credentials (Access Key and Secret Key). You can get it by creating an IAM User and giving programmatic access. You will get access key (User-name) and Secret Key (Password).
- Creating a Key-Pair using:
>> aws ec2 create-key-pair --key-name cli-key-1
3. Creating a Security Group or Firewall:
aws ec2 create-security-group --group-name Manan --description "My new Security Group"
4. Launch an instance using the above created key pair and security group:
aws ec2 run-instances --image-id ami-032930428bf1abbff --instance-type t2.micro --key-name cli-key-1 --security-group-id sg-0fc1c079e6f8e66d1
5. Create an EBS volume of 1 GB.
aws ec2 create-volume --availability-zone us-east-1d --size 1
6. Attach the above created EBS volume to the instance you created in the previous steps.
aws ec2 attach-volume --device /dev/sdf --instance-id i-08e21463ae9082a0c --volume-id vol-0b1ec71b196bc76f0
7. Go to AWS-Management-Console. Navigate to the EC2 Instance Services. You will find the instance created running successfully with all the configurations you done.
Thanks a lot!! Hope you liked it!!