Using AWS Services through AWS CLI
Completed Some Beginner Task over AWS using AWS CLI
Task Description:
π 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.
Tools Used:
AWS CLI
Task Procedure:
Installation of AWS CLI to our system by downloading and installing the software from the AWS website
For confirmation of installation, we need to run the command
aws --version
This indicates that AWS CLI is successfully installed.
For Configuring the AWS CLI we have to provide it with the access key and secret key of our AWS account to login through the account using CLI.
aws configure
For Creating Key Pair
aws ec2 create-key-pair --key-name MyKeyPair --query 'KeyMaterial' --output text | out-file -encoding ascii -filepath MyKeyPair.pem
AWS creates the KeyPair in .pem extension for ssh using system third party software we require to convert from .pem to .ppk. [One of the software which I used was puttygen]
Once you are done with Creating the KeyPair
Change mode of execution of keypair
chmod 400 .\MyKeyPair.pem
Now Letβs go to the next step to create a security group using CLI
The command for this is
aws ec2 create-security-group --group-name Security_Group_cli --description "CLI security group"
Adding Rules to Security Group for ssh connection to Instance
aws ec2 authorize-security-group=ingress --group-id <group-id> --portocol tcp --port 22 --cidr <Public IPs/CIDR>
aws ec2 describe-security-groups --group-ids <group ID>
For Launching Instance using Key pair and security group
aws ec2 run-instances --image-id AMI ID --instance-type instance type --key-name keyname --security-group-ids security group id --tag-specification 'ResourceType=instance,Tags=[{Key=Name,Value=<Instance name>}]'
create an EBS volume of 1 GB.
For this, we give information about the availability zone, volume of other information according to our use cases.
Command is
aws ec2 create-volume --size <sizeofvolume> --availability-zone <availabilityzone>
Using this command we can fetch the complete info about any Volume
aws ec2 describe-volumes --volumes <Volume ID>
For confirmation, we can check GUI
Letβs move on to the final step
To attach the above created EBS volume to the instance created in the previous steps.
The requirement for this is the volume id of the EBS volume we have created and the Instance ID to which we want to attach to this volume.
The command for this is
aws ec2 attach-volume --volume-id volume_id_of_block --instance-id instance_id --device /dev/sdb
Confirming that the Instance which we launched have two disks connected
To modify the Root Disk Size
aws ec2 modify-volume --region <regionName> --volume-id <volumeId> --size <newSize> --volume-type <newType> --iops <newIops>
Iops β Input-output speed per second from disk
TASK Successfully Accomplished