Using AWS CLI to create a basic Infrastructure on Cloud
"Cloud Computing" is becoming the norm of modern society. Cloud computing is the on-demand availability of computer system resources, especially data storage and computing power, without direct active management by the user
Now, usually, in order to use Cloud Computing, there are mainly 3 ways to do that :-
- From GUI (Graphical User Interface) i.e. going to the Cloud Management Console, login into the account and start using any service
- Another way is, operating every single service of Cloud Platform through CLI (Command Line Interface) i.e. using specific commands to control any service of a user's choice
- The final way is, to use a programming tool and creating a program file and specifying the things we want to do on the Cloud Platform
❗ ❕ Which is Better (GUI or CLI) ?
Usually, the way of operating Cloud Computing platforms using CLI is "more preferred" over GUI . This is because, "Using Cloud Computing through CLI makes our process much more fast and quick, as compared to GUI"
" So, today, I am gonna demonstrate the power of operating Cloud Computing from CLI, by launching a basic Cloud Infrastructure completely using CLI "
Pre-requisites for this task :-
♦ Cloud Computing Platform - Amazon Web Services (AWS)
♦ Tool used - AWS CLI
🔴 If you don't have AWS CLI already installed in your system :-
○ First, download the AWS CLI package file from the link given below :-
○ After downloading is complete, just open the setup file and install the application using the basic procedure
○ Now, the installation is done and it is now time to make the CLI program executable. For that, search in your local system for "Edit Environment Variables"
○ Now, we have to create the path for the CLI program, for that......
○ Now, open your Windows Command Prompt, and if everything is done correctly, just confirm the installation of the program using the command.....
# aws --version
Now, our main work starts.......
- First, in order to interact with the AWS management console using CLI, we first have to configure our CLI. Now, what happens is, as HUMAN BEINGS, we use to login using the Username and Password, but in this case where the machine has to login into the console, we need to provide the ACCESS KEY and SECRET KEY to the CLI program. So, we have to provide the ACCESS and SECRET key of our account to the program
2. Now, first, we will create a key pair using the CLI. I have given name to the key as myfirstkey
# aws ec2 create-key-pair --key-name <your_key_name>
3. Now, we are gonna create a security group. I have given my Security Group the name myfirstSG
# aws ec2 create-security-group --group-name myfirstSG --description "My firsy Security Group"
4. Now, let's create an EBS volume for our Instance. The Volume size I am gonna give to my EBS is 1 GiB
# aws ec2 create-volume --volume-type gp2 --size 1 --availability-zone ap-south-1a
5. Now comes the main part. Now, we are gonna create an EC2 instance from CLI using the Key-Pair and Security-Group we recently created
# aws ec2 run-instances --image-id ami-052c08d70def0ac62 --instance-type t2.micro --count 1 --subnet-id subnet-529b913a --key-name myfirstkey --security-group-ids sg-0528ed51b7301be01
6. Now comes the final part. Since the EC2 instance is running perfectly fine, it's time to attach the EBS volume we created recently to our running instance
# aws ec2 attach-volume --device /dev/sdh --instance-id i-0d2c5eeb5de4ee337 --volume-id vol-06234fc5d2fb1365f
That completes the setup of a basic Cloud Infrastructure using CLI and with this practical, we get to know about the power of operating AWS using Command Line Interface (CLI)
Thanks for reading my article. I hope you liked it. If you do, leave a big THUMBS-UP and all the suggestions are welcomed in the COMMENT section
Great going buddy! All the best👍