AWS Command Line Interface
š¤©Letās see some intersting thing about AWS CLI.
To work or use AWS Cloud we can use two methods:
- WebUI.
- AWS CLI(Command Line Interface).
The WebUI we use normally to work with AWS Cloud. but, Today letās see how we can work with AWS CLI.
What is AWS CLI ā
AWS Command Line Interface (CLI) is a unified tool to manage AWS services using Command Line Interface.
Before that we have to setup the AWS CLI
šØ SETUP interface by installing the CLI SDK tool.
After installing the SDK tool we have to configure the AWS CLI to manage services but, before this we need to create the IAM user with Administrator access. Which gives the Access Key and Access Secret Key to login in AWS in command line.
if you have IAM user you can login through it ,if donāt have IAM user first login to AWS .
goto IAM user Dashboard and click on the users.
šif you have the user you can use. but, if donāt have you can create by clicking Add user.
šafter clicking the Add user you get the interface of creating IAM user.
šfor new user, User name and for working with AWS using cli we have to select the option AWS Management Console access and next:permissions.
In set permissions ,select Attach exixting policies directly and select PowerUserAcces then click next, if want to add tag then add tag otherwise click next .
After successfully creating the IAM user Access Key Id and Secret access Key generated. by using them we can Configure.
šNow let us configure AWS usingCLI .
now letās ask for some help of AWS to know what we can do..
a command used for configuration
aws configure
here we user the Access key ID ,Secret access key and Region to login to IAM user which generated when you created.
Up to now we have setup the SDK tool and we have configured the AWS.
Now letās see the some intersting commands which perform different tasks.
š²letās see some basics command today.
š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 and attach to the instance we created above and detach the volume.
Create a key pair :
A Key pair is a private key which is used to connect to the EC2 instance . when you lunch any instance we use this private key as password for login.
aws ec2 create-key-pair - -key-name <keyname> - -query keyMaterial - -output text > <keyname>.pem
it will create and Download the key pair with .pem and downloaded in .pem format.
the key pair is created, we can use this key pair when we are lunching the instance.
Create a security group:
command to create security group
aws ec2 create-security-group - -group-name <name> - -description <description>
and letās look does security group is created properly or not.
using above command we only create the Security Group but we canāt create inbound rule.To set inbound rule to authorize the traffic the command is
aws ec2 authorize-security-group-ingress - -group-id <group id> - -group-name <groupname> - -protocol <protocolname> - -port <portnumber> - -cidr <cidrblocknumber>
The inbound rule created.
Launch an instance using the above created key pair and security group :
To launch the EC2 instance we are using the key pair and security that we created. the command to launch the EC2 instance is
aws ec2 run-instances - -image-id <imageid> - -instance-type- -<instancetype>count <count> - -subnet-id <subnetid> - -security-group-ids <securitygroupid>n- -key-name <keyname>
and letās look does instanc is created properly or not.
Creating an EBS volume of 1 GB and attach to the Ec2 instance that we created:
To create the EBS volume command is
aws ec2 create-volume - -availability-zone <zone name> - -size <size>
and letās look does EBS volume is created properly or not.
To attach the EBS volume to the EC2 instance the command is
aws ec2 attach-volume - -volume-id <volumeid> - -instance-id <instanceid> - -device <devicename>
volume is attached to the EC2 instance.
detach the EBS from the EC2 instance
The command to detach is
aws ec2 detach-volume - -volume-id <volumeid> - -instance-id <instanceid>
EBS is detached from the EC2 instance.
Today we have learned some intersting things about AWS CLI and how to use them .
futher we look with more commandsā¦..
Thank you for reading ā¦..š