UPD: global resources are listed under us-east-1
This commit is contained in:
parent
102c2f9c9b
commit
048f81a315
@ -2,42 +2,44 @@
|
|||||||
|
|
||||||
|
|
||||||
function list-resources-in-region {
|
function list-resources-in-region {
|
||||||
export AWS_DEFAULT_REGION=$1
|
|
||||||
echo "---"
|
echo "---"
|
||||||
echo "# Region: $1"
|
echo "# Region: $1"
|
||||||
echo "---"
|
echo "---"
|
||||||
echo -e "\n## EC2:"
|
echo -e "\n## EC2:"
|
||||||
aws ec2 describe-instances --query 'Reservations[*].Instances[*].[InstanceId, Tags[?Key==`Name`].Value[] | [0], PlatformDetails, InstanceType,PrivateIpAddress]' --output json | jq -cr '.[][] | @tsv' | tr -d '[\" '
|
aws --region=$1 ec2 describe-instances --query 'Reservations[*].Instances[*].[InstanceId, Tags[?Key==`Name`].Value[] | [0], PlatformDetails, InstanceType,PrivateIpAddress]' --output json | jq -cr '.[][] | @tsv' | tr -d '[\" '
|
||||||
|
|
||||||
echo -e "\n## RDS:"
|
echo -e "\n## RDS:"
|
||||||
aws rds describe-db-instances --query 'DBInstances[*].[DBInstanceIdentifier, DBInstanceClass, Engine, AllocatedStorage]' --output json | jq -cr '.[]|@tsv' | tr -d \"
|
aws --region=$1 rds describe-db-instances --query 'DBInstances[*].[DBInstanceIdentifier, DBInstanceClass, Engine, AllocatedStorage]' --output json | jq -cr '.[]|@tsv' | tr -d \"
|
||||||
|
|
||||||
echo -e "\n## ElastiCache:"
|
echo -e "\n## ElastiCache:"
|
||||||
aws elasticache describe-cache-clusters --query 'CacheClusters[*].[CacheClusterId, CacheNodeType, Engine, EngineVersion]' --output json | jq -cr '.[]|@tsv' | tr -d \"
|
aws --region=$1 elasticache describe-cache-clusters --query 'CacheClusters[*].[CacheClusterId, CacheNodeType, Engine, EngineVersion]' --output json | jq -cr '.[]|@tsv' | tr -d \"
|
||||||
|
|
||||||
echo -e "\n## ELB:"
|
echo -e "\n## ELB:"
|
||||||
aws elb describe-load-balancers --query 'LoadBalancerDescriptions[*].[LoadBalancerName,DNSName,Scheme]' --output json | jq -cr '.[]|@tsv' | tr -d \"
|
aws --region=$1 elb describe-load-balancers --query 'LoadBalancerDescriptions[*].[LoadBalancerName,DNSName,Scheme]' --output json | jq -cr '.[]|@tsv' | tr -d \"
|
||||||
|
|
||||||
echo -e "\n## ALB:"
|
echo -e "\n## ALB:"
|
||||||
aws elbv2 describe-load-balancers --query 'LoadBalancers[*].[LoadBalancerName,DNSName,Scheme]' --output json | jq -cr '.[]|@tsv' | tr -d \"
|
aws --region=$1 elbv2 describe-load-balancers --query 'LoadBalancers[*].[LoadBalancerName,DNSName,Scheme]' --output json | jq -cr '.[]|@tsv' | tr -d \"
|
||||||
|
|
||||||
echo -e "\n## VPC:"
|
echo -e "\n## VPC:"
|
||||||
aws ec2 describe-vpcs --query 'Vpcs[*].[VpcId, CidrBlock]' --output json | jq -cr '.[]|@tsv' | tr -d \"
|
aws --region=$1 ec2 describe-vpcs --query 'Vpcs[*].[VpcId, CidrBlock]' --output json | jq -cr '.[]|@tsv' | tr -d \"
|
||||||
|
|
||||||
echo -e "\n## S3_Buckets:"
|
|
||||||
aws s3api list-buckets --output text | awk '{print $NF}'
|
|
||||||
|
|
||||||
echo -e "\n## ECS_Clusters:"
|
echo -e "\n## ECS_Clusters:"
|
||||||
aws ecs list-clusters | jq -cr '.[][]' | awk -F/ '{print $NF}'
|
aws --region=$1 ecs list-clusters | jq -cr '.[][]' | awk -F/ '{print $NF}'
|
||||||
|
|
||||||
echo -e "\n## EKS_Clusters:"
|
echo -e "\n## EKS_Clusters:"
|
||||||
aws eks list-clusters | jq '.[][]' | awk -F/ '{print $NF}'
|
aws --region=$1 eks list-clusters | jq '.[][]' | awk -F/ '{print $NF}'
|
||||||
|
|
||||||
echo -e "\n## Cloudfront:"
|
# global resources
|
||||||
aws cloudfront list-distributions --query 'DistributionList.Items[*].[DomainName]' --output text
|
if [ $1 == "us-east-1" ]; then
|
||||||
|
echo -e "\n## Route53_zones:"
|
||||||
|
aws --region=$1 --no-cli-pager route53 list-hosted-zones --query 'HostedZones[].Name' --output text | tr '\t' '\n'
|
||||||
|
|
||||||
echo -e "\n## Route53_zones:"
|
echo -e "\n## S3_Buckets:"
|
||||||
aws --no-cli-pager route53 list-hosted-zones --query 'HostedZones[].Name' --output text
|
aws --region=$1 s3api list-buckets --output text | awk '{print $NF}'
|
||||||
|
|
||||||
|
echo -e "\n## Cloudfront:"
|
||||||
|
aws --region=$1 cloudfront list-distributions --query 'DistributionList.Items[*].[DomainName]' --output text
|
||||||
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
# Generate inventory of ec2, rds, lb, and s3 buckets.
|
# Generate inventory of ec2, rds, lb, and s3 buckets.
|
||||||
|
Loading…
Reference in New Issue
Block a user