Skip to content

aws ec2 describe

Show ec2 instances (list)
Bash
aws ec2 describe-instances --region=eu-west-1 --query '''Reservations[*].Instances[*].[InstanceId,Tags[?Key==`Name`].Value|[0],State.Name,PrivateIpAddress,PublicIpAddress]''' --output table
  • as alias
Bash
alias aws_show_instances='/usr/local/bin/aws ec2 describe-instances --region=eu-west-1 --query '\''Reservations[*].Instances[*].[InstanceId,Tags[?Key==`Name`].Value|[0],State.Name,PrivateIpAddress,PublicIpAddress]'\'' --output table'

Show name, public IP, status=running and type

Bash
aws ec2 describe-instances \
> --query "Reservations[*].Instances[*].{PublicIP:PublicIpAddress,Type:InstanceType,Name:Tags[?Key=='Name']|[0].Value,Status:State.Name}"  \
> --filters "Name=instance-state-name,Values=running" "Name=tag:Name,Values='*'"  \
> --output table

List all running instances based on the Instance Type. t2.medium, t2.large etc.

Bash
aws ec2 describe-instances \
--query "Reservations[*].Instances[*].{PublicIP:PublicIpAddress,Type:InstanceType,Name:Tags[?Key=='Name']|[0].Value,Status:State.Name}"  \
--filters "Name=instance-state-name,Values=running" "Name=instance-type,Values='*large*'" \
--output table

Show name, public IP, running, type and vpc

Bash
aws ec2 describe-instances \
--query "Reservations[*].Instances[*].{PublicIP:PublicIpAddress,PrivateIP:PrivateIpAddress,Name:Tags[?Key=='Name']| [0].Value,Type:InstanceType,Status:State.Name,VpcId:VpcId}" \
--filters Name=instance-state-name,Values=running \
--output table

A good one

Bash
aws ec2 describe-instances --query "Reservations[*].Instances[*].{PublicIP:PublicIpAddress,PrivateIP:PrivateIpAddress,Name:Tags[?Key=='Name']| [0].Value,Type:InstanceType,Status:State.Name,VpcId:VpcId}" --filters Name=instance-state-name,Values=* --output table