AWS CLI
In this article you will see how to use AWS by the command line .
๐ 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.
We have 3 ways to interact/communicate with AWS Technology i.e
1)Using WebUI: In this we can access the AWS services through Web portal that is by Graphical Interface where we can click and select operations using Mouse.
2)Using CLI (Command Line Interface):For this we have to install one software i.e AWS CLI SDK Tool in our base OS
3)Using Automation i.e by writing program/code
In this Practical You will see Using CLI method โฆโฆ
AWS CLI ??
The AWS Command Line Interface (AWS CLI) is an open source tool that enables us to interact with AWS services using commands in our command-line shell. For this we need to install one software for CLI for window you can download from this link
- (For Windows): https://awscli.amazonaws.com/AWSCLIV2.msi
For Linux and Mac :
- (For Linux): https://awscli.amazonaws.com/awscli-exe-linux-x86_64.zip
- (For Mac): https://awscli.amazonaws.com/AWSCLIV2.pkg
1 ) For myside this is Windows base :
First Download This Software then Install by this showing Below Images
Doing Practical By AWS CLI we need to setup Access key and secret key .
So For this first crate IAM user And Put this Access Key And Secret Key In this Cli .
First Crate IAM User Then Do below Work ..
1)Login in to AWS Account
> aws configure
AWS Access Key ID [None]: *******************
AWS Secret Access Key [None]: ***************
Default region name [None]: ap-south-1
Default output format [None]: json
Now we successfully Login to AWS Account
2) Create key-pair
For Crating Key-pair Write below command
> aws ec2 create-key-pair โ key-name MYKEY โ query keyinfo โ output text > MYKEY.pem
To see all the Key-Pairs exist in that particular region using CLI we use command
3) Create security Group
>aws ec2 create-security-group โ group-name MyCLiSecurityGroup โ description โMy security groupโ
So to Set Inbound or Ingress Rule to a security group so that we can authorize the outside traffic we can use the command
> aws ec2 authorize-security-group-ingress --group-id sg-0ac9d9eddb7112a21 --protocol all --port all --cidr 0.0.0.0/0
See in web consol
To see the above all Information about Security Group and see all the existing security group using CLI we use command
> aws ec2 describe-security-groups
4) Now, we have to launch an EC2 Instance using the Key-Pair and the Security Group that we have created in the above previous steps.
If we want to launch one more EC2 Instance using CLI we use command
> aws ec2 run-instances --image-id ami-081bb417559035fe8 --instance-type t2.micro --security-group-ids sg-0ac9d9eddb7112a21 --key-name MYKEY
5) Now, after Launching EC2 Instance now we have to create one EBS Volume of 1 GB
> aws ec2 create-volume --availability-zone ap-south-1a --size 1
6)Now We have Ec2 Instance and One EBs for Attach EBs with instances
Then Go to Instance Cli :
- Partition
- format
- mount The EBs So EBs attach with Instances
For Run bellow Command
> fdisk /dev/sdf
> mkfs.ext4 /dev/sdf
> mount /dev/sdf /mydrive
> df -h
So Our EBs Connect with Instances