Launch AWS EC2 instance with the help of AWS Command Line Interface
" 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. "
# TASK:-
?? Create a key pair
?? Create a security group
?? Launch an instance using the above created key pair and security group.
?? Create an EBS volume of 1 GB.
?? The final step is to attach the above created EBS volume to the instance you created in the previous steps.
All the above steps must be performed using AWS CLI
Step-1: Download AWS CLI Tool and install it
link:- https://aws.amazon.com/cli/
Step-2: Create IAM user in AWS and Configure AWS CLI
Goto:- aws console -> services -> IAM -> Access Management -> Users -> Add user
Now download csv file and copy aws access key and secret key from it.
aws configure
Step-3: Create key pair using AWS CLI
aws ec2 create-key-pair --key-name {name of key}
Step-4: Create Security Group using AWS CLI
aws ec2 create-security-group --group-name {name of group} --description "created using cli" --vpc-id {your vpc id}
Step-5: Launch EC2 instance
aws ec2 run-instances --image-id {ami id of instance} --count 1 --instance-type t2.micro --key-name {key name} --security-groups {name of group}
Step-6: Create volume and attach it to ec2 instance
aws ec2 create-volume --volume-type gp2 --size 1 --availability-zone ap-south-1a aws ec2 attach-volume --volume-id {id of volume create by previous command} --instance-id {your instance id} --device /dev/sdf
EBS volume attached successfully to our EC2 instance.