SortedFilteredEc2InstancesByName

nicolaw 29th February 2024 at 12:51pm
awscli
aws ec2 describe-instances --filter "Name=instance-state-name,Values=running" "Name=tag:aws:cloudformation:stack-id,Values=*" --query "Reservations[*].Instances[*].[PrivateIpAddress, InstanceType, Tags[?Key=='Name']|[0].Value]|sort_by(@, &@[0][2])" --output text
10.11.1.6	c6i.2xlarge	demo-client
10.11.1.9	i3en.12xlarge	demo
10.11.1.92	i3en.xlarge	foo
10.11.1.173	i3en.large	nightwatch
10.11.1.225	i3en.6xlarge	prod-1
10.11.1.135	m5d.large	prod-2
10.11.1.144	i3en.6xlarge	prod-3
10.11.1.209	i3en.6xlarge	prod-4
10.11.1.114	c6i.4xlarge	prod-client