AWS Classroom Series – 21/Oct/2021

AWS CLI Contd

  • Creating EC2 instance using AWS CLI.
  • To create an ec2 instance we have the command run-instances Refer Here
  • Ubuntu EC2 instance
    • Make a note of AMI id of ubuntu 20 => ami-03d5c68bab01f3496
    • Make a note of instance type => t2.micro
    • Make a note of security group name and id => (sg-0eb0f3fca6c9a45a8 openall)
    • Make a note of key pair => ansible
  • Lets try to create ubuntu ec2 instance
aws ec2 run-instances --image-id 'ami-03d5c68bab01f3496' \
    --instance-type 't2.micro' --key-name 'ansible' \
    --security-group-ids 'sg-0eb0f3fca6c9a45a8' 
  • Lets try to stop the instance
aws ec2 stop-instances --instance-ids i-05025418f5dbd5d9e
  • Now lets try to terminate the ec2 instance
aws ec2 terminate-instances --instance-ids i-05025418f5dbd5d9e

Exercise using AWS CLI

  1. Create two ubuntu ec2 instances with t2.micro instance type
    1. Try login in to both instances and install any software such as apache or nginx
    sudo apt update
    sudo apt install apache2 -y
    
    1. Stop one ec2 instance and modify the instance type to t2.nano
    2. Terminate all the two ec2 instances
    aws ec2 run-instances --image-id 'ami-03d5c68bab01f3496'     --instance-type 't2.micro' --key-name 'ansible'     --security-group-ids 'sg-0eb0f3fca6c9a45a8'     --count 2 
    aws ec2 describe-instances --filter 'Name=instance-state-name, Values=running'
    aws ec2 stop-instances --instance-ids i-051287cbe1819817f
    aws ec2 describe-instances --filter 'Name=instance-state-name, Values=running'
     aws ec2 stop-instances --instance-ids i-0c8d896941e95dea2
     aws ec2 modify-instance-attribute --instance-id i-0c8d896941e95dea2 --instance-type "{\"Value\": \"t2.micro\"}"
     aws ec2 start-instances --instance-ids i-0c8d896941e95dea2
     aws ec2 describe-instance --instance-id i-0c8d896941e95dea2
    aws ec2 describe-instances --instance-id i-0c8d896941e95dea2
     aws ec2 stop-instances --instance-ids i-0c8d896941e95dea2
     aws ec2 modify-instance-attribute --instance-id i-0c8d896941e95dea2 --instance-type "{\"Value\": \"t2.nano\"}"
    aws ec2 terminate-instances --instance-ids i-0c8d896941e95dea2
     aws ec2 terminate-instances --instance-ids i-051287cbe1819817f
  1. Create one windows ec2 instance with t2.mico.
    1. Login into windows ec2 instance and install IIS Server.
    2. Launch Powershell as admin and execute Install-WindowsFeature -name Web-Server -IncludeManagementTools

Leave a ReplyCancel reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Please turn AdBlock off
Animated Social Media Icons by Acurax Responsive Web Designing Company

Discover more from Direct DevOps from Quality Thought

Subscribe now to keep reading and get access to the full archive.

Continue reading

Exit mobile version
%%footer%%