本文整理汇总了Java中com.amazonaws.services.rds.AmazonRDSClient.describeDBInstances方法的典型用法代码示例。如果您正苦于以下问题:Java AmazonRDSClient.describeDBInstances方法的具体用法?Java AmazonRDSClient.describeDBInstances怎么用?Java AmazonRDSClient.describeDBInstances使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.amazonaws.services.rds.AmazonRDSClient
的用法示例。
在下文中一共展示了AmazonRDSClient.describeDBInstances方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getDbInstance
import com.amazonaws.services.rds.AmazonRDSClient; //导入方法依赖的package包/类
private static DBInstance getDbInstance(final AmazonRDSClient amazonRds, final String rdsInstanceId) {
try {
final DescribeDBInstancesRequest request = new DescribeDBInstancesRequest()
.withDBInstanceIdentifier(rdsInstanceId);
final DescribeDBInstancesResult response = amazonRds.describeDBInstances(request);
return response.getDBInstances().get(0);
} catch (DBInstanceNotFoundException e) {
throw new IllegalStateException("Could not find DB instance!");
}
}
示例2: run
import com.amazonaws.services.rds.AmazonRDSClient; //导入方法依赖的package包/类
@Scheduled(fixedRate = 300_000)
public void run() {
for (final String accountId : allAccountIds.get()) {
for (final String region : jobsProperties.getWhitelistedRegions()) {
try {
final AmazonRDSClient amazonRDSClient = clientProvider.getClient(AmazonRDSClient.class, accountId,
Region.getRegion(Regions.fromName(region)));
Optional<String> marker = Optional.empty();
do {
final DescribeDBInstancesRequest request = new DescribeDBInstancesRequest();
marker.ifPresent(request::setMarker);
final DescribeDBInstancesResult result = amazonRDSClient.describeDBInstances(request);
marker = Optional.ofNullable(trimToNull(result.getMarker()));
result.getDBInstances().stream()
.filter(DBInstance::getPubliclyAccessible)
.filter(dbInstance -> dbInstance.getEndpoint() != null)
.forEach(dbInstance -> {
final Map<String, Object> metadata = newHashMap();
metadata.put("unsecuredDatabase", dbInstance.getEndpoint().getAddress());
metadata.put("errorMessages", "Unsecured Database! Your DB can be reached from outside");
writeViolation(accountId, region, metadata, dbInstance.getEndpoint().getAddress());
});
} while (marker.isPresent());
} catch (final Exception e) {
jobExceptionHandler.onException(e, ImmutableMap.of(
"job", this.getClass().getSimpleName(),
"aws_account_id", accountId,
"aws_region", region));
}
}
}
}