/**
* Look for Existing Resource Record Sets
*/
{
ResourceRecordSet resourceRecordSet = null;
ListResourceRecordSetsResult listResourceRecordSets = ctx.r53
.listResourceRecordSets(new ListResourceRecordSetsRequest(
zoneId));
for (ResourceRecordSet rrs : listResourceRecordSets
.getResourceRecordSets()) {
if (!rrs.getName().equals(record))
continue;
if (!"A".equals(rrs.getType()))
continue;
resourceRecordSet = rrs;
break;
}
if (null != resourceRecordSet) {
if (getLog().isInfoEnabled())
getLog().info(format("Excluding resourceRecordSet %s for domain %s", resourceRecordSet, record));
changeBatch.getChanges().add(new Change(ChangeAction.DELETE,
resourceRecordSet));
}
}
/**
* Then Add Ours
*/
AliasTarget aliasTarget = new AliasTarget();
aliasTarget.setHostedZoneId(ctx.elbHostedZoneId);
aliasTarget.setDNSName(curEnv.getEndpointURL());
ResourceRecordSet resourceRecordSet = new ResourceRecordSet();
resourceRecordSet.setName(record);
resourceRecordSet.setType(RRType.A);
resourceRecordSet.setAliasTarget(aliasTarget);
if (getLog().isInfoEnabled())
getLog().info(format("Adding resourceRecordSet %s for domain %s mapped to %s", resourceRecordSet, record, aliasTarget.getDNSName()));
changeBatch.getChanges().add(new Change(ChangeAction.CREATE, resourceRecordSet));