How to Operate AWS Services Using AWS CLI
?????????? ?????????????????????? ..!!
Today I am going to perform a task in front of you, let's start:
?? Task Description
?? Creating a New Key Pair
?? Creating a Security Group
?? Creating New Inbound Rules
?? Launch an instance using above Key pair & Security group
?? Create an EBS Volume & Attach it to the launched Instance
?? Detaching the EBS volume & finally Termiating the instance
?? All these steps have been performed on the CLI.
?? What is AWS CLI ?
It is basically a way of operating the AWS Services. With the help of CLI you can configure & control Multiple AWS services at the same time.
Pre-Requiste : You should have AWS CLI software installed in your system.
You can easily download this software by searching on google 'download aws cli software'. It is available for all OS. After the installation add its path to the environment variables. Now you are ready to go..!!
1). Now open the terminal(black screen) and type aws to check whether aws cli software is working or not.
It's working....?? it's not an error, just asking for the next command.
2). How to login ?
Use command : aws configure
But it's asking for some Access Key & Secret Key. What it is...??. Don't worry it's just like a username/password asking before login. So create it first, for this create one IAM user. When you create it successfully you will get an access key(username) & secret key (password). Choose any region name as you wish.
3). How to create a New Key Pair ?
Use Command : aws ec2 create-key-pair --key-name <key_name>
I write here ec2, may you guys think why? EC2 is one of the aws service provides intances (resources/os) to run our program. I think now it's clear, if not feel free to ask??.
4). How to create your own security group ?
Use Command : aws ec2 create-security-group --group-name <any_name> --description <description_name>
I give here description name 'help' randomly you can give something else.
5). How to create your own security rules ?
Use Command : aws ec2 authorize-security-group-ingress --group-id sg-0d8bb9cf2945c2f72 --group-name <security_name> --protocol tcp --port 22 --cidr 0.0.0.0/0
Here I allow the client can only connect to the program having port number 22.
6). How to launch a new instance using above key-pair & security group ?
Use Command : aws ec2 run-instances --image-id ami-0e306788ff2473ccb --instance-type t2.micro --key-name <key_name> --security-group-ids sg-0a830f8e17f7e598c --subnet-id subnet-c6767fae --count 1
Now your instances is successfully launched??. You can see here all your instance info you created.
7). How to create EBS volume & attach it to the launched Instance ?
To create EBS volume, use command : aws ec2 create-volume --volume-type gp2 --size 1 --availability-zone ap-south-1a
To attach EBS volume, use command : aws ec2 attach-volume --instance-id i-0090de2f9625bf745 --volume-id vol-0deea87bd15afcf09 --device /dev/xvdf
Now you are all done??
Now in next steps we are going to detach the EBS volume & then finally terminate the instance.
?? Note: You must detach EBS volume first before terminating the Instance.
8). How to detach the EBS volume ?
Use Command : aws ec2 detach-volume --volume-id vol-0deea87bd15afcf09
9). How to terminate the Instance ?
Use Command : aws ec2 terminate-instances --instance-ids i-0090de2f9625bf745
That's how I completed my task successfully????.
I would like to thanks to Mr. Vimal Daga Sir for giving this challenging task. While doing this task, I learnt a lot of things related to AWS CLI.
If you have any doubt or suggestions you're most welcome, just DM me or can ask in Comments.
!!.....Thankyou so much to all who visit this article.....!!
?????????? Keep Learning, Keep Sharing??
#awscloud #awscli #aws #vimaldaga #righteducation #educationredefine #rightmentor #worldrecordholder #linuxworld #makingindiafutureready #righeudcation #arthbylw #awsbylw #uiet #mdu
@Vimal Daga @Onkar Naik @Preeti
DevOps @Forescout ?? | Google Champion Innovator | AWS | DevOps | 3X GCP | 1X Azure | 1X Terraform | Ansible | Kubernetes | SRE | Jenkins | Tech Blogger ??
4 年Good one Deepak .
System Architect at Eko
4 年Great Article! also, write on Docker.
Student at University of East London, London
4 年Wow....????