Task3:- AWS Instance Set up with CLI
Task Description β AWS π¨π»βπ»
π 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
βA key pair, consisting of a private key and a public key, is a set of security credentials that you use to prove your identity when connecting to an instance. Amazon EC2 stores the public key, and you store the private key. You use the private key, instead of a password, to securely access your instances.β
βA Security group acts as a virtual firewall for your EC2 instances to control incoming and outgoing traffic. Inbound rules control the incoming traffic to your instance, and outbound rules control the outgoing traffic from your instance.β
βAn Amazon EBS volume is a durable, block-level storage device that you can attach to your instances. β¦ EBS volumes persist independently from the running life of an EC2 instance. You can attach multiple EBS volumes to a single instance. The volume and instance must be in the same Availability Zone.
Let the task Begin:-
First of all configure the IAM User profile to your command line
aws configure β profile aman
Now Create a Key Pair
aws ec2 create-key-pair β key-name task3key β query βKeyMaterialβ β output text > task3key.pem
aws ec2 describe-key-pairs
Create Security Group & Allow 22 , 80 Ports
As in future if we want to configure web server then we are going to allow port 80 and 22 as ingress rule
aws ec2 create-security-group β group-name task3sg β description βMy security group for task 3β
aws ec2 authorize-security-group-ingress β group-name task3sg β protocol tcp β port 80 β cidr 0.0.0.0/0
aws ec2 authorize-security-group-ingress β group-name task3sg β protocol tcp β port 22 β cidr 0.0.0.0/0
aws ec2 describe-security-groups
Launch EC2 Instance
aws ec2 run-instances β image-id ami-052c08d70def0ac62 β count 1 β instance-type t2.micro β key-name task3key β security-group-ids sg-0582a6f9e4ba4daf2
here we found that launched instance id is i-036e878b80c079c93 and region is region ap-south-1b
Create EBS Volume of 1GiB
aws ec2 create-volume β volume-type gp2 β size 1 β availability-zone ap-south-1b
Here we found our VolumeID: βvol-0b80e01b389a94045β
Attach volume with EC2 instance
aws ec2 attach-volume β volume-id vol-0b80e01b389a94045 β instance-id i-036e878b80c079c93 β device /dev/sdf
Thatβs all with this article. I hope you found the post Informative, if something was missing or you think some more things could have been added, feel free to provide suggestions in the comments section.
You can check out my LinkedIn profile.
Also you can check out my GitHub profile.