From 94776e997f09979ca09ab6435671dc683241edc0 Mon Sep 17 00:00:00 2001 From: x p k Date: Thu, 24 Aug 2023 08:41:14 +0800 Subject: [PATCH] NEW: aws inventory script using config as data source --- aws/aws-inventory3.sh | 11 +++++++++++ 1 file changed, 11 insertions(+) create mode 100755 aws/aws-inventory3.sh diff --git a/aws/aws-inventory3.sh b/aws/aws-inventory3.sh new file mode 100755 index 0000000..950755c --- /dev/null +++ b/aws/aws-inventory3.sh @@ -0,0 +1,11 @@ +#!/bin/bash + +exclude_services=("AWS::AppConfig::DeploymentStrategy" "AWS::Athena::WorkGroup" "AWS::Cassandra::Keyspace" "AWS::CloudWatch::Alarm" "AWS::CodeDeploy::DeploymentConfig" "AWS::Config::ResourceCompliance" "AWS::EC2::DHCPOptions" "AWS::EC2::EC2Fleet" "AWS::EC2::LaunchTemplate" "AWS::EC2::NetworkAcl" "AWS::EC2::NetworkInsightsPath" "AWS::EC2::RouteTable" "AWS::EC2::SubnetRouteTableAssociation" "AWS::EventSchemas::Registry" "AWS::IAM::Policy" "AWS::RDS::DBSubnetGroup" "AWS::S3::AccountPublicAccessBlock" "AWS::Route53Resolver::ResolverRuleAssociation" "AWS::Route53Resolver::ResolverRule" "AWS::EC2::FlowLog" "AWS::Events::Rule" "AWS::SecretsManager::Secret" "AWS::SSM::PatchCompliance" "AWS::SSM::ManagedInstanceInventory" "AWS::SSM::AssociationCompliance" "AWS::IAM::Role" "AWS::RDS::DBSnapshot" "AWS::EC2::NetworkInterface" "AWS::Backup::RecoveryPoint" "AWS::Route53Resolver::ResolverRuleAssociation" "AWS::Events::EventBus" "AWS::GuardDuty::IPSet" "AWS::Config::ConfigurationRecorder" "AWS::Backup::BackupSelection" "AWS::KMS::Key" ) + +aws configservice get-discovered-resource-counts | jq -cr '.resourceCounts[] | .resourceType' | while read r; do +if [[ " ${exclude_services[@]} " =~ "${r}" ]]; then + continue +fi +echo "* $r" +aws configservice list-discovered-resources --resource-type $r | jq -cr '.resourceIdentifiers[] | .resourceId' | nl +done