Getting started with AWS CLI…..
No doubt we started using AWS services with Web-UI,It‘s quite easy to go through various services and access the same.
But,if it can be done by Command Line Interface?
Yes ! we can manage the AWS services using Command Line Interface. We have provision of AWS CLI with the application which we have to install on our device.
🟣Setting Up User-Account:
Setup IAM configuration by adding user in AWS and get Access Key,Secret Key and in Command Prompt of Windows / Linux ,
Type command: aws configure
Insert Access key as well as Secret Key ,
And here we go ✈….
🟣New to AWS CLI ?
Don’t worry we can lookup documentation or we have the help option in AWS CLI which assist us to step forward.
To use help option in AWS CLI , we have :
: aws help
OR : aws <servicename> help
OR : aws <servicename> <service_attribute> help
We will see this in more detail below.
🟣Deep diving in AWS :
If we want to check how many instances are running in our EC2 service,
We have command : aws ec2 describe-instances
This will show you all the instances running which will be output in JSON format.
🟣Can we launch instance using CLI ? Yes we can !
Lets see how !
To launch instance we use command :
:aws ec2 run-instances — image-id ami-xxxxxxxxx — count 1 — instance-type t2.micro — key-name Mykey — security-group-ids sg-xxxxxx — subnet-id subnet-xxxxxx
🟣Similarly a Key-pair can be created :
To create a new key pair:
:aws create-key-pair — key-name <key_name>
🟣Is it feasible to configure a new Security Group ? Yes why not!
To create Security Group: aws ec2 create-security-group — group-name <Security-Group name> — description “<description of key>”
🟣Can we create an EBS volume ?
To create an EBS volume : aws ec2 create-volume — volume-type <bydefault-(gp2)> — size <value> — availability-zone <zone_name>
🟣What if we want to attach the same block storage to previously launched instance?
→To attach EBS volume :
:aws ec2 attach-volume — volume-id <vol-xxxxxxx> — instance-id <i-xxxxxxxx> — device <(say)/dev/sdfg>