• 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 1GB
• Finally attach the above created EBS Volume to the instance created in the previous step.
Note — This task should be performed using the AWS CLI and not by using the WebUI.
1. To login to the aws account through CLI just run the command aws configure and copy the access key and secret access key from the downloaded .csv file then give the region name and give the format like JSON.
2. Now we need to create a New Key Pair using AWS CLI
3. For creating a new key pair through the CLI run the command:
aws ec2 create-key-pair –key-name <give the key name>
To confirm the key pair is successfully created just go to the WebUI and check.
Note: Change the region in which we have created the user account on the right top corner.
4. To describe all the key pairs run the command:
aws ec2 describe-key-pairs
5. Know we need to create a Security Group using AWS CLI.
6. To create a new security group using the AWS CLI just run the command:
aws ec2 create-security-group –group-name <give security group name> –description “give any description”
To confirm the Security Group is successfully created just go to the WebUI and check.
7. By default, no inbound rule is created and due to that, no one can enter as no protocol is associated so just add the inbound to all traffic.
8. To create the inbound run the command:
aws ec2 authorize-security-group-ingress –group-id <give the group id> — protocol tcp –port 22 –cidr 0.0.0.0/0
We don’t need to memorize all the commands just take the help of documents by using the help command or just take the help of google.
To confirm the Security Group is successfully created just go to WebUI and check.
9. To describe all the security groups run the command:
aws ec2 describe-security-groups
10. Now we need to launch an ec2 instance using the above created key pair and security group
11. To launch the instance run the command:
aws ec2 run-instances –security-group-ids <give the groupid> — instance-type t2.micro –image-id ami-0e306788ff2473ccb –key- name <give key name> — count 1
12. The ec2 instance is successfully launched and is running.
13. After launching the ec2 instance we have to create 1 EBS Volume of 1 GB.
14. To create a new EBS Volume from CLI run the command:
aws ec2 create-volume –volume-type gp2 –size 1 –availability-zone ap-south-1a
To confirm the EBS Volume is successfully created just go to WebUI and check.
EBS Volume of 1 GB is successfully created.
15. Now last step is to attach this EBS Volume created to the ec2 instance that we have created in the previous steps.
16. To attach the EBS Volume to ec2 instance through CLI run the command:
aws ec2 attach-volume –volume-id <give the volume id> — instance-id <give the instance id> — device /dev/sdf
17. The EBS Volume is successfully attached to the instance.