AWS CLI Setup and Launch EC2 Instance with KeyPair and Security Group with AWS CLI
The AWS Command Line Interface (CLI) is a unified tool to manage your AWS services. With just one tool to download and configure, you can control multiple AWS services from the command line and automate them through scripts.
- A 64-bit version of Windows XP or later.
- Admin rights to install software
Download AWS CLI v2 on Your System
Configure AWS CLI
You Need Your AWS Access_key and Secret Key to configure AWS_CLI.
What is access_key or secret_key?
Access keys consist of an access key ID and secret access key, which are used to sign programmatic requests that you make to AWS. If you don’t have access keys, you can create them from the AWS Management Console.
How to Create Access Keys?
Check this AWS Official Documentation: Here
Now, Let see How to Create a KeyPair, Security Group with SSH access, an EBS Storage, Instance with Same KeyPair, SecurityGroup and EBS.
Creating A Key-Pair:
aws ec2 create-key-pair
--output text > MyKeyname.pem
This will save your Key to MyKeyname.pem file.
Creating a Security Group:
aws ec2 create-security-group
--description “My security group Description” > securitygrp.txt
This Creates a Security Group with Name my-securityGrp_name with no Rules for Ingress and all traffic allowed for Egress.
Security Group ID is saved in securitygrp.txt
Adding Ingress Rules
aws ec2 authorize-security-group-ingress
SSH rule Added to our Security Group.
For Egress Rules :
authorize-security-group-egress in the same Format
Creating an EBS Storage:
aws ec2 create-volume
--volume-type gp2 > ebsstorage.txt
New EBS Storage Made!
Volume ID saved in ebsstorage.txt
Launch Instance With Our Key, Security grp:
aws ec2 run-instances
--associate-public-ip-address > instance_details.txt
Instance Created with our KeyPair, Security Grp.
All Details About Instance Are stored in instance_details.txt
Attach the EBS storage to Instance:
aws ec2 attach-volume
Our EBS Is Now attached to Instance!
Done! Enjoy AWS_CLI!
Thanks For Reading 🙏
Connect With Me: