private boolean createResourceRecordSet(ResourceRecordSetWithHostedZone rrs) throws InterruptedException { rrs.getResourceRecordSet().setResourceRecords(Arrays.asList(new ResourceRecord(registrationHostname))); Change change = new Change(ChangeAction.UPSERT, rrs.getResourceRecordSet()); if (executeChangeWithRetry(change, rrs.getHostedZone())) { Thread.sleep(1000); // check change not overwritten ResourceRecordSet resourceRecordSet = getResourceRecordSet(rrs.getResourceRecordSet().getName(), rrs.getHostedZone()); return resourceRecordSet.getResourceRecords().equals(rrs.getResourceRecordSet().getResourceRecords()); } return false; }
public ResourceRecord unmarshall(StaxUnmarshallerContext context) throws Exception { ResourceRecord resourceRecord = new ResourceRecord(); int originalDepth = context.getCurrentDepth(); int targetDepth = originalDepth + 1; if (context.isStartOfDocument()) targetDepth += 1; while (true) { XMLEvent xmlEvent = context.nextEvent(); if (xmlEvent.isEndDocument()) return resourceRecord; if (xmlEvent.isAttribute() || xmlEvent.isStartElement()) { if (context.testExpression("Value", targetDepth)) { resourceRecord.setValue(StringStaxUnmarshaller.getInstance().unmarshall(context)); continue; } } else if (xmlEvent.isEndElement()) { if (context.getCurrentDepth() < originalDepth) { return resourceRecord; } } } }
private boolean createResourceRecordSet(ResourceRecordSetWithHostedZone rrs) throws InterruptedException { rrs.getResourceRecordSet().setResourceRecords(Arrays.asList(new ResourceRecord(registrationHostname))); Change change = new Change(ChangeAction.UPSERT, rrs.getResourceRecordSet()); if (executeChangeWithRetry(change, rrs.getHostedZone())) { Thread.sleep(1000); // check change not overwritten ResourceRecordSet resourceRecordSet = getResourceRecordSet(rrs.getResourceRecordSet().getName(), rrs.getHostedZone()); return resourceRecordSet.getResourceRecords().equals(rrs.getResourceRecordSet().getResourceRecords()); } return false; }
@TaskAction public void changeResourceRecordSets() { // to enable conventionMappings feature String hostedZoneId = getHostedZoneId(); String rrsName = getRrsName(); String resourceRecord = getResourceRecord(); AmazonRoute53PluginExtension ext = getProject().getExtensions().getByType(AmazonRoute53PluginExtension.class); AmazonRoute53 route53 = ext.getClient(); route53.changeResourceRecordSets(new ChangeResourceRecordSetsRequest() .withHostedZoneId(hostedZoneId) .withChangeBatch(new ChangeBatch() .withChanges(new Change(ChangeAction.CREATE, new ResourceRecordSet(rrsName, RRType.CNAME) .withResourceRecords(new ResourceRecord(resourceRecord)))))); getLogger().info("change {} requested", hostedZoneId); } }
.withType(RRType.CNAME) .withTTL(300L) .withResourceRecords(new ResourceRecord() .withValue(target)
ResourceRecord resourceRecord = new ResourceRecord(address);