Skip to content

Instantly share code, notes, and snippets.

@sidewinder12s
Last active March 20, 2017 22:25
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sidewinder12s/2bc679e738d5eeec35fa0946d524f9aa to your computer and use it in GitHub Desktop.
Save sidewinder12s/2bc679e738d5eeec35fa0946d524f9aa to your computer and use it in GitHub Desktop.
Lists out instances that have been user shutdown. Display's Instance ID, Shutdown Date, Contact & Name tags.
aws ec2 describe-instances --region us-west-2 --output text --filters Name=state-reason-code,Values=Client.UserInitiatedShutdown --query 'sort_by(Reservations[*].Instances[], &StateTransitionReason)[*].[InstanceId,`,`, StateTransitionReason,`,`, [Tags[?Key==`Name`].Value] [0][0],`,`, [Tags[?Key==`Contact`].Value] [0][0] ]' > shutdown_instances.csv
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment