要使用AWS Java SDK v2来访问Route 53,您可以使用software.amazon.awssdk.regions.Region
类来指定区域端点。
以下是使用AWS Java SDK v2访问Route 53的示例代码:
import software.amazon.awssdk.regions.Region;
import software.amazon.awssdk.services.route53.Route53Client;
import software.amazon.awssdk.services.route53.model.*;
public class Route53Example {
public static void main(String[] args) {
// 指定区域端点为us-east-1
Region region = Region.US_EAST_1;
// 创建Route53Client对象
Route53Client route53Client = Route53Client.builder()
.region(region)
.build();
// 使用Route53Client对象执行操作
ListHostedZonesResponse response = route53Client.listHostedZones();
// 打印结果
for (HostedZone hostedZone : response.hostedZones()) {
System.out.println("Hosted Zone ID: " + hostedZone.id());
System.out.println("Hosted Zone Name: " + hostedZone.name());
System.out.println();
}
// 关闭Route53Client对象
route53Client.close();
}
}
在上面的示例中,我们通过Region.US_EAST_1
指定了区域端点为us-east-1。您可以根据您的实际需求,使用其他区域端点来访问Route 53。
请注意,您需要在构建Route53Client
对象时使用正确的区域端点,以确保正确连接到Route 53服务。