AWS Command Line Interface

AWS Command Line Interface

Amazon Web Services (AWS) is the world’s most comprehensive and broadly adopted cloud platform, offering over 175 fully featured services from data centers globally.

  • The AWS Command Line Interface ( CLI ) is a unified tool to manage your AWS services.
  • With just one tool to download and configure, you can control multiple AWS services from the command line and automate them through scripts.

We can use AWS services from three of the following ways:-

  1. WebUI
  2. Command Line Interface (CLI)
  3. Automation through scripts


Why use AWS CLI?

  • In WEBUI we cannot launch two instances at different subnets at same time. [ There are many more such cases this is just an example ]
  • CLI is automatable
  • Real developers don’t use GUI !

YOU CAN VISIT HERE TO GET MORE INFO - AMAZON CLI

YOU CAN GET HELP FROM CLI FOR ANY COMMAND -

USING --->>> aws help , aws <command> help , aws <command> <subcommand> help

few examples:- aws ec2 help, aws ec2 describe-instance help

So we will perform a task wherein we will

?? 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.


To perform this task first we need to follow few steps:

  • Create AWS account 
  • Install AWS CLI (version 2)
  • For Windows you can use this link → AMAZON CLI V2 FOR WINDOWS
  • Open Control Panel run command aws --version (For confirmation of installation)
  1. After all is set we need to go to AWS console to create user (We can also create user from CLI)

→ Go to all service → choose IAM and choose go to IAM Dashboard

No alt text provided for this image

Now you need to perform following task to create user.

  1. Select Users option from left sidebar in Dashboard and select add user.
No alt text provided for this image

2. Add username and password → Next Permission

No alt text provided for this image

3. Click attach existing policy -> select Power User Access

No alt text provided for this image

5. Click → Next Review → add user

6. You have to use this access key and secret key

No alt text provided for this image

7. Go to the command prompt and enter your credentials.

  • You will need to enter here your access key and secret key
  • You can choose availability zone and output format like - yaml , yaml-stream, table , json
No alt text provided for this image


Let us now start with the task

  1. create key pair

Command → aws ec2 create-key-pair --key-name keypair

No alt text provided for this image

2. Create security group with Inbound rule all traffic

Command → aws ec2 create-security-group --group-name security --description security

Command → aws ec2 authorize-security-group-ingress --group-name security --protocol all --cidr 0.0.0.0/0

No alt text provided for this image

3. Launch instance using above security group and key pair

Command → aws ec2 run-instances --image-id ami-0e306788ff2473ccb --key-name keypair --tag-specifications ResourceType=instance,Tags=[{Key=Name,Value=Hasti}] --security-groups security --instance-type t2.micro --placement AvailabilityZone=ap-south-1a --count 1

No alt text provided for this image

4. Create EBS Volume of 1GB

Command → aws ec2 create-volume --availability-zone ap-south-1a --size 1 --tag-specifications ResourceType=volume,Tags=[{Key=Name,Value=vol}]

No alt text provided for this image

5. Attach above created volume to instance

Command → aws ec2 attach-volume --volume-id vol-027d8476f1d155c31 --instance-id i-02d4ff604f947e5b8 --device /dev/sdf

No alt text provided for this image

So, in conclusion we have used AWS CLI to successfully launch instance. Once you have got idea of how to use it, its great tool believe me ! This is everything you will need to bring automation through your scripts and perform task which is not possible through WebUI.

!! THANKYOU !!
Prajwal Suryawanshi

Site Reliability Engineer at Crest Data Systems

4 å¹´

Very helpful!!

Vijay S.

Learning Enthusiast let's Connect...

4 å¹´

Fantastic...

Vimal Daga

World Record Holder | 2x TEDx Speaker | Philanthropist | Sr. Principal Consultant | Entrepreneur | Founder LW Informatics | Founder Hash13 pvt ltd | Founder IIEC

4 å¹´

Grt

Priyanka Hajare

DevOps Engineer || Python || Docker || Ansible || Kubernetes || AWS || Jenkins || Buildkite || GoCD || GIT || GITHUB ||

4 å¹´

Great work

要查看或添加评论,请登录

Hasti Vora的更多文章

  • AWS SIMPLE QUEUE SERVICE (SQS)

    AWS SIMPLE QUEUE SERVICE (SQS)

    Before we understand SQS we need to know what is Message Queuing. INTRODUCTION TO MESSAGE QUEUE Message queue is a…

    2 条评论
  • AI ON AWS

    AI ON AWS

    The advent of Machine Learning (ML) and Artificial Intelligence (AI) technology has helped companies to push the…

    4 条评论
  • HOW INDUSTRY USING JENKINS?

    HOW INDUSTRY USING JENKINS?

    Jenkins helps you to build and test your software projects thus its an powerful application that allows continuous…

  • How industries are solving challenges using Ansible?

    How industries are solving challenges using Ansible?

    When you Automate you Accelerate ! Okay So before talking about amazing usecases of ansible let us know about What is…

  • Creating a setup so that we can ping to google but not to facebook from same system

    Creating a setup so that we can ping to google but not to facebook from same system

    Before beginning with the task let us know basic networking concepts that will help you to understand it better. * 1.

    2 条评论
  • Kubernetes and Adidas

    Kubernetes and Adidas

    What is Kubernetes? Kubernetes is also known as K8's or kube which was developed and designed by engineer at Google…

  • Expert Session on Industry Use Cases With Demonstration On Kubernetes

    Expert Session on Industry Use Cases With Demonstration On Kubernetes

    1. CVS is Concurrent Versioning System that works on file level 2.

  • Industry UseCases of Kubernetes and OpenShift

    Industry UseCases of Kubernetes and OpenShift

    An Expert session on Industry Use Cases of Kubernetes and OpenShift was held yesterday i.e.

  • 8 Hours Journey of Git and GitHub with Vimal Daga Sir

    8 Hours Journey of Git and GitHub with Vimal Daga Sir

    So, let me start from a small scenerio to explain what I learnt Consider developer is developing the WebApp. Workspace…

    4 条评论
  • Setting up Python Interpreter and running Python Code on Docker Container

    Setting up Python Interpreter and running Python Code on Docker Container

    Previously I showed you how to install and launch docker in RHEL8. You can visit this article to get more details:…

    3 条评论

社区洞察

其他会员也浏览了