Skip to content

Instantly share code, notes, and snippets.

@akinnard
Created January 29, 2017 21:51
Show Gist options
  • Save akinnard/2a0abd31dfad360ba8ba326f69eaa86e to your computer and use it in GitHub Desktop.
Save akinnard/2a0abd31dfad360ba8ba326f69eaa86e to your computer and use it in GitHub Desktop.
AWS bashrc alias commands
# list all instances that are not terminated, useful for greping for a server(s); aws-instance --profile myprofile | grep myserver
alias aws-instances="aws ec2 describe-instances --filters Name=instance-state-name,Values=running,pending,shutting-down,stopping,stopped --output table --query 'Reservations[].Instances[].{InstanceId:InstanceId,KeyName:KeyName,InstanceType:InstanceType,LaunchTime:LaunchTime,PrivateIpAddress:PrivateIpAddress,PublicIpAddress:PublicIpAddress, InstanceNameTag:Tags[?Key==\`Name\`].Value | [0], State:State.Name}'"
# list all ami's shared with your account
alias aws-images="aws ec2 describe-images --owners 99999999999999 --query 'Images[*].[Name,ImageId,CreationDate,Description]'"
# list all rds servers, just like aws-instances
alias aws-rds="aws rds describe-db-instances --query 'DBInstances[*].[DBInstanceIdentifier,DBInstanceClass,Engine,EngineVersion,AllocatedStorage,StorageType,DBInstanceStatus]' --output table"
# list all snap shots, usefull for grepping a specific rds server
alias aws-rds-snapshots="aws rds describe-db-snapshots --query 'DBSnapshots[*].[DBSnapshotIdentifier,DBInstanceIdentifier,Engine,EngineVersion,StorageType,AllocatedStorage,SnapshotType,Status,PercentProgress]' --output table"
# list all subnets, once again, useful for greping for a specific subnet
alias aws-subnets="aws ec2 describe-subnets --query 'Subnets[*].{az:AvailabilityZone,cdir:CidrBlock,subnet:SubnetId,vpc:VpcId,name:Tags[0].Value}' --output table"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment