use of com.amazonaws.services.route53.model.ChangeResourceRecordSetsRequest in project SimianArmy by Netflix.
the class AWSClient method deleteDNSRecord.
/** {@inheritDoc} */
@Override
public void deleteDNSRecord(String dnsName, String dnsType, String hostedZoneID) {
Validate.notEmpty(dnsName);
Validate.notEmpty(dnsType);
if (dnsType.equals("A") || dnsType.equals("AAAA") || dnsType.equals("CNAME")) {
LOGGER.info(String.format("Deleting DNS Route 53 record %s", dnsName));
AmazonRoute53Client route53Client = route53Client();
// AWS API requires us to query for the record first
ListResourceRecordSetsRequest listRequest = new ListResourceRecordSetsRequest(hostedZoneID);
listRequest.setMaxItems("1");
listRequest.setStartRecordType(dnsType);
listRequest.setStartRecordName(dnsName);
ListResourceRecordSetsResult listResult = route53Client.listResourceRecordSets(listRequest);
if (listResult.getResourceRecordSets().size() < 1) {
throw new NotFoundException("Could not find Route53 record for " + dnsName + " (" + dnsType + ") in zone " + hostedZoneID);
} else {
ResourceRecordSet resourceRecord = listResult.getResourceRecordSets().get(0);
ArrayList<Change> changeList = new ArrayList<>();
Change recordChange = new Change(ChangeAction.DELETE, resourceRecord);
changeList.add(recordChange);
ChangeBatch recordChangeBatch = new ChangeBatch(changeList);
ChangeResourceRecordSetsRequest request = new ChangeResourceRecordSetsRequest(hostedZoneID, recordChangeBatch);
ChangeResourceRecordSetsResult result = route53Client.changeResourceRecordSets(request);
}
} else {
LOGGER.error("dnsType must be one of 'A', 'AAAA', or 'CNAME'");
}
}
use of com.amazonaws.services.route53.model.ChangeResourceRecordSetsRequest in project GNS by MobilityFirst.
the class Route53 method createRecordSetFromHostedZone.
private static void createRecordSetFromHostedZone() {
List<ResourceRecord> records = new ArrayList<>();
ResourceRecord record = new ResourceRecord();
record.setValue("http://www.marksdevserver.com");
records.add(record);
ResourceRecordSet recordSet = new ResourceRecordSet();
recordSet.setName("markstest.domain.com.");
recordSet.setType(RRType.CNAME);
recordSet.setTTL(new Long(60));
recordSet.setResourceRecords(records);
// Create the Change
List<Change> changes = new ArrayList<>();
Change change = new Change();
change.setAction(ChangeAction.CREATE);
change.setResourceRecordSet(recordSet);
changes.add(change);
// Create a batch and add the change to it
ChangeBatch batch = new ChangeBatch();
batch.setChanges(changes);
// Create a Request and add the batch to it.
ChangeResourceRecordSetsRequest request = new ChangeResourceRecordSetsRequest();
request.setHostedZoneId(HOSTED_ZONE_ID);
request.setChangeBatch(batch);
// send the request
ChangeResourceRecordSetsResult result = route53.changeResourceRecordSets(request);
System.out.println(result.toString());
}
use of com.amazonaws.services.route53.model.ChangeResourceRecordSetsRequest in project Synapse-Stack-Builder by Sage-Bionetworks.
the class Route53Setup method setupResources.
public void setupResources() throws InterruptedException {
List<Change> changes = buildChangesList(Constants.ROUTE53_PREFIXES);
if (changes.size() > 0) {
ChangeBatch changeBatch = new ChangeBatch().withChanges(changes);
ChangeResourceRecordSetsRequest cReq = new ChangeResourceRecordSetsRequest().withHostedZoneId(hostedZone.getId()).withChangeBatch(changeBatch);
ChangeResourceRecordSetsResult cRes = route53Client.changeResourceRecordSets(cReq);
GetChangeRequest gcReq = new GetChangeRequest(cRes.getChangeInfo().getId());
GetChangeResult gcRes = route53Client.getChange(gcReq);
// TODO: No real need to wait here, could just exit
while (!"INSYNC".equals(gcRes.getChangeInfo().getStatus())) {
Thread.sleep(1000L);
gcRes = route53Client.getChange(gcReq);
String s = gcRes.getChangeInfo().getStatus();
}
}
}
Aggregations