Installation and configuration:
Package installation:
apt-get install awscli
configuration:
aws configure
OR configure for another user profile.
aws configire --profile
List configuration:
aws configure list
OR
aws configure list --profile <profile-name>
Set default region for specific profile:
aws configure set region eu-west-1 --profile <profile-name>
EC2 Instance:
List all available instance type:
aws ec2 describe-instance-type --query "InstanceTypes[*].[InstanceType]" --output text
All instance information fetch:
aws ec2 describe-instances
Get all Active AWS Regions:
aws ec2 describe-regions
aws ec2 describe-regions --query "Regions[*].[RegionName]" --output text
List instance from specific region:
aws ec2 describe-instances --region eu-west-1
List LiveIP, InstanceID and Instance name:
aws ec2 describe-instances --query 'Reservations[*].Instances[*].{Instance:InstanceId,Name:Tags[?Key==`Name`]|[0].Value,IP:PublicIpAddress}' --output text
Start instance:
aws ec2 start-instances --instance-ids <instance-id>
aws ec2 start-instances --region us-east-1 --instance-ids <instance-id>
Stop Instance:
aws ec2 stop-instances --instance-ids <instance-id>
Terminate instance:
aws ec2 terminate-instances --region us-east-1 --instance-ids <instance-id>
Elastic IP:
aws ec2 describe-addresses
List in text format:
aws ec2 describe-addresses --query "Addresses[*].[PublicIp]" --output text
From Specific Region:
aws ec2 describe-addresses --query "Addresses[*].[PublicIp]" --region us-west-1 --output text
server name and IP address:
aws ec2 describe-instances --query 'Reservations[*].Instances[*].{Name:Tags[?Key==`Name`]|[0].Value,IP:PublicIpAddress}' | jq '.[]' | jq '.[]' | sed -e 's/null/\"null\"/g' | jq -r '.Name+"="+.IP'
AWS Images:
aws ec2 describe-images
aws ec2 describe-images --query "Images[*].{Image:ImageId,Name:Name}" --output text
Subnets:
aws ec2 describe-subnets
aws ec2 describe-subnets --query "Subnets[*].[SubnetId]" --output text
aws ec2 describe-subnets –region ap-south-1 --query "Subnets[*].[SubnetId]" --output text
aws ec2 describe-subnets --region ap-south-1 --query "Subnets[*].{AvailabilityZone:AvailabilityZone,Subnets:SubnetId}" --output text
Security Group:
Create:
aws ec2 create-security-group \
--group-name arth-aws-allowall \
--description "Allow all traffic for arth aws security group" aws ec2 describe-security-groups
Get list of security groups with specific region:
aws ec2 describe-security-groups --query "SecurityGroups[*].{id:GroupId,Name:GroupName}" --output text
Get inbound ports of specific security group:
aws ec2 describe-security-groups --group-ids sg-xxxxxxxxxxxxxxxxx --query 'SecurityGroups[0].IpPermissions[?IpProtocol==`tcp`].{InboundPorts: ToPort}' --output table
Get inbound ports with CIDR IP’s:
aws ec2 describe-security-groups --group-ids sg-04aarrdefe4366fc5 --query 'SecurityGroups[0].IpPermissions[?IpProtocol==`tcp`].{InboundPorts: ToPort, CIDR: IpRanges[].CidrIp}' --output json
Add Rules to Security group:
aws ec2 authorize-security-group-ingress --group-id sg-0807d7349c453839b --protocol tcp --port 5511-5512 --cidr 0.0.0.0/0
Keypair:
Create:
aws ec2 create-key-pair --key-name MyArthKey
List:
aws ec2 describe-key-pairs
aws ec2 describe-key-pairs --query "KeyPairs[*].[KeyName]" --output text
No comments:
Post a Comment