Launch EC2 instance using CLI(Command Line interface)

Launch EC2 instance using CLI(Command Line interface)

AWS(Amazon Web Service):-

Amazon Web Services (AWS) is a on-demand cloud computing platforms and APIs to individuals, companies, and governments, on a metered pay-as-you-go basis. These cloud computing web services provide a variety of basic abstract technical infrastructure and distributed computing building blocks and tools.

AWS provide many services like EC2,EBS,EKS,VPC etc..........

In this artical we discuss EC2 service using CLI(Command Line Interface).

EC2(Amazon Elastic Compute cloud):-

EC2 encourages scalable deployment of applications by providing a web service through which a user can boot an Amazon Machine Image (AMI) to configure a virtual machine, which Amazon calls an "instance", containing any software desired. A user can create, launch, and terminate server-instances as needed, paying by the second for active servers – hence the term "elastic".

->EC2 provide boot able Image, use to launch operating systems.

->EC2 provide Compute infrastructure like RAM and CPU.

AWS(Amazon web service) provide 3 way to communicate with the clients like WebUi, CLI and programming way to communicate with AWS.

In this artical we learn how to communicate AWS using CLI commands.

Installing AWS Commands:-

Follow the below URL install the AWS command on the Redhat 8,https://docs.aws.amazon.com/cli/latest/userguide/install-cliv2-linux.html

Check the AWS command install in my system or not, run the command

aws --version
No alt text provided for this image

Above command show the AWS command successfully install in my systems.

Run AWS command show the option what we do using AWS commands.

aws
No alt text provided for this image

Configure AWS system using secret key and access key..............................

aws configure
No alt text provided for this image

Above command use to login the AWS , IAM(Identity access management) user account,IAM service provide to create a user and give the Admin and power user access to use service of AWS clouds.

Find information about instances:-

aws ec2 descibe-instances

Run this command find the information about all instances stopped and running status of the instances.............

No alt text provided for this image

describe-instance -> show all the current status of EC2 dashboards.show how many instances in the running and stopped.

Start EC2 instance using AWS commands:-

 aws ec2 start-instances --instance-ids "EC2 instance ID"

This command use start the EC2 instance using instance id and start ec2 instance.

No alt text provided for this image
No alt text provided for this image

Above diagram show the status of running commands.

Launch Ec2 instance using CLI(Command line Interfaces):-

Requirements of launch EC2 instances.............

aws ec2 run-instances --image-id ami-0e306788ff2473ccb --instance-type t2.micro --subnet-id subnet-90b882f8 --count 1 --security-group-ids  sg-0261a80ac31a91c30 --key-name arthhadoop1122

No alt text provided for this image
No alt text provided for this image

Use CLI concepts launch Ec2 instance, above figure show the launching status of EC2 instances.

Solve one use case using CLI(Command Line Interface) concepts...........

Task descriptions..............

Step1:-Create a key pair

step2:-Create a security group

step3:- Launch an instance using the above created key pair and security group.

step4:- Create an EBS volume of 1 GB.

step5:-The final step is to attach the above created EBS volume to the instance you created in the previous steps.

Solutions of use case...................

Step1:- Create a key pair using CLI(Command line Interface) concepts.....

aws ec2 create-key-pair  --key-name arthkey

No alt text provided for this image
No alt text provided for this image

Step1 to solve how to create key pair, Key pair use give the password of the instance.

step2:-Create a security group use CLI(Command line interface) concepts.

aws ec2 create-security-group --group-name MysecurityGroup --description "My security group"

No alt text provided for this image
No alt text provided for this image

Step2 use to create security groups.

step3:- Launch an instance using the above created key pair and security group.

aws ec2 run-instances --image-id ami-0e306788ff2473ccb --instance-type t2.micro --subnet-id subnet-90b882f8 --count 1 --security-group-ids  sg-0c07ac51a9a23a376 --key-name arthkey

No alt text provided for this image
No alt text provided for this image

Use step1 and step2 create step3 and launch ec2 instance.

step4:- Create an EBS volume of 1 GB using CLI(Command line Interface) concepts.

aws ec2 create-volume --availability-zone ap-south-1a --volume-type gp2 --size 10

No alt text provided for this image
No alt text provided for this image

In this step create EBS volumes..............

step5:-The final step is to attach the above created EBS volume to the instance you created in the previous steps.

aws ec2 attach-volume --volume-id vol-033ddb83195b01c53 --instance-id i-091cace16629819b8 --device /dev/sdf

No alt text provided for this image
No alt text provided for this image

Summary:-

In this artical we learn how to use CLI(Command line Interface) and launch EC2 interface and mount EBS storage with EC2 instance.

Thanks vimal Daga sir Give high level and advance idea to use Command line interface and launch services and learn more new concepts about AWS clouds.

To view or add a comment, sign in

More articles by Neetesh Yadav

  • AWS Cloudfornt setup using CLI(Command Line Interface)

    Description of Task..

  • Machine Learning Use in Health Care Fields

    The field of medical AI is buzzing. More and more companies set the purpose to disrupt healthcare with the help of…

  • AWS Task-2

    AWS:- Amazon Web Services (AWS) is a subsidiary of Amazon that provides on-demand cloud computing platforms and APIs to…

  • Arth - Task3

    Hadoop:- Apache Hadoop is a collection of open-source software utilities that facilitate using a network of many…

  • Healthcare AWS case study

    Myriad Genetics Uses DNAnexus on AWS to Bring Precision Medicine to the Clinic DNAnexus case study:- " With AWS…

  • Ansible+EC2(AWS)+Haproxy

    Haproxy:- HAProxy is free, open source software that provides a high availability load- balancer and proxy server for…

  • Ansible+ AWS+Webserver

    In this articale we solve one great use case use concepts of AWS and ansible and web-server. Description of Use case:-…

  • Flutter Integrate with Python

    In this article we create app integrate with various technology and tools like,Docker,Python etc..

  • Big Data

    Big data is a field that treats ways to analyze, systematically extract information from, or otherwise deal with data…

  • Communicate with System using Python

    In this artical we create simple chat bot system using python conditional statements concepts.In this we learn how to…

Explore content categories