Skip to content

Instantly share code, notes, and snippets.

@zahidulislam012
Last active July 26, 2017 10:24
Show Gist options
  • Save zahidulislam012/8617cb2751044d7793f8af3742989a47 to your computer and use it in GitHub Desktop.
Save zahidulislam012/8617cb2751044d7793f8af3742989a47 to your computer and use it in GitHub Desktop.
aws cli configuration , launch kypair and instance
#for create aws command line interface we need python so if you do not have python then use this command
sudo apt-get install python
# after that install awscli
pip install --upgrade --user awscli
#check the aws version
aws --version
#if you need to upgrae the aws cli then upgrade it
pip install --upgrade --user awscli
# now we have to configure the aws account via aws cli
aws configure
AWS Access Key ID [None]: ************************************************
AWS Secret Access Key [None]:***********************************************
Default region name [None]:***********************************
Default output format [None]: json (i prefer json)
#if you have another aws account then follow this commmand:
aws configure --profile user2
AWS Access Key ID [None]: ************************************************
AWS Secret Access Key [None]:***********************************************
Default region name [None]:***********************************
Default output format [None]: json (i prefer json)
#create instance via aws cli command
#at first we need a key pair if you already have a key pair then skip this :
aws ec2 create-key-pair --key-name key pair name (do not use .pem at last because it auto generate)
#aws instance launch
aws ec2 run-instances --image-id ami-2cdfca3a --count 1 --instance-type t2.micro --key-name key-pair-name --security-group-ids sg-46d19837 --subnet-id subnet-d266ef9
******************************--count (if you lauch only one instance than ise count 1 if you need 2 instances then you use count 2)
--image-d(if you have the previous image other wise skip this flag)
--instance-type(i use t2.micro you can use your preferable machine)
--key name(your new and the old one)
-security group(i use my previous security group if you haven't then skip this flag)
******************************
#if you need to name your instance then use this command:(the instance id is mendatory)
aws ec2 create-tags --resources i-0851f965385eb72cd --tags Key=Name,Value=your prefererable instance name)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment