@SuppressWarnings({ "static-access"}) @Test public void fetchS3InfoTest() throws Exception { mockStatic(AmazonS3ClientBuilder.class); AmazonS3 amazonS3Client = PowerMockito.mock(AmazonS3.class); AmazonS3ClientBuilder amazonRDSClientBuilder = PowerMockito.mock(AmazonS3ClientBuilder.class); AWSStaticCredentialsProvider awsStaticCredentialsProvider = PowerMockito.mock(AWSStaticCredentialsProvider.class); PowerMockito.whenNew(AWSStaticCredentialsProvider.class).withAnyArguments().thenReturn(awsStaticCredentialsProvider); when(amazonRDSClientBuilder.standard()).thenReturn(amazonRDSClientBuilder); when(amazonRDSClientBuilder.withCredentials(anyObject())).thenReturn(amazonRDSClientBuilder); when(amazonRDSClientBuilder.withRegion(anyString())).thenReturn(amazonRDSClientBuilder); when(amazonRDSClientBuilder.build()).thenReturn(amazonS3Client); List<Bucket> s3buckets = new ArrayList<>(); Bucket bucket = new Bucket(); bucket.setName("name"); s3buckets.add(bucket); when(amazonS3Client.listBuckets()).thenReturn(s3buckets); when(amazonS3Client.getBucketLocation(anyString())).thenReturn("bucketLocation"); mockStatic(com.amazonaws.services.s3.model.Region.class); com.amazonaws.services.s3.model.Region value = null; when(com.amazonaws.services.s3.model.Region.fromValue(anyString())).thenReturn(value.US_West); when(value.US_West.toAWSRegion()).thenReturn(getRegions().get(0)); when(amazonS3Client.getBucketVersioningConfiguration(anyString())).thenReturn(new BucketVersioningConfiguration()); BucketTaggingConfiguration tagConfig = new BucketTaggingConfiguration(); List<TagSet> tagSets = new ArrayList<>(); TagSet tagSet = new TagSet(); tagSet.setTag("key", "value"); tagSets.add(tagSet); tagSets.add(tagSet); tagConfig.setTagSets(tagSets); when(amazonS3Client.getBucketTaggingConfiguration(anyString())).thenReturn(tagConfig); assertThat(inventoryUtil.fetchS3Info(new BasicSessionCredentials("awsAccessKey", "awsSecretKey", "sessionToken"), "skipRegions", "account","accountName").size(), is(1)); }
public static Map<String,List<BucketVH>> fetchS3Info(BasicSessionCredentials temporaryCredentials, String skipRegions,String accountId,String accountName){ Map<String,List<BucketVH>> s3Map = new HashMap<>(); String expPrefix = InventoryConstants.ERROR_PREFIX_CODE+accountId + "\",\"Message\": \"Exception in fetching info for resource\" ,\"type\": \"S3\" , \"Bucket\":\"" ; AmazonS3 amazonS3Client ; List<BucketVH> buckets = new ArrayList<>(); amazonS3Client = AmazonS3ClientBuilder.standard().withCredentials(new AWSStaticCredentialsProvider(temporaryCredentials)).withRegion(InventoryConstants.REGION_US_WEST_2).build(); List<Bucket> s3buckets = amazonS3Client.listBuckets(); log.debug(InventoryConstants.ACCOUNT + accountId +" Type : S3 "+ " >> "+s3buckets.size()); Map<String,AmazonS3> regionS3map = new HashMap<>(); for(Region region : RegionUtils.getRegions()){ if(!skipRegions.contains(region.getName())){ regionS3map.put(region.getName(), AmazonS3ClientBuilder.standard().withCredentials(new AWSStaticCredentialsProvider(temporaryCredentials)).withRegion(region.getName()).build()); } } s3buckets.parallelStream().forEach(bucket -> { String bucketRegion =""; BucketLoggingConfiguration bucketLoggingConfiguration = null; BucketVersioningConfiguration versionconfig = null; List<Tag> tags = new ArrayList<>(); boolean hasWebSiteConfiguration = false; try{ String bucketLocation = amazonS3Client.getBucketLocation(bucket.getName()); bucketRegion = com.amazonaws.services.s3.model.Region.fromValue(bucketLocation).toAWSRegion().getName(); AmazonS3 s3Client = regionS3map.get(bucketRegion); versionconfig = s3Client.getBucketVersioningConfiguration(bucket.getName()); bucketLoggingConfiguration = s3Client.getBucketLoggingConfiguration(bucket.getName()); BucketTaggingConfiguration tagConfig = s3Client.getBucketTaggingConfiguration(bucket.getName()); if(tagConfig!=null){ List<TagSet> tagSets = tagConfig.getAllTagSets(); for(TagSet ts : tagSets){ Map<String,String> tagsTemp = ts.getAllTags(); Iterator<Entry<String,String>> it = tagsTemp.entrySet().iterator(); while(it.hasNext()){ Entry<String,String> tag = it.next(); tags.add(new Tag(tag.getKey(),tag.getValue())); } } } String bucketEncryp = fetchS3EncryptInfo(bucket, s3Client); BucketWebsiteConfiguration bucketWebsiteConfiguration = s3Client .getBucketWebsiteConfiguration(bucket.getName()); if(bucketWebsiteConfiguration!=null) { hasWebSiteConfiguration=true; } synchronized(buckets){ buckets.add(new BucketVH(bucket,bucketRegion,versionconfig, tags, bucketEncryp,hasWebSiteConfiguration,bucketLoggingConfiguration)); } } catch(AmazonS3Exception e){ if("AccessDenied".equals(e.getErrorCode())){ log.info("Access Denied for bucket " + bucket.getName()); buckets.add(new BucketVH(bucket,"",versionconfig, tags, null,hasWebSiteConfiguration,bucketLoggingConfiguration)); }else{ log.info("Exception fetching S3 Bucket",e); } } catch(Exception e){ log.warn(expPrefix+ bucket.getName()+InventoryConstants.ERROR_CAUSE +e.getMessage()+"\"}"); ErrorManageUtil.uploadError(accountId,"","s3",e.getMessage()); } }); log.debug(InventoryConstants.ACCOUNT + accountId +" Type : S3 >> "+buckets.size()); if(!buckets.isEmpty()){ s3Map.put(accountId+delimiter+accountName, buckets); } return s3Map; }
InventoryUtil { public static Map<String,List<BucketVH>> fetchS3Info(BasicSessionCredentials temporaryCredentials, String skipRegions,String accountId,String accountName){ Map<String,List<BucketVH>> s3Map = new HashMap<>(); String expPrefix = InventoryConstants.ERROR_PREFIX_CODE+accountId + "\",\"Message\": \"Exception in fetching info for resource\" ,\"type\": \"S3\" , \"Bucket\":\"" ; AmazonS3 amazonS3Client ; List<BucketVH> buckets = new ArrayList<>(); amazonS3Client = AmazonS3ClientBuilder.standard().withCredentials(new AWSStaticCredentialsProvider(temporaryCredentials)).withRegion(InventoryConstants.REGION_US_WEST_2).build(); List<Bucket> s3buckets = amazonS3Client.listBuckets(); log.debug(InventoryConstants.ACCOUNT + accountId +" Type : S3 "+ " >> "+s3buckets.size()); Map<String,AmazonS3> regionS3map = new HashMap<>(); for(Region region : RegionUtils.getRegions()){ if(!skipRegions.contains(region.getName())){ regionS3map.put(region.getName(), AmazonS3ClientBuilder.standard().withCredentials(new AWSStaticCredentialsProvider(temporaryCredentials)).withRegion(region.getName()).build()); } } s3buckets.parallelStream().forEach(bucket -> { String bucketRegion =""; BucketLoggingConfiguration bucketLoggingConfiguration = null; BucketVersioningConfiguration versionconfig = null; List<Tag> tags = new ArrayList<>(); boolean hasWebSiteConfiguration = false; try{ String bucketLocation = amazonS3Client.getBucketLocation(bucket.getName()); bucketRegion = com.amazonaws.services.s3.model.Region.fromValue(bucketLocation).toAWSRegion().getName(); AmazonS3 s3Client = regionS3map.get(bucketRegion); versionconfig = s3Client.getBucketVersioningConfiguration(bucket.getName()); bucketLoggingConfiguration = s3Client.getBucketLoggingConfiguration(bucket.getName()); BucketTaggingConfiguration tagConfig = s3Client.getBucketTaggingConfiguration(bucket.getName()); if(tagConfig!=null){ List<TagSet> tagSets = tagConfig.getAllTagSets(); for(TagSet ts : tagSets){ Map<String,String> tagsTemp = ts.getAllTags(); Iterator<Entry<String,String>> it = tagsTemp.entrySet().iterator(); while(it.hasNext()){ Entry<String,String> tag = it.next(); tags.add(new Tag(tag.getKey(),tag.getValue())); } } } String bucketEncryp = fetchS3EncryptInfo(bucket, s3Client); BucketWebsiteConfiguration bucketWebsiteConfiguration = s3Client .getBucketWebsiteConfiguration(bucket.getName()); if(bucketWebsiteConfiguration!=null) { hasWebSiteConfiguration=true; } synchronized(buckets){ buckets.add(new BucketVH(bucket,bucketRegion,versionconfig, tags, bucketEncryp,hasWebSiteConfiguration,bucketLoggingConfiguration)); } } catch(AmazonS3Exception e){ if("AccessDenied".equals(e.getErrorCode())){ log.info("Access Denied for bucket " + bucket.getName()); buckets.add(new BucketVH(bucket,"",versionconfig, tags, null,hasWebSiteConfiguration,bucketLoggingConfiguration)); }else{ log.info("Exception fetching S3 Bucket",e); } } catch(Exception e){ log.warn(expPrefix+ bucket.getName()+InventoryConstants.ERROR_CAUSE +e.getMessage()+"\"}"); ErrorManageUtil.uploadError(accountId,"","s3",e.getMessage()); } }); log.debug(InventoryConstants.ACCOUNT + accountId +" Type : S3 >> "+buckets.size()); if(!buckets.isEmpty()){ s3Map.put(accountId+delimiter+accountName, buckets); } return s3Map; } }
InventoryUtil { public static Map<String,List<BucketVH>> fetchS3Info(BasicSessionCredentials temporaryCredentials, String skipRegions,String accountId,String accountName){ Map<String,List<BucketVH>> s3Map = new HashMap<>(); String expPrefix = InventoryConstants.ERROR_PREFIX_CODE+accountId + "\",\"Message\": \"Exception in fetching info for resource\" ,\"type\": \"S3\" , \"Bucket\":\"" ; AmazonS3 amazonS3Client ; List<BucketVH> buckets = new ArrayList<>(); amazonS3Client = AmazonS3ClientBuilder.standard().withCredentials(new AWSStaticCredentialsProvider(temporaryCredentials)).withRegion(InventoryConstants.REGION_US_WEST_2).build(); List<Bucket> s3buckets = amazonS3Client.listBuckets(); log.debug(InventoryConstants.ACCOUNT + accountId +" Type : S3 "+ " >> "+s3buckets.size()); Map<String,AmazonS3> regionS3map = new HashMap<>(); for(Region region : RegionUtils.getRegions()){ if(!skipRegions.contains(region.getName())){ regionS3map.put(region.getName(), AmazonS3ClientBuilder.standard().withCredentials(new AWSStaticCredentialsProvider(temporaryCredentials)).withRegion(region.getName()).build()); } } s3buckets.parallelStream().forEach(bucket -> { String bucketRegion =""; BucketLoggingConfiguration bucketLoggingConfiguration = null; BucketVersioningConfiguration versionconfig = null; List<Tag> tags = new ArrayList<>(); boolean hasWebSiteConfiguration = false; try{ String bucketLocation = amazonS3Client.getBucketLocation(bucket.getName()); bucketRegion = com.amazonaws.services.s3.model.Region.fromValue(bucketLocation).toAWSRegion().getName(); AmazonS3 s3Client = regionS3map.get(bucketRegion); versionconfig = s3Client.getBucketVersioningConfiguration(bucket.getName()); bucketLoggingConfiguration = s3Client.getBucketLoggingConfiguration(bucket.getName()); BucketTaggingConfiguration tagConfig = s3Client.getBucketTaggingConfiguration(bucket.getName()); if(tagConfig!=null){ List<TagSet> tagSets = tagConfig.getAllTagSets(); for(TagSet ts : tagSets){ Map<String,String> tagsTemp = ts.getAllTags(); Iterator<Entry<String,String>> it = tagsTemp.entrySet().iterator(); while(it.hasNext()){ Entry<String,String> tag = it.next(); tags.add(new Tag(tag.getKey(),tag.getValue())); } } } String bucketEncryp = fetchS3EncryptInfo(bucket, s3Client); BucketWebsiteConfiguration bucketWebsiteConfiguration = s3Client .getBucketWebsiteConfiguration(bucket.getName()); if(bucketWebsiteConfiguration!=null) { hasWebSiteConfiguration=true; } synchronized(buckets){ buckets.add(new BucketVH(bucket,bucketRegion,versionconfig, tags, bucketEncryp,hasWebSiteConfiguration,bucketLoggingConfiguration)); } } catch(AmazonS3Exception e){ if("AccessDenied".equals(e.getErrorCode())){ log.info("Access Denied for bucket " + bucket.getName()); buckets.add(new BucketVH(bucket,"",versionconfig, tags, null,hasWebSiteConfiguration,bucketLoggingConfiguration)); }else{ log.info("Exception fetching S3 Bucket",e); } } catch(Exception e){ log.warn(expPrefix+ bucket.getName()+InventoryConstants.ERROR_CAUSE +e.getMessage()+"\"}"); ErrorManageUtil.uploadError(accountId,"","s3",e.getMessage()); } }); log.debug(InventoryConstants.ACCOUNT + accountId +" Type : S3 >> "+buckets.size()); if(!buckets.isEmpty()){ s3Map.put(accountId+delimiter+accountName, buckets); } return s3Map; } private  InventoryUtil(); }
InventoryUtil { public static Map<String,List<BucketVH>> fetchS3Info(BasicSessionCredentials temporaryCredentials, String skipRegions,String accountId,String accountName){ Map<String,List<BucketVH>> s3Map = new HashMap<>(); String expPrefix = InventoryConstants.ERROR_PREFIX_CODE+accountId + "\",\"Message\": \"Exception in fetching info for resource\" ,\"type\": \"S3\" , \"Bucket\":\"" ; AmazonS3 amazonS3Client ; List<BucketVH> buckets = new ArrayList<>(); amazonS3Client = AmazonS3ClientBuilder.standard().withCredentials(new AWSStaticCredentialsProvider(temporaryCredentials)).withRegion(InventoryConstants.REGION_US_WEST_2).build(); List<Bucket> s3buckets = amazonS3Client.listBuckets(); log.debug(InventoryConstants.ACCOUNT + accountId +" Type : S3 "+ " >> "+s3buckets.size()); Map<String,AmazonS3> regionS3map = new HashMap<>(); for(Region region : RegionUtils.getRegions()){ if(!skipRegions.contains(region.getName())){ regionS3map.put(region.getName(), AmazonS3ClientBuilder.standard().withCredentials(new AWSStaticCredentialsProvider(temporaryCredentials)).withRegion(region.getName()).build()); } } s3buckets.parallelStream().forEach(bucket -> { String bucketRegion =""; BucketLoggingConfiguration bucketLoggingConfiguration = null; BucketVersioningConfiguration versionconfig = null; List<Tag> tags = new ArrayList<>(); boolean hasWebSiteConfiguration = false; try{ String bucketLocation = amazonS3Client.getBucketLocation(bucket.getName()); bucketRegion = com.amazonaws.services.s3.model.Region.fromValue(bucketLocation).toAWSRegion().getName(); AmazonS3 s3Client = regionS3map.get(bucketRegion); versionconfig = s3Client.getBucketVersioningConfiguration(bucket.getName()); bucketLoggingConfiguration = s3Client.getBucketLoggingConfiguration(bucket.getName()); BucketTaggingConfiguration tagConfig = s3Client.getBucketTaggingConfiguration(bucket.getName()); if(tagConfig!=null){ List<TagSet> tagSets = tagConfig.getAllTagSets(); for(TagSet ts : tagSets){ Map<String,String> tagsTemp = ts.getAllTags(); Iterator<Entry<String,String>> it = tagsTemp.entrySet().iterator(); while(it.hasNext()){ Entry<String,String> tag = it.next(); tags.add(new Tag(tag.getKey(),tag.getValue())); } } } String bucketEncryp = fetchS3EncryptInfo(bucket, s3Client); BucketWebsiteConfiguration bucketWebsiteConfiguration = s3Client .getBucketWebsiteConfiguration(bucket.getName()); if(bucketWebsiteConfiguration!=null) { hasWebSiteConfiguration=true; } synchronized(buckets){ buckets.add(new BucketVH(bucket,bucketRegion,versionconfig, tags, bucketEncryp,hasWebSiteConfiguration,bucketLoggingConfiguration)); } } catch(AmazonS3Exception e){ if("AccessDenied".equals(e.getErrorCode())){ log.info("Access Denied for bucket " + bucket.getName()); buckets.add(new BucketVH(bucket,"",versionconfig, tags, null,hasWebSiteConfiguration,bucketLoggingConfiguration)); }else{ log.info("Exception fetching S3 Bucket",e); } } catch(Exception e){ log.warn(expPrefix+ bucket.getName()+InventoryConstants.ERROR_CAUSE +e.getMessage()+"\"}"); ErrorManageUtil.uploadError(accountId,"","s3",e.getMessage()); } }); log.debug(InventoryConstants.ACCOUNT + accountId +" Type : S3 >> "+buckets.size()); if(!buckets.isEmpty()){ s3Map.put(accountId+delimiter+accountName, buckets); } return s3Map; } private  InventoryUtil(); static Map<String,List<Instance>> fetchInstances(BasicSessionCredentials temporaryCredentials, String skipRegions,String accountId,String accountName,String ec2Filters); static Map<String,List<NetworkInterface>> fetchNetworkIntefaces(BasicSessionCredentials temporaryCredentials, String skipRegions,String accountId,String accountName); static Map<String,List<SecurityGroup>> fetchSecurityGroups(BasicSessionCredentials temporaryCredentials, String skipRegions,String accountId,String accountName); static Map<String,List<AutoScalingGroup>> fetchAsg(BasicSessionCredentials temporaryCredentials, String skipRegions,String accountId,String accountName); static Map<String,List<Stack>> fetchCloudFormationStack(BasicSessionCredentials temporaryCredentials, String skipRegions,String accountId,String accountName); static Map<String,List<DynamoVH>> fetchDynamoDBTables(BasicSessionCredentials temporaryCredentials, String skipRegions,String accountId,String accountName); static Map<String,List<EfsVH>> fetchEFSInfo(BasicSessionCredentials temporaryCredentials, String skipRegions,String accountId,String accountName); static Map<String,List<Cluster>> fetchEMRInfo(BasicSessionCredentials temporaryCredentials, String skipRegions,String accountId,String accountName); static Map<String,List<LambdaVH>> fetchLambdaInfo(BasicSessionCredentials temporaryCredentials, String skipRegions,String accountId,String accountName); static Map<String,List<ClassicELBVH>> fetchClassicElbInfo(BasicSessionCredentials temporaryCredentials, String skipRegions,String accountId,String accountName); static Map<String,List<LoadBalancerVH>> fetchElbInfo(BasicSessionCredentials temporaryCredentials, String skipRegions,String accountId,String accountName); static Map<String,List<TargetGroupVH>> fetchTargetGroups(BasicSessionCredentials temporaryCredentials, String skipRegions,String accountId,String accountName); static Map<String,List<NatGateway>> fetchNATGatewayInfo(BasicSessionCredentials temporaryCredentials, String skipRegions,String accountId,String accountName); static Map<String,List<DBClusterVH>> fetchRDSClusterInfo(BasicSessionCredentials temporaryCredentials, String skipRegions,String accountId,String accountName); static Map<String,List<DBInstanceVH>> fetchRDSInstanceInfo(BasicSessionCredentials temporaryCredentials, String skipRegions,String accountId,String accountName); static Map<String,List<BucketVH>> fetchS3Info(BasicSessionCredentials temporaryCredentials, String skipRegions,String accountId,String accountName); static Map<String,List<Subnet>> fetchSubnets(BasicSessionCredentials temporaryCredentials, String skipRegions,String accountId,String accountName); static Map<String,List<CheckVH>> fetchTrusterdAdvisorsChecks(BasicSessionCredentials temporaryCredentials,String accountId,String accountName ); static Map<String,List<RedshiftVH>> fetchRedshiftInfo(BasicSessionCredentials temporaryCredentials,String skipRegions,String accountId,String accountName); static Map<String,List<Volume>> fetchVolumetInfo(BasicSessionCredentials temporaryCredentials, String skipRegions,String accountId,String accountName); static Map<String,List<Snapshot>> fetchSnapshots(BasicSessionCredentials temporaryCredentials, String skipRegions,String accountId,String accountName); @SuppressWarnings("rawtypes") static Map<String,List<VpcVH>> fetchVpcInfo(BasicSessionCredentials temporaryCredentials, String skipRegions,String accountId,String accountName); static Map<String,List<RestApi>> fetchApiGateways(BasicSessionCredentials temporaryCredentials, String skipRegions,String accountId,String accountName); static Map<String,List<UserVH>> fetchIAMUsers(BasicSessionCredentials temporaryCredentials,String accountId,String accountName); static Map<String,List<Role>> fetchIAMRoles(BasicSessionCredentials temporaryCredentials,String accountId,String accountName); static Map<String,List<DBSnapshot>> fetchRDSDBSnapshots(BasicSessionCredentials temporaryCredentials, String skipRegions,String accountId,String accountName); static Map<String,List<KMSKeyVH>> fetchKMSKeys(BasicSessionCredentials temporaryCredentials, String skipRegions,String accountId,String accountName); static Map<String,List<CloudFrontVH>> fetchCloudFrontInfo(BasicSessionCredentials temporaryCredentials,String accountId,String accountName); static Map<String,List<EbsVH>> fetchEBSInfo(BasicSessionCredentials temporaryCredentials, String skipRegions,String accountId,String accountName); static Map<String,List<PhdVH>> fetchPHDInfo(BasicSessionCredentials temporaryCredentials,String accountId,String accountName); static Map<String,List<SQSVH>> fetchSQSInfo(BasicSessionCredentials temporaryCredentials, String skipRegions,String accountId,String accountName); static Map<String,List<SSLCertificateVH>> fetchACMCertficateInfo(BasicSessionCredentials temporaryCredentials, String skipRegions, String account, String accountName); static Map<String,List<IAMCertificateVH>> fetchIAMCertificateInfo(BasicSessionCredentials temporaryCredentials, String skipRegions, String account, String accountName); static Map<String,List<AccountVH>> fetchAccountsInfo(BasicSessionCredentials temporaryCredentials, String skipRegions,
			String account, String accountName); static Map<String,List<GroupVH>> fetchIAMGroups(BasicSessionCredentials temporaryCredentials,String account, String accountName); static Map<String,List<Trail>> fetchCloudTrails(BasicSessionCredentials temporaryCredentials, String skipRegions,String account, String accountName); }
InventoryUtil { public static Map<String,List<BucketVH>> fetchS3Info(BasicSessionCredentials temporaryCredentials, String skipRegions,String accountId,String accountName){ Map<String,List<BucketVH>> s3Map = new HashMap<>(); String expPrefix = InventoryConstants.ERROR_PREFIX_CODE+accountId + "\",\"Message\": \"Exception in fetching info for resource\" ,\"type\": \"S3\" , \"Bucket\":\"" ; AmazonS3 amazonS3Client ; List<BucketVH> buckets = new ArrayList<>(); amazonS3Client = AmazonS3ClientBuilder.standard().withCredentials(new AWSStaticCredentialsProvider(temporaryCredentials)).withRegion(InventoryConstants.REGION_US_WEST_2).build(); List<Bucket> s3buckets = amazonS3Client.listBuckets(); log.debug(InventoryConstants.ACCOUNT + accountId +" Type : S3 "+ " >> "+s3buckets.size()); Map<String,AmazonS3> regionS3map = new HashMap<>(); for(Region region : RegionUtils.getRegions()){ if(!skipRegions.contains(region.getName())){ regionS3map.put(region.getName(), AmazonS3ClientBuilder.standard().withCredentials(new AWSStaticCredentialsProvider(temporaryCredentials)).withRegion(region.getName()).build()); } } s3buckets.parallelStream().forEach(bucket -> { String bucketRegion =""; BucketLoggingConfiguration bucketLoggingConfiguration = null; BucketVersioningConfiguration versionconfig = null; List<Tag> tags = new ArrayList<>(); boolean hasWebSiteConfiguration = false; try{ String bucketLocation = amazonS3Client.getBucketLocation(bucket.getName()); bucketRegion = com.amazonaws.services.s3.model.Region.fromValue(bucketLocation).toAWSRegion().getName(); AmazonS3 s3Client = regionS3map.get(bucketRegion); versionconfig = s3Client.getBucketVersioningConfiguration(bucket.getName()); bucketLoggingConfiguration = s3Client.getBucketLoggingConfiguration(bucket.getName()); BucketTaggingConfiguration tagConfig = s3Client.getBucketTaggingConfiguration(bucket.getName()); if(tagConfig!=null){ List<TagSet> tagSets = tagConfig.getAllTagSets(); for(TagSet ts : tagSets){ Map<String,String> tagsTemp = ts.getAllTags(); Iterator<Entry<String,String>> it = tagsTemp.entrySet().iterator(); while(it.hasNext()){ Entry<String,String> tag = it.next(); tags.add(new Tag(tag.getKey(),tag.getValue())); } } } String bucketEncryp = fetchS3EncryptInfo(bucket, s3Client); BucketWebsiteConfiguration bucketWebsiteConfiguration = s3Client .getBucketWebsiteConfiguration(bucket.getName()); if(bucketWebsiteConfiguration!=null) { hasWebSiteConfiguration=true; } synchronized(buckets){ buckets.add(new BucketVH(bucket,bucketRegion,versionconfig, tags, bucketEncryp,hasWebSiteConfiguration,bucketLoggingConfiguration)); } } catch(AmazonS3Exception e){ if("AccessDenied".equals(e.getErrorCode())){ log.info("Access Denied for bucket " + bucket.getName()); buckets.add(new BucketVH(bucket,"",versionconfig, tags, null,hasWebSiteConfiguration,bucketLoggingConfiguration)); }else{ log.info("Exception fetching S3 Bucket",e); } } catch(Exception e){ log.warn(expPrefix+ bucket.getName()+InventoryConstants.ERROR_CAUSE +e.getMessage()+"\"}"); ErrorManageUtil.uploadError(accountId,"","s3",e.getMessage()); } }); log.debug(InventoryConstants.ACCOUNT + accountId +" Type : S3 >> "+buckets.size()); if(!buckets.isEmpty()){ s3Map.put(accountId+delimiter+accountName, buckets); } return s3Map; } private  InventoryUtil(); static Map<String,List<Instance>> fetchInstances(BasicSessionCredentials temporaryCredentials, String skipRegions,String accountId,String accountName,String ec2Filters); static Map<String,List<NetworkInterface>> fetchNetworkIntefaces(BasicSessionCredentials temporaryCredentials, String skipRegions,String accountId,String accountName); static Map<String,List<SecurityGroup>> fetchSecurityGroups(BasicSessionCredentials temporaryCredentials, String skipRegions,String accountId,String accountName); static Map<String,List<AutoScalingGroup>> fetchAsg(BasicSessionCredentials temporaryCredentials, String skipRegions,String accountId,String accountName); static Map<String,List<Stack>> fetchCloudFormationStack(BasicSessionCredentials temporaryCredentials, String skipRegions,String accountId,String accountName); static Map<String,List<DynamoVH>> fetchDynamoDBTables(BasicSessionCredentials temporaryCredentials, String skipRegions,String accountId,String accountName); static Map<String,List<EfsVH>> fetchEFSInfo(BasicSessionCredentials temporaryCredentials, String skipRegions,String accountId,String accountName); static Map<String,List<Cluster>> fetchEMRInfo(BasicSessionCredentials temporaryCredentials, String skipRegions,String accountId,String accountName); static Map<String,List<LambdaVH>> fetchLambdaInfo(BasicSessionCredentials temporaryCredentials, String skipRegions,String accountId,String accountName); static Map<String,List<ClassicELBVH>> fetchClassicElbInfo(BasicSessionCredentials temporaryCredentials, String skipRegions,String accountId,String accountName); static Map<String,List<LoadBalancerVH>> fetchElbInfo(BasicSessionCredentials temporaryCredentials, String skipRegions,String accountId,String accountName); static Map<String,List<TargetGroupVH>> fetchTargetGroups(BasicSessionCredentials temporaryCredentials, String skipRegions,String accountId,String accountName); static Map<String,List<NatGateway>> fetchNATGatewayInfo(BasicSessionCredentials temporaryCredentials, String skipRegions,String accountId,String accountName); static Map<String,List<DBClusterVH>> fetchRDSClusterInfo(BasicSessionCredentials temporaryCredentials, String skipRegions,String accountId,String accountName); static Map<String,List<DBInstanceVH>> fetchRDSInstanceInfo(BasicSessionCredentials temporaryCredentials, String skipRegions,String accountId,String accountName); static Map<String,List<BucketVH>> fetchS3Info(BasicSessionCredentials temporaryCredentials, String skipRegions,String accountId,String accountName); static Map<String,List<Subnet>> fetchSubnets(BasicSessionCredentials temporaryCredentials, String skipRegions,String accountId,String accountName); static Map<String,List<CheckVH>> fetchTrusterdAdvisorsChecks(BasicSessionCredentials temporaryCredentials,String accountId,String accountName ); static Map<String,List<RedshiftVH>> fetchRedshiftInfo(BasicSessionCredentials temporaryCredentials,String skipRegions,String accountId,String accountName); static Map<String,List<Volume>> fetchVolumetInfo(BasicSessionCredentials temporaryCredentials, String skipRegions,String accountId,String accountName); static Map<String,List<Snapshot>> fetchSnapshots(BasicSessionCredentials temporaryCredentials, String skipRegions,String accountId,String accountName); @SuppressWarnings("rawtypes") static Map<String,List<VpcVH>> fetchVpcInfo(BasicSessionCredentials temporaryCredentials, String skipRegions,String accountId,String accountName); static Map<String,List<RestApi>> fetchApiGateways(BasicSessionCredentials temporaryCredentials, String skipRegions,String accountId,String accountName); static Map<String,List<UserVH>> fetchIAMUsers(BasicSessionCredentials temporaryCredentials,String accountId,String accountName); static Map<String,List<Role>> fetchIAMRoles(BasicSessionCredentials temporaryCredentials,String accountId,String accountName); static Map<String,List<DBSnapshot>> fetchRDSDBSnapshots(BasicSessionCredentials temporaryCredentials, String skipRegions,String accountId,String accountName); static Map<String,List<KMSKeyVH>> fetchKMSKeys(BasicSessionCredentials temporaryCredentials, String skipRegions,String accountId,String accountName); static Map<String,List<CloudFrontVH>> fetchCloudFrontInfo(BasicSessionCredentials temporaryCredentials,String accountId,String accountName); static Map<String,List<EbsVH>> fetchEBSInfo(BasicSessionCredentials temporaryCredentials, String skipRegions,String accountId,String accountName); static Map<String,List<PhdVH>> fetchPHDInfo(BasicSessionCredentials temporaryCredentials,String accountId,String accountName); static Map<String,List<SQSVH>> fetchSQSInfo(BasicSessionCredentials temporaryCredentials, String skipRegions,String accountId,String accountName); static Map<String,List<SSLCertificateVH>> fetchACMCertficateInfo(BasicSessionCredentials temporaryCredentials, String skipRegions, String account, String accountName); static Map<String,List<IAMCertificateVH>> fetchIAMCertificateInfo(BasicSessionCredentials temporaryCredentials, String skipRegions, String account, String accountName); static Map<String,List<AccountVH>> fetchAccountsInfo(BasicSessionCredentials temporaryCredentials, String skipRegions,
			String account, String accountName); static Map<String,List<GroupVH>> fetchIAMGroups(BasicSessionCredentials temporaryCredentials,String account, String accountName); static Map<String,List<Trail>> fetchCloudTrails(BasicSessionCredentials temporaryCredentials, String skipRegions,String account, String accountName);  }