AWS CLI

steps for aws auto complete 

1. which aws_completer

2. complete -C '/Library/Python/3.6/bin/aws_completer' aws

Quick Reference on aws cli commands:

list all the s3 buckets

aws s3 ls

List ec2  instance details by name

aws ec2 describe-instances –filters "Name=tag:Name,Values=*myinstance*" –region us-east-1

to further filter to instance id's only

aws ec2 describe-instances –filters "Name=tag:Name,Values=*myinstance*" –output text –query 'Reservations[*].Instances[*].InstanceId' –region us-east-1

to display aws cli result of ec2 instance name, private ip and instanceId

aws ec2 describe-instances –filters "Name=tag:Name,Values=*myinstance*" –output text –query 'Reservations[*].Instances[*].[PrivateIpAddress,InstanceId,Tags[?Key==`Name`].Value]' –region us-east-1

to display aws cli result in json format

aws ec2 describe-instances –filters "Name=tag:Name,Values=*myinstance*" –output json –query 'Reservations[*].Instances[*].[PrivateIpAddress,InstanceId,Tags[?Key==`Name`].Value]' –region us-east-1

aws ec2 describe-instances –filters "Name=tag:Name,Values=*propensity*" –output json –query 'Reservations[*].Instances[*].[ImageId,PrivateIpAddress,InstanceId,Tags[?Key==`Name`],Tags[?Key==`ASV`]]' –region us-west-2

——- To terminate/delete ASG(auto scalling group), ELB(Elastic load balancer), EC2 and Launch Configuration through CLI, 

aws elb delete-load-balancer –load-balancer-name {instance-name} –region us-west-2
aws ec2 terminate-instances –instance-ids {instance-id} –region us-west-2
aws autoscaling delete-auto-scaling-group –auto-scaling-group-name {instance-name} –region us-west-2
aws autoscaling delete-launch-configuration –launch-configuration-name {instance-name}  –region us-west-2

 

Leave a Reply

Your email address will not be published. Required fields are marked *