Configuration of ec2 instance

Kalpanatale
2 min readOct 20, 2020

Initial setup

Insatllation of aws cli

  • aws — version #to check wheather awc cli intalled or not
  • aws configure #to configure aws servics
  • enter asked access code and access key

Creating ec2 keypair

*aws ec2 create-key-pair — key-name awsclikp #to create a key pair named as awsclikp

Creating ec2 security group

aws ec2 create-security-group — group-name awsclisg — description “awscli security group” #to create a security group named as awsclisg and has description as awscli security group

Creating esb volume

  • aws ec2 create-volume \ — volume-type gp2 \ — size 1 \ — availability-zone ap-south-1c #to create a volume of size 1gb of type gp2 and having availability zone as ap-south-1c

Lauching the instance using the above created key-pair, security-group and volume

  • aws ec2 run-instances — image-ids _______ — instance-type _______ — count ___ — subnet-id ______ — security-group-ids _______ — key-name #substitute the key name from the output of :created keypair above, :created security group in the required and specified blanks also take the required remaining info from aws ec2 webui

Now the ec2 instance has launched and we have to attach a volume created of size 1gb, as the volume can only be attach to a stopped instance so first we have to stop the launched running instance

Stopping the running instance

aws ec2 stop-instances — instance-ids _______ #to stop the running instance; substitute the id of above launched running instance

Attaching a volume created to above instance

aws ec2 attach-volume — volume-id _____ — instance-id _____ — device _____ #to attach a volume, substitute volume id from the output taken from volume created and instance id from the instance launched and fill the device name

Now the volume has attached, to use the instances we have to start the stopped instance

To start a stopped instance

aws ec2 start-instances — instance-ids ______ #starting a stopped instance; put the instance id of stopped instance

#awscloud #awscli #aws #vimaldaga #righteducation #educationredefine #rightmentor #worldrecordholder #linuxworld #makingindiafutureready #righeudcation #arthbylw #awsbylw

--

--