UPD: touch up format
This commit is contained in:
parent
9bcfeeba31
commit
c864e0f394
@ -1,37 +1,34 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
|
function formatprint() {
|
||||||
|
cat - > /tmp/formatprint.tmp
|
||||||
|
echo "# $1 ($(cat /tmp/formatprint.tmp | wc -l))"
|
||||||
|
cat /tmp/formatprint.tmp | sed -e 's/^/ /g'
|
||||||
|
rm -f /tmp/formatprint.tmp
|
||||||
|
}
|
||||||
|
|
||||||
# Generate inventory of ec2, rds, lb, and s3 buckets.
|
# Generate inventory of ec2, rds, lb, and s3 buckets.
|
||||||
|
|
||||||
echo "# EC2"
|
aws ec2 describe-instances --query 'Reservations[*].Instances[*].[InstanceId, Tags[?Key==`Name`].Value[] | [0], PlatformDetails, InstanceType,PrivateIpAddress]' --output json | jq -cr '.[][] | @csv' | tr -d '[\" ' | formatprint EC2
|
||||||
aws ec2 describe-instances --query 'Reservations[*].Instances[*].[InstanceId, Tags[?Key==`Name`].Value[] | [0], PlatformDetails, InstanceType]' --output json | jq -cr '.[][] | @csv' | tr -d '[\" '
|
|
||||||
|
|
||||||
echo "# RDS"
|
aws rds describe-db-instances --query 'DBInstances[*].[DBInstanceIdentifier, DBInstanceClass, Engine, AllocatedStorage]' --output json | jq -cr '.[]|@csv' | tr -d \" | formatprint RDS
|
||||||
aws rds describe-db-instances --query 'DBInstances[*].[DBInstanceIdentifier, DBInstanceClass, Engine, AllocatedStorage]' --output json | jq -cr '.[]|@csv' | tr -d \"
|
|
||||||
|
|
||||||
echo "# elasticache"
|
aws elasticache describe-cache-clusters --query 'CacheClusters[*].[CacheClusterId, CacheNodeType, Engine, EngineVersion]' --output json | jq -cr '.[]|@csv' | tr -d \" | formatprint ElastiCache
|
||||||
aws elasticache describe-cache-clusters --query 'CacheClusters[*].[CacheClusterId, CacheNodeType, Engine, EngineVersion]' --output json | jq -cr '.[]|@csv' | tr -d \"
|
|
||||||
|
|
||||||
echo "# LB"
|
aws elb describe-load-balancers --query 'LoadBalancerDescriptions[*].[LoadBalancerName,DNSName,Scheme]' --output json | jq -cr '.[]|@csv' | tr -d \" | formatprint ELB
|
||||||
aws elb describe-load-balancers --query 'LoadBalancerDescriptions[*].[LoadBalancerName,DNSName,Scheme]' --output json | jq -cr '.[]|@csv' | tr -d \"
|
aws elbv2 describe-load-balancers --query 'LoadBalancers[*].[LoadBalancerName,DNSName,Scheme]' --output json | jq -cr '.[]|@csv' | tr -d \" | formatprint ALB
|
||||||
aws elbv2 describe-load-balancers --query 'LoadBalancers[*].[LoadBalancerName,DNSName,Scheme]' --output json | jq -cr '.[]|@csv' | tr -d \"
|
|
||||||
|
|
||||||
echo "# VPC"
|
aws ec2 describe-vpcs --query 'Vpcs[*].[VpcId, CidrBlock]' --output json | jq -cr '.[]|@csv' | tr -d \" | formatprint VPC
|
||||||
aws ec2 describe-vpcs --query 'Vpcs[*].[VpcId, CidrBlock]' --output json | jq -cr '.[]|@csv' | tr -d \"
|
|
||||||
|
|
||||||
echo "# S3buckets"
|
aws s3api list-buckets --output text | awk '{print $NF}' | formatprint S3Bucket
|
||||||
aws s3api list-buckets --output text | awk '{print $NF}'
|
|
||||||
|
|
||||||
echo "# ECS"
|
aws ecs list-clusters | jq -cr '.[][]' | awk -F/ '{print $NF}' | formatprint ECS
|
||||||
aws ecs list-clusters | jq -cr '.[][]' | awk -F/ '{print $NF}'
|
|
||||||
|
|
||||||
echo "# EKS"
|
aws eks list-clusters | jq '.[][]' | awk -F/ '{print $NF}' | formatprint EKS
|
||||||
aws eks list-clusters | jq '.[][]' | awk -F/ '{print $NF}'
|
|
||||||
|
|
||||||
echo "# CloudFront"
|
aws cloudfront list-distributions --query 'DistributionList.Items[*].[DomainName]' --output text | formatprint CloudFront
|
||||||
aws cloudfront list-distributions --query 'DistributionList.Items[*].[DomainName]' --output text
|
|
||||||
|
|
||||||
echo "# Route53Zones-RecordCount"
|
aws --no-cli-pager route53 list-hosted-zones --query 'HostedZones[*].[Name,ResourceRecordSetCount]' --output json | jq -cr '.[]|@csv' | tr -d \" | sort -k1 | formatprint R53-RecordCount
|
||||||
aws --no-cli-pager route53 list-hosted-zones --query 'HostedZones[*].[Name,ResourceRecordSetCount]' --output json | jq -cr '.[]|@csv' | tr -d \" | sort -k1
|
|
||||||
|
|
||||||
echo "# IAM roles"
|
# echo "# IAM roles"
|
||||||
aws iam list-roles | jq -cr '.Roles[] | .RoleName' | grep -v AWSServiceRoleFor
|
# aws iam list-roles | jq -cr '.Roles[] | .RoleName' | grep -v AWSServiceRoleFor
|
||||||
|
Loading…
Reference in New Issue
Block a user