Installation:
curl "https://awscli.amazonaws.com/awscli-exe-linux-x86_64.zip" -o "awscliv2.zip"
unzip awscliv2.zip
sudo ./aws/install
Configuration:
# aws configure
//ENter the access key and Secret access. Also the default region from AWS
(Profile > Security Credentials > Access Key ID and Secret Key> Create New Access Key > Download Key File > )
Commands:
aws --version
aws help //to get the general documentation of aws commands
aws ec2 describe-instances --- To list all Ec2 instances available in this region
Steps for launching EC2 instance:
Create Keypair
Create security group
Allowing inbound connections for needed protocols like SSH and HTTPD
Launching instance with the keypair and security groups that we crated
1.Create Keypair
aws ec2 create-security-group --group-name MySG --description "allow http and ssh"
2) Create Security Group
aws ec2 create-security-group --group-name MySG --description "allow http and ssh"
3) Allowing both ssh and HTTP:
aws ec2 authorize-security-group-ingress --group-name MySG --protocol tcp --port 22 --cidr 0.0.0.0/0
aws ec2 authorize-security-group-ingress --group-name MySG --protocol tcp --port 80 --cidr 0.0.0.0/0
4) Launching the instance with the key pair and security group we made:
aws ec2 run-instances --image-id ami-045137e8d34668746 --count 1 --instance-type t2.micro --key-name mykey --security-group-ids sg-0d812a01b8ee0f5eb --tag-specifications 'ResourceType=instance,Tags=[{Key=Name,Value=myos}]'