code-dumps/aws/aws-inventory.sh
2021-11-29 16:33:17 +08:00

34 lines
1.2 KiB
Bash
Executable File

#!/bin/bash
# Generate inventory of ec2, rds, lb, and s3 buckets.
echo "# EC2"
aws ec2 describe-instances --query 'Reservations[*].Instances[*].[InstanceId, Tags[?Key==`Name`].Value[] | [0], Platform, InstanceType]' --output text | nl
echo "# RDS"
aws rds describe-db-instances --query 'DBInstances[*].[DBInstanceIdentifier, DBInstanceClass, Engine, AllocatedStorage]' --output text | nl
echo "# elasticache"
aws elasticache describe-cache-clusters --query 'CacheClusters[*].[CacheClusterId, CacheNodeType, Engine, EngineVersion]' --output text | nl
echo "# LB"
aws elb describe-load-balancers --query 'LoadBalancerDescriptions[*].[LoadBalancerName,Scheme]' --output text | nl
echo "# VPC"
aws ec2 describe-vpcs --query 'Vpcs[*].[VpcId, CidrBlock]' --output text | nl
echo "# S3buckets"
aws s3api list-buckets --output text | awk '{print $NF}' | nl
echo "# ECS"
aws ecs list-clusters | jq -cr '.[][]' | awk -F/ '{print $NF}' | nl
echo "# EKS"
aws eks list-clusters | jq '.[][]' | awk -F/ '{print $NF}' | nl
echo "# CloudFront"
aws cloudfront list-distributions --query 'DistributionList.Items[*].[DomainName]' --output text | nl
echo "# IAM roles"
aws iam list-roles | jq -cr '.Roles[] | .RoleName' | grep -v AWSServiceRoleFor | nl