Prerequisites:
-An Amazon AWS account.(Free or Paid account)
-An IAM user with Access Key and secret access key.
–Pre-configured VPC, Subnets, Routes, Internet gateways, Security policy.
-Any Linux Machine with aws cli utlity installed.
aws cli installation:
Requirements:– Linux.
– Python 2.6.5 or higher.
[Tested on Linux Mint with bash shell. should work on Ubuntu as well.]
Update your system and its packages:
sudo apt update && sudo apt upgrade -y
Install Pip:
sudo apt install python-pip -y
sudo pip install --upgrade pip
Install the following modules:
sudo pip install setuptools
sudo pip install wheel
Install AWS CLI:
sudo pip install awscli
To verify that the installation went well, you can run the following command.
aws --version
If the output shows the aws version, then you are all set.
Enable AWS commands Auto completion:
-To enable auto completion of sub commands, run the following to check where your “aws” and “aws_completer” are located.
which aws
which aws_completer
-Copy the output of “which aws_completer”. This would the path.
Most used aws ec2 commands for shell scripts:
aws ec2 describe-instances
aws ec2 start-instances --instance-ids i-dddddd70
aws ec2 stop-instances --instance-ids i-5c8282ed
aws ec2 terminate-instances --dry-run --instance-ids i-dddddd70
aws ec2 create-tags --resources i-dddddd70 --tags Key=Department,Value=Finance
aws ec2 describe-volumes
aws ec2 attach-volume --volume-id vol-1d5cc8cc --instance-id i-dddddd70 --device /dev/sdh
aws ec2 run-instances --dry-run --image-id ami-08111162 --count 1 --instance-type t1.micro --key-name MyKeyPair --security-groups my-ami-security-group
aws ec2 reboot-instances --instance-ids i-dddddd70
aws ec2 modify-instance-attribute --instance-id i-44a44ac3 --instance-type "{\"Value\": \"m1.small\"}"
aws ec2 create-image --instance-id i-44a44ac3 --name "Dev AMI" --description "AMI for development server"
aws ec2 describe-images --image-ids ami-2d574747
aws ec2 deregister-image --image-id ami-2d574747 && aws ec2 delete-snapshot --snapshot-id snap-4e665454
aws ec2 delete-snapshot --snapshot-id snap-4e665454
aws ec2 modify-instance-attribute --instance-id i-44a44ac3 --disable-api-termination
aws ec2 modify-instance-attribute --instance-id i-44a44ac3 --no-disable-api-termination
aws ec2 get-console-output --instance-id i-44a44ac3
aws ec2 monitor-instances --instance-ids i-44a44ac3
aws ec2 unmonitor-instances --instance-ids i-44a44ac3
aws ec2 describe-key-pairs
aws ec2 create-key-pair --key-name dev-servers
aws ec2 delete-key-pair --key-name dev-servers
No comments:
Post a Comment