当前位置: 首页>>代码示例>>Java>>正文


Java AmazonRDSClient.describeDBInstances方法代码示例

本文整理汇总了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!");
    }
}
 
开发者ID:suomenriistakeskus,项目名称:oma-riista-web,代码行数:13,代码来源:DataSourceProperties.java

示例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));
            }
        }
    }
}
 
开发者ID:zalando-stups,项目名称:fullstop,代码行数:39,代码来源:FetchRdsJob.java


注:本文中的com.amazonaws.services.rds.AmazonRDSClient.describeDBInstances方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。