Launch EC2 Instance from AWSCLI

Launch EC2 Instance from AWSCLI


In this blogpost, I will show you how to launch EC2 instance from AWSCLI (AWS command line).  This is very quick when compared to creating instances with console.  Please check my previous post about how to launch EC2 from AWS Console.

First, we need to install the AWS CLI, then configure it and finally launch EC2 using CLI.

Download appropriate AWS CLI MSI installer for your system, here I will be using Windows version.  Once installed, go to Windows command prompt and type aws.  If you are getting any output, then it means aws cli was installed.

Now, we need to configure AWS CLI with security credentials.  If you don’t have them, then we need to create them.   

For the sake of easiness, I am creating security credentials for root user, don’t share the credentials with anyone and delete them or make them inactive after your activity.

In the navigation panel, choose user and  My Security Credentials



Press Continue to Security Credentials


 

Then click ‘Create New Access Key’ from Access Keys


Click Download Key File, the downloaded file will be in .csv format.  Keep the file in a safe location and don’t share it with anyone.  It will contain AWSAccessKeyId and AWSSecretKey.






Now, we need to configure aws cli with the security credentials

In the command prompt, type:  aws configure
It will prompt you Access Key ID, Secret Access Key, Region and Output format; enter the first two from csv file that we have downloaded; enter region as us-west-2 – we will be using Oregon as our region; leave output as default.