========== AWS CLI ========== => AWS provides multiple ways to configure and manage infrastructure => We can manage infrastructure in aws cloud with below approaches 1) Web Console 2) AWS CLI 3) Terraform =========================== Using the AWS web console =========================== => It is a graphical user interface to connect with various AWS resources, their configuration, modification, etc. => It is very simple to use and does not require knowledge of scripting. ============================ AWS Command Line Interface ============================ => Using AWS CLI we can manage infrastructure in AWS cloud using commands Ex: $ aws s3 ls $ aws ec2 describe-instances ============================ Configuring AWS CLI ============================ 1) Login into AWS account & generate access keys Access Key : AKIA2RP6H2FDCHYERR Secret Access key : oLnTOtmBi1szsu4SU16d1nslc2olp3qxKJ 2) Download and Install AWS CLI s/w For windows : https://awscli.amazonaws.com/AWSCLIV2.msi 3) Open command prompt and configure AWS CLI $ aws --version $ aws configure Note: AWS configure command will ask for access key, secret access key, region and output format. ######### CLI Documentation : https://docs.aws.amazon.com/cli/latest/reference/ ########## ================================================ Working with AWS S3 Service using AWS CLI ================================================ # list down all buckets available $ aws s3 ls # list down all objects of bucket $ aws s3 ls s3://mybucket --recursive # create bucket in s3 $ aws s3 mb s3://ashokit097978 # copy file into bucket $ aws s3 cp test.txt s3://ashokit097978/test.txt # remove file from bucket $ aws s3 rm s3://ashokit097978/test.txt # remove bucket $ aws s3 rb s3://ashokit097978 ========================== Working with EC2 AWS CLI ========================== # list down all ec2 instances available $ aws ec2 describe-instances # create key-pair in ec2 $ aws ec2 create-key-pair --key-name test --output text > test.pem # Launch EC2 instance $ aws ec2 run-instances --image-id ami-0d682f26195e9ec0f --instance-type t2.micro --key-name test Instance ID : i-03cec5835807f5d8a # stop ec2 instance $ aws ec2 stop-instances --instance-ids i-03cec5835807f5d8a # start ec2 instance $ aws ec2 start-instances --instance-ids i-03cec5835807f5d8a # terminate ec2 instance $ aws ec2 terminate-instances --instance-ids i-03cec5835807f5d8a ======================================= Installing AWS CLI in Ubunut Linux VM ======================================= $ sudo apt-get install -y python-dev python-pip $ sudo pip install awscli $ aws --version $ aws configure ======================================= Installing AWS CLI in Amazon Linux VM ======================================= curl "https://awscli.amazonaws.com/awscli-exe-linux-x86_64.zip" -o "awscliv2.zip" unzip awscliv2.zip sudo ./aws/install