Building Basic AWS Cloud Infrastructure Using AWS CLI
Onkar Naik
DevOps @Forescout ?? | Google Developer Expert | AWS | DevOps | 3X GCP | 1X Azure | 1X Terraform | Ansible | Kubernetes | SRE | Platform | Jenkins | Tech Blogger ??
!! ?????????? ?????????????????????? !!
? Welcome you all to my article based on TASK-2 of AWS CSA & Developer Training?
?? TASK DESCRIPTION:
?? Create a key pair
?? Create a security group
?? Launch an instance using the above created key pair and security group
?? Create an EBS volume and attach to the instance we created above
? All the above steps must be performed using AWS CLI
?? What is 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.
? To use AWS Cloud through CLI only Prerequisite is to Install AWS CLI SDK tool .
?? TASK COMPLETION:
1) To use AWS Cloud as we require first Login to the AWS Account .Here we are using AWS CLI which Login to AWS Account for these we have to create one IAM User instead of Root user .
2) Now we can Login to AWS Using security credentials of IAM User we created . To Login to AWS Cloud through AWS CLI we have command as aws configure . After running these command once we have to give AWS Public and Secret Access key and Region name .
aws configure
3) Now we successfully Logged In to AWS Account . After these We have to create Private Key to connect to the ec2 Instance . For creating Key Pair we have command as :
aws create-key-pair --key-name key_name
To Download the Key Pair .pem File We have to Use following command which pipe the key pair into the file .
aws create-key-pair --key-name key_name --query "keyMaterial" > key_name.pem
4) To create Security group we have the command as :
aws ec2 create-security-group --group-name group_name --description "_description_"
To Set Inbound or Ingress Rule to authorize the outside traffic we have the command as :
aws ec2 authorize-security-group-ingress --group-id security_group_id --protocol protocol_name --port port_no --cidr cidr_block_value
We can also see above Information about Security Group in CLI using command :
aws ec2 describe-security-group --group-id security_group_id
5) Now we have to Launch one EC2 Instance using above Key pair and Security Group .To launch ec2 instance AWS CLI has command as :
aws ec2 run-instances --security-group-ids group_id --instance-type _type_ --image-id ami_id --key-name key_name --count no_of_instance
6) After Launching EC2 Instance now we have to create one EBS Volume and attach it to the EC2 Instance we launched .
??To Create EBS Volume AWS CLI has command as :
aws ec2 create-volume --volume-type volume_type --size volume_size --availability-zone AZ_name
?? To Attach EBS Volume to EC2 Instance we have command :
aws ec2 attach-volume --volume-id volume_id --instance-id instance_id --device device_name
7) We can also check the EBS Volume is attached to our EC2 Instance by Connecting to EC2 Instance via SSH . By using fdisk -l we can see the partitions of Hard Disks we attach to our EC2 Instance .
8) For getting the Information of EC2 Instance AWS CLI has command as :
aws ec2 describe-instances
To get output of the command in other format we have to use --output parameter .In my case I use YAML format .
aws ec2 describe-instances --output
9) At last we have to Terminate the EC2 Instance before that we first Detach the EBS Volume using command :
aws ec2 detach-volume --volume-id volume_id
?? To Terminate the EC2 Instance use command :
aws ec2 terminate-instances --instance-ids instance_id
?? In these way I successfully completed the TASK-2 of AWS CSA & Developer Training .
? I would like to thanks Mr.Vimal Daga for giving such challenging task which helps to me to explore my core concepts of Cloud Computing .
??For any queries or suggestions DM me .
!! Thanking you all for visiting my article !!
?? Keep Sharing Keep Learning ??
Sr. Cloud Engineer at Searce Inc | Passionate Cloud and DevOps Professional
4 年Great work ??
MTS 1 @Cohesity | Ex-Veritas | Kubernetes | Docker | Golang | Python
4 年Great work Onkar??
AWS || AZURE || PYTHON || BIG DATA || TERRAFORM || KUBERNETES || SHELL SCRIPTING || POWERSHELL || LINUX
4 年Brilliant work bro?
Terraform || Openshift(EX180) || AWS(CLF-CO2) || AWS(SAA-C03) Certified
4 年Fantastic article...??????????
Software Engineer@Principal Global Services | 1xAWS Certified | 1xMicrosoft Certified | 1xOracle Certified | AWS | Azure | Docker | K8s | Ansible
4 年Nice??