List of usage examples for com.amazonaws.services.route53 AmazonRoute53 getHostedZone
GetHostedZoneResult getHostedZone(GetHostedZoneRequest getHostedZoneRequest);
Gets information about a specified hosted zone including the four name servers assigned to the hosted zone.
From source file:com.oneops.inductor.AbstractOrderExecutor.java
License:Apache License
/** * Gets dns servers/* www . java 2 s. c o m*/ * * @param awsCredentials AWSCredentials * @param zoneDomainName zoneDomainName * @return dns servers */ private List<String> getAuthoritativeServersWithAwsCreds(AWSCredentials awsCredentials, String zoneDomainName) { if (!zoneDomainName.endsWith(".")) { zoneDomainName += "."; } AmazonRoute53 route53 = new AmazonRoute53Client(awsCredentials); ListHostedZonesResult result = route53.listHostedZones(); List<HostedZone> zones = result.getHostedZones(); List<String> dnsServers = new ArrayList<String>(); for (int i = 0; i < zones.size(); i++) { HostedZone hostedZone = zones.get(i); logger.info("zone: " + hostedZone.getName()); if (hostedZone.getName().equalsIgnoreCase(zoneDomainName)) { logger.info("matched zone"); GetHostedZoneResult zone = route53.getHostedZone( new GetHostedZoneRequest().withId(hostedZone.getId().replace("/hostedzone/", ""))); DelegationSet delegationSet = zone.getDelegationSet(); dnsServers = delegationSet.getNameServers(); break; } } logger.info("dnsServer: " + dnsServers.toString()); return dnsServers; }
From source file:org.ofbiz.tenant.amazonaws.AwsServices.java
License:Apache License
/** * get Amazon Rout53 hosted zone//from w ww. j a v a 2 s . c o m * @param ctx * @param context * @return */ public static Map<String, Object> getAmazonRoute53HostedZone(DispatchContext ctx, Map<String, Object> context) { String hostedZoneId = (String) context.get("hostedZoneId"); AmazonRoute53 route53 = AwsFactory.getAmazonRoute53(); GetHostedZoneRequest request = new GetHostedZoneRequest(hostedZoneId); GetHostedZoneResult hostedZoneResult = route53.getHostedZone(request); HostedZone hostedZone = hostedZoneResult.getHostedZone(); if (UtilValidate.isEmpty(hostedZone)) { return ServiceUtil.returnError("Could not find hosted zone: " + hostedZoneId); } DelegationSet delegationSet = hostedZoneResult.getDelegationSet(); Map<String, Object> results = ServiceUtil.returnSuccess(); results.put("hostedZone", hostedZone); results.put("delegationSet", delegationSet); return results; }