Java 类com.amazonaws.services.route53.AmazonRoute53 实例源码

项目:route53-dynamic-dns    文件:UpdateDns.java   
public static void main(String[] args) throws IOException {
    Arguments arguments = new Arguments();
    CmdLineParser parser = new CmdLineParser(arguments);
    try {
        parser.parseArgument(args);
    } catch (CmdLineException e) {
        System.err.println("Usage: java -jar dyndns.jar <arguments>");
        parser.printUsage(System.err);
        System.exit(1);
    }

    AmazonRoute53 route53 = new AmazonRoute53Client(new DefaultAWSCredentialsProviderChain());

    UpdateDns updateDns = new UpdateDns(route53, arguments.hostedZoneId);
    updateDns.updateDns(arguments.recordSetName, arguments.force);
}
项目:ec2-util    文件:AwsRoute53Client.java   
public static ChangeInfo attachDomainToEip(AmazonRoute53 route53, String publicIp, String domain) {
    String hostedZoneId = findHostedZoneForDomain(route53, domain);
    if (hostedZoneId != null) {
        System.out.println("Found HostedZone's Id(" + hostedZoneId + ")");
    } else {
        return null;
    }

    ResourceRecordSet resourceRecordSet = generateResourceRecordSetForARecord(publicIp, domain);
    ChangeInfo changeinfo = AwsRoute53Client.changeResourceRecordSet(route53, hostedZoneId, resourceRecordSet,
            ChangeAction.CREATE);
    return changeinfo;
}
项目:ec2-util    文件:AwsRoute53Client.java   
public static String findHostedZoneForDomain(AmazonRoute53 route53, String domain) {
    ListHostedZonesResult listHostedZonesResult = route53.listHostedZones();
    List<HostedZone> hostedZones = listHostedZonesResult.getHostedZones();
    String hostedZoneId = null;
    for (HostedZone hostedZone : hostedZones) {
        if (isRootDomain(domain, hostedZone)) {
            hostedZoneId = hostedZone.getId();
            break;
        }
    }
    return hostedZoneId;
}
项目:ec2-util    文件:AwsRoute53Client.java   
public static ChangeInfo changeResourceRecordSet(AmazonRoute53 route53, String hostedZoneId,
        ResourceRecordSet resourceRecordSet, ChangeAction changeAction) {
    Change change = new Change(changeAction, resourceRecordSet);
    ChangeBatch changeBatch = new ChangeBatch().withChanges(change);
    ChangeResourceRecordSetsRequest changeResourceRecordSetsRequest = new ChangeResourceRecordSetsRequest(
            hostedZoneId, changeBatch);
    ChangeResourceRecordSetsResult changeResourceRecordSetsResult = route53
            .changeResourceRecordSets(changeResourceRecordSetsRequest);
    ChangeInfo changeinfo = changeResourceRecordSetsResult.getChangeInfo();
    return changeinfo;
}
项目:Ec2InstanceStarter    文件:PropertyConfig.java   
@Override
public AmazonRoute53 getAmazonRoute53Client() {
    return r53;
}
项目:ec2-util    文件:AwsRoute53Client.java   
public static AmazonRoute53 getRoute53() {
    AmazonRoute53 route53 = new AmazonRoute53Client(ConfigProvider.getCredential());
    route53.setRegion(ConfigProvider.getDefaultRegion());
    return route53;
}
项目:ec2-util    文件:Ec2StartCommand.java   
private int startByName(Ec2CommandOptions options) throws FileNotFoundException {
    String name = options.getName();
    InputStream inputStream = new FileInputStream(new File(options.getCredentialsPath()));
    ConfigProvider.loadConfigure(inputStream);
    AmazonEC2 ec2 = AwsEc2Client.getEc2();

    // Check Exists Instance
    Instance instance = AwsEc2Client.findInstanceByName(ec2, name);
    if (instance == null) {
        System.err.println("Not exists instance (name = " + name + ").");
        return 2;
    }
    String instanceId = instance.getInstanceId();
    System.out.println("Exists instance (id = " + instanceId + ")");

    // Start Ec2 Instance
    InstanceStateChange stateChange = AwsEc2Client.startInstance(ec2, instanceId);
    AwsEc2Client.showStateChange(stateChange, "Starting Instance");

    // Allocate Address
    DomainType domainType = (instance.getVpcId() == null) ? DomainType.Standard : DomainType.Vpc;
    Address address = AwsEc2Client.allocateAddress(ec2, domainType);
    String publicIp = address.getPublicIp();
    System.out.println("Allocated Address(" + publicIp + ", " + address.getAllocationId() + ")");
    if (address != null) {
        // TODO: Wait for Starting Instance.
        waitForStartingInstance();

        try {
            // Associate Address
            String associateAddress = AwsEc2Client.associateAddress(ec2, address, instanceId);
            System.out.println("Associated Address(" + publicIp + ", " + associateAddress + ")");

            String domain = options.getDomain();
            if (domain != null) {
                // Attach Domain to EIP
                AmazonRoute53 route53 = AwsRoute53Client.getRoute53();
                ChangeInfo attachedResult = AwsRoute53Client.attachDomainToEip(route53, publicIp, domain);
                if (attachedResult != null) {
                    System.out.println("Attached domain(" + domain + ")");
                } else {
                    System.err.println("Not Found Available Hosted Zone for specified Domain(" + domain + ")");
                }
            }
        } catch (AmazonServiceException e) {
            AwsEc2Client.releaseAddress(ec2, address);
            System.out.println("Released Address (" + publicIp + ")");
            return 2;
        }
    }
    return 0;
}
项目:awsroute53    文件:PropertyConfig.java   
@Override
   public AmazonRoute53 getAmazonClient() {
return r53;
   }
项目:route53-dynamic-dns    文件:UpdateDns.java   
public UpdateDns(AmazonRoute53 route53, String hostedZoneId) {
    this.route53 = route53;
    this.hostedZoneId = hostedZoneId;
}
项目:jwrapper-maven-plugin    文件:CarrotRoute53.java   
private AmazonRoute53 newClient() {

        final AmazonRoute53 amazonClient = new AmazonRoute53Client(credentials);

        return amazonClient;

    }
项目:Ec2InstanceStarter    文件:Configuration.java   
/**
 * 
 * @return
 */
AmazonRoute53 getAmazonRoute53Client();
项目:awsroute53    文件:Configuration.java   
/**
 * 
 * @return The amazon client
 */
AmazonRoute53 getAmazonClient();