AWS Cli – Search EC2 instances by tag and state

 

To get the IP addresses of all instances with the "Application" tag and its value "Frontend", and also filter by state to display information about only those instances that are in the "running" state.

aws ec2 describe-instances --filter "Name=tag:Application,Values=Frontent" "Name=instance-state-name,Values=running" --query "Reservations[*].Instances[*][NetworkInterfaces[0].PrivateIpAddresses[0].PrivateIpAddress]" --output text

 

To display the name of the istans along with the IP address:

aws ec2 describe-instances --filter "Name=tag:Application,Values=Frontend" "Name=instance-state-name,Values=running" --query "Reservations[*].Instances[*][Tags[?Key=='Name'].Value[],NetworkInterfaces[0].PrivateIpAddresses[0].PrivateIpAddress]" --output text
0 0 vote
Article Rating

Tagged: Tags

Подписаться
Уведомление о
guest
0 Comments
Inline Feedbacks
View all comments