Create a EC2 Instances using key pair and security groups and attach the EBS volume to existing Instances using AWS CLI

Prerequisite for this task!

  • Familiar with AWS basic services.
aws ec2 create-key-pair --key-name <name of the key> > <name of the Key File>.pemFor example: “aws ec2 create-key-pair --key-name CLIKey > CLIKey.pem”
image by author
aws ec2 create-security-group --group-name <name of the Security Group> --description “Any Description abou the security groupFor example: aws ec2 create-security-group --group-name CLISG --description "Basic Security group created using AWS CLI! "
Image by author .
aws ec2 run-instances --image-id <AMI Image ID> --key-name <Key Name> --instance-type <Type Of Instance> --security-groups <Name of the Security Group> --tag-specifications 'ResourceType=instance,Tags=[{Key=<Any Key>,Value=<Any Value>}]
'For Example: aws ec2 run-instances --image-id ami-052c08d70def0ac62 --key-name CLIKey --instance-type t2.micro --security-groups CLISG --tag-specifications 'ResourceType=instance,Tags=[{Key=Name,Value=CLI-EC2-Instance}]
Image by author.
aws ec2 create-volume --size <Size in GiB> --availability-zone <Name of the Availability Zone where EC2 Instance is launched>For Example: aws ec2 create-volume --size 1 --availability-zone ap-south-1a
image by author.
aws ec2 attach-volume --volume-id <Volume ID to be attached> --instance-id  <Instance ID to which this volume has to be attached>  --device <Device Name>For Example: aws ec2 attach-volume --volume-id vol-0c266c523d78050de --instance-id  i-0c7ef601cda90170c  --device /dev/xvdh
Image by author.




self learner ! Engineer ! dedication to learn new skills

Love podcasts or audiobooks? Learn on the go with our new app.

Recommended from Medium

Eclipse IDO Partnership: Amara Finance

Python: Checking that everything is object! Mutable, Immutable objects.

Roadmap Series: Competitive Programming

Today is the Day

How to Create your own Container without using the Container Management To0l

Partitioning in PostgreSQL

Prince of Persia on Phaser 3

100 Days of Hacking — DAY 4

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Himanshu singh

Himanshu singh

self learner ! Engineer ! dedication to learn new skills

More from Medium

History of Automation and eCommerce Business

History of eCommerce automation

Simpler than it looks: Discovering the Shoestring approach to digital manufacturing

Measure What Matters For Business Agility With SAFe Metrics

Project Management Organization Chart Template

Project Management Organization Chart Template