Home > Back-end >  How to get Hosted Zone Nameservers using the AWS JAVA SDK
How to get Hosted Zone Nameservers using the AWS JAVA SDK

Time:11-10

I am using the AWS Java SDK to retrieve Hosted Zone details, I don't see any method in the AmazonRoute53Client class to list nameservers. I found that there is a method ListReusableDelegationSets, and the DelegationSet class has a getNameServers method, but I think that method wont list default nameservers for Hosted Zones created using the AWS web console.

Do you know any method to achieve this?

CodePudding user response:

You can retrieve the nameservers by using the getHostedZone method. Example:

AmazonRoute53 client = AmazonRoute53ClientBuilder.standard().build();
GetHostedZoneRequest request = new GetHostedZoneRequest().withId("Z3M3LMPEXAMPLE");
GetHostedZoneResult response = client.getHostedZone(request);

Now, from the GetHostedZoneResult response, we can use getDelegationSet method to retrieve a DelegationSet, from which using the getNameServers method we can retrieve a list with the 4 assigned nameservers.

  • Related