Install awscli locally. In this case with brew on a mac:

brew install awscli

Configure the cli:

aws configure

AWS Access Key ID: IAM credential with necessary access
AWS Secret Access Key: IAM credential with necessary access
Default region name: e.g. eu-west-1
Default output format [None]: Leave as none

Now export all instances in this region to csv file:

aws ec2 describe-instances --output text --query 'Reservations[*].Instances[*].[InstanceId, InstanceType, ImageId, State.Name, LaunchTime, Placement.AvailabilityZone, Placement.Tenancy, PrivateIpAddress, PrivateDnsName, PublicDnsName, [Tags[?Key==`Name`].Value] [0][0], [Tags[?Key==`purpose`].Value] [0][0], [Tags[?Key==`environment`].Value] [0][0], [Tags[?Key==`team`].Value] [0][0] ]' > instances.csv

Written by Matt Cooper
Hi, I'm Matt Cooper. I started this blog to pretty much act as a brain dump area for things I learn from day to day. You can contact me at: