17 lines
717 B
Bash
Executable File
17 lines
717 B
Bash
Executable File
#!/bin/bash
|
|
|
|
function formatprint() {
|
|
cat - > /tmp/formatprint.tmp
|
|
echo "# $1 ($(cat /tmp/formatprint.tmp | wc -l))"
|
|
#cat /tmp/formatprint.tmp | sed -e 's/^/ /g'
|
|
cat /tmp/formatprint.tmp | column -t -s, | sed -e 's/^/ /g'
|
|
rm -f /tmp/formatprint.tmp
|
|
}
|
|
|
|
# Generate inventory of ec2 in all regions
|
|
|
|
aws --region=us-east-1 ec2 describe-regions --query Regions[].RegionName --output text | sed -e 's/\t/\n/g' | while read r; do
|
|
echo "Region: $r"
|
|
aws --region=$r ec2 describe-instances --query 'Reservations[*].Instances[*].[InstanceId, Tags[?Key==`Name`].Value[] | [0], PlatformDetails, InstanceType,PrivateIpAddress, PublicIpAddress]' --output json | jq -cr '.[][] | @csv' | tr -d '[\" ' | formatprint EC2
|
|
done
|