Skip to content

Commit

Permalink
Fix Route53 issues
Browse files Browse the repository at this point in the history
  • Loading branch information
ericvergnaud committed Dec 22, 2018
1 parent c97a851 commit bd71e7b
Showing 1 changed file with 11 additions and 8 deletions.
19 changes: 11 additions & 8 deletions AwsClient/src/main/java/prompto/aws/Route53.java
Original file line number Diff line number Diff line change
Expand Up @@ -50,18 +50,18 @@ public String createARecord(String domainName, String domainPrefix, String ipAdd
.withChangeBatch(new ChangeBatch(Collections.singletonList(new Change()
.withAction(ChangeAction.CREATE)
.withResourceRecordSet(new ResourceRecordSet()
.withName("test-user.prompto.org")
.withName(domainPrefix + domainName)
.withType(RRType.A)
.withTTL(300L)
.withResourceRecords(new ResourceRecord("222.222.222.222"))
.withResourceRecords(new ResourceRecord(ipAddress))
))));
ChangeResourceRecordSetsResult result = route53.changeResourceRecordSets(request);
return result.getChangeInfo().getStatus();
}

public PromptoDocument<String, Object> readARecord(String domainName, String domainPrefix) {
domainPrefix = domainPrefix.endsWith(".") ? domainPrefix : domainPrefix + ".";
domainName = domainName.endsWith(".") ? domainName : domainName + ".";
public PromptoDocument<String, Object> readARecord(String domainName_, String domainPrefix_) {
String domainPrefix = domainName_.endsWith(".") ? domainName_ : domainName_ + ".";
String domainName = domainName_.endsWith(".") ? domainName_ : domainName_ + ".";
String zoneId = getZoneId(domainName);
ListResourceRecordSetsRequest listRequest = new ListResourceRecordSetsRequest()
.withHostedZoneId(zoneId)
Expand All @@ -71,14 +71,17 @@ public PromptoDocument<String, Object> readARecord(String domainName, String dom
List<ResourceRecordSet> recordSets = listResult.getResourceRecordSets();
if(recordSets.isEmpty())
return null;
ResourceRecordSet recordSet = recordSets.get(0);
ResourceRecordSet recordSet = recordSets.stream()
.filter(rs->rs.getName().startsWith(domainPrefix))
.findFirst()
.orElse(null);
if(recordSet==null)
return null;
PromptoDocument<String, Object> result = new PromptoDocument<>();
result.put("name", recordSet.getName());
result.put("ttl", recordSet.getTTL());
result.put("ipAddress", recordSet.getResourceRecords().get(0).getValue());
return result;


}

public String deleteARecord(String domainName, String domainPrefix) {
Expand Down

0 comments on commit bd71e7b

Please sign in to comment.