Example usage for com.amazonaws.services.route53.model ResourceRecordSet withResourceRecords

List of usage examples for com.amazonaws.services.route53.model ResourceRecordSet withResourceRecords

Introduction

In this page you can find the example usage for com.amazonaws.services.route53.model ResourceRecordSet withResourceRecords.

Prototype


public ResourceRecordSet withResourceRecords(java.util.Collection<ResourceRecord> resourceRecords) 

Source Link

Document

Information about the resource records to act upon.

Usage

From source file:com.deploymentio.ec2namer.helpers.DnsRegistrar.java

License:Apache License

protected Change createName(NamerRequest req, LambdaContext context, String name) {

    Instance instance = instanceLookup.lookup(context, req.getInstanceId());

    boolean isVpc = req.isAlwaysUsePublicName() ? false : !StringUtils.isEmpty(instance.getVpcId());
    RRType recordType = isVpc ? RRType.A : RRType.CNAME;

    ResourceRecordSet set = new ResourceRecordSet(req.createFqdn(name) + ".", recordType);
    set.withTTL(60l);/*from   w w w.j  a v  a2s . c o  m*/
    set.withResourceRecords(
            new ResourceRecord(isVpc ? instance.getPrivateIpAddress() : instance.getPublicDnsName()));

    return new Change(ChangeAction.UPSERT, set);
}

From source file:tech.greenfield.aws.route53.EventHandler.java

License:Open Source License

/**
 * Start an DNS registration for the launched instance
 * @param ec2InstanceId instance ID of instance that needs to be registered
 * @param ttl TTL in seconds to use when creating a new record
 *//*from w ww .j  a  va 2s.  com*/
private void registerInstance(String ec2InstanceId) throws NoIpException {
    logger.info("Registering " + ec2InstanceId);
    ChangeBatch cb = message.getUpsertChanges(Collections.singletonList(getInstance(ec2InstanceId)));

    if (Route53Message.isDebug())
        logger.fine("Adding instance with addresses: " + cb);

    for (Change c : cb.getChanges()) {
        ResourceRecordSet rr = c.getResourceRecordSet();
        ResourceRecordSet oldrr = Tools.getRecordSet(rr.getName(), rr.getType());
        if (Objects.nonNull(oldrr))
            oldrr.getResourceRecords().forEach(r -> rr.withResourceRecords(r));
    }
    ChangeResourceRecordSetsRequest req = new ChangeResourceRecordSetsRequest(Route53Message.getHostedZoneId(),
            cb);
    if (Route53Message.isDebug())
        logger.fine("Sending rr change request: " + req);
    Tools.waitFor(route53().changeResourceRecordSets(req));
}