-
-
Save stafot/59bcb93457f96da3a49bb477b47f867a to your computer and use it in GitHub Desktop.
AWS CLI bash wrapper dot file
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
_warning(){ | |
echo -e "\e[31m${@}\e[0m" | |
} | |
_info(){ | |
echo -e $@ | |
} | |
_success(){ | |
echo -e "\e[32m${@}\e[0m" | |
} | |
aws_s3_buckets(){ | |
aws s3api list-buckets --query 'Buckets[].Name' --output table | |
} | |
aws_s3_list() { | |
if [ -z "$1" ]; then | |
_warning "Missing the bucket name"; | |
_info "usage: aws_s3_list <bucket_name>" | |
_info "to get bucket names run aws_s3_buckets" | |
return ; | |
fi | |
aws s3api list-objects --bucket $1 --query 'Contents[].{Key: Key, Size: Size, LastModified: LastModified}' --output table | |
} | |
aws_instance(){ | |
aws ec2 describe-instances \ | |
--no-paginate \ | |
--query "Reservations[].Instances[] \ | |
[\ | |
[Tags[?Key=='Name'].Value][0][0],\ | |
InstanceId,\ | |
PrivateIpAddress,\ | |
ImageId,\ | |
InstanceType,\ | |
State.Name,\ | |
Placement.AvailabilityZone, \ | |
[Tags[?Key=='Cluster'].Value][0][0] \ | |
]" --output table | |
} | |
aws_instance_details(){ | |
if [ -z "$1" ]; then | |
_warning "Missing Instance Id please run aws_instance to get the id"; | |
_info "You can pass more ids as <id> <id>" | |
return ; | |
fi | |
aws ec2 describe-instances \ | |
--output table \ | |
--instance-ids $@ | |
} | |
aws_instance_status(){ | |
if [ -z "$1" ]; then | |
_warning "Missing Instance Id please run aws_instance to get the id"; | |
_info "You can pass more ids as <id> <id>" | |
return ; | |
fi | |
aws ec2 describe-instances \ | |
--output table \ | |
--query "Reservations[].Instances[] \ | |
[\ | |
[Tags[?Key=='Name'].Value][0][0],\ | |
InstanceId,\ | |
PrivateIpAddress,\ | |
State.Name,\ | |
[Tags[?Key=='Cluster'].Value][0][0] \ | |
]" --output table \ | |
--instance-ids $@ | |
} | |
aws_rds(){ | |
aws rds describe-db-instances \ | |
--no-paginate \ | |
--query "DBInstances[] \ | |
[ \ | |
DBInstanceIdentifier,\ | |
Endpoint.Address, \ | |
DBInstanceClass, \ | |
DBInstanceStatus, \ | |
SubnetAvailabilityZone.Name, \ | |
DBInstanceArn \ | |
]" --output table | |
} | |
aws_sqs(){ | |
aws sqs list-queues \ | |
--no-paginate \ | |
--output table | |
} | |
aws_asg() { | |
aws autoscaling describe-auto-scaling-groups \ | |
--no-paginate \ | |
--query "AutoScalingGroups[] \ | |
[ \ | |
AutoScalingGroupName,\ | |
DesiredCapacity, \ | |
MaxSize, \ | |
MinSize, \ | |
join(' ', AvailabilityZones), \ | |
join(' ', Instances[].InstanceId) \ | |
]" \ | |
--output table | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment