Launching EC2 Instance with AWS-CLI


AWS provides us different ways to communicate, one of them is CLI.

Command Line Interface is used for customization and saving the precious time that is used in manual things. For example if I want to launch 100 instances with different OS in aws then a lot of time is going to be wasted but with CLI power it can be done in just few minutes.

First things first an IAM account is required to this we can do this by root account but IAM is preferred. To know more about it

Click -:

Lets Start launching an EC2 instance with aws-cli.

Steps -:

  1. Install aws cli to our os.
    Link -
  2. After Installing for the first time we have to put our credentials in it.
    Use Command
aws configure

First wehave to get our access key and secret key. Make an IAM account and give it progamatic access.

3. After putting the credentials we are good to go.

4. Now you have to put the region in it. You can view its values in the webui of AWS.

You can use any of the one as values to put in CLI.

5. After that if you are a novice user then just enter for the output screen as default will be none. Internally it is JSON.

6. NOW, our task starts to launch EC2 instance with aws-cli. To launch it somethings are necessary to do.

First thing is to select AMI(Amazon Machine Image) or iso image you want to select as OS.

To find the AMI’s use command

aws ec2 describe-images --owners amazon --filters "Name=root-device-type,Values=ebs"

EBS is like an extra storage, here by using, it will only show you the instances that are backed by ebs.

Copy the image id and keep it with you.

Next thing is to Create a key pair if you are doing it first time or you can use your old key pair. To know more about creating key-pair. Click

Now to see the existing keypairs use command

aws ec2 describe-key-pairs

Copy the keypair id you want to use and keep it with you.

Do the same thing for security group. To know about Security groups more click

To see the existing security groups use the command

aws ec2 describe-security-groups

and now copy the group id you want to use and keep it with you.

You are ready with everything. To launch instance use command

aws ec2 run-instances --image-id youImageID --count 1 --instance-type t2.micro --key-name keyPairName --security-groups securityGroupName

Count is the number of instances you want to launch.

Instance type is the hardware specifications for your OS, t2.micro is free currently. To see the list of available instance types use command

aws ec2 describe-instance-types

Thank You for Reading

I would like to thanks Vimal Daga Sir. (

Email —

LinkedIn —