use of com.amazonaws.services.route53.AmazonRoute53Client 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.AmazonRoute53Client in project SimianArmy by Netflix.
the class AWSClient method route53Client.
/**
* Amazon Route53 client. Abstracted to aid testing.
*
* @return the Amazon Route53 client
*/
protected AmazonRoute53Client route53Client() {
AmazonRoute53Client client;
if (awsClientConfig == null) {
if (awsCredentialsProvider == null) {
client = new AmazonRoute53Client();
} else {
client = new AmazonRoute53Client(awsCredentialsProvider);
}
} else {
if (awsCredentialsProvider == null) {
client = new AmazonRoute53Client(awsClientConfig);
} else {
client = new AmazonRoute53Client(awsCredentialsProvider, awsClientConfig);
}
}
client.setEndpoint("route53.amazonaws.com");
return client;
}
use of com.amazonaws.services.route53.AmazonRoute53Client in project GNS by MobilityFirst.
the class Route53 method main.
/**
*
* @param args
* @throws Exception
*/
public static void main(String[] args) throws Exception {
AWSCredentials credentials = new PropertiesCredentials(AWSEC2.class.getResourceAsStream("resources/AwsCredentials.properties"));
//Create Amazon Client object
route53 = new AmazonRoute53Client(credentials);
listRecordSetsForHostedZone();
}
use of com.amazonaws.services.route53.AmazonRoute53Client in project eureka by Netflix.
the class Route53Binder method getAmazonRoute53Client.
private AmazonRoute53Client getAmazonRoute53Client(EurekaServerConfig serverConfig) {
String aWSAccessId = serverConfig.getAWSAccessId();
String aWSSecretKey = serverConfig.getAWSSecretKey();
ClientConfiguration clientConfiguration = new ClientConfiguration().withConnectionTimeout(serverConfig.getASGQueryTimeoutMs());
if (null != aWSAccessId && !"".equals(aWSAccessId) && null != aWSSecretKey && !"".equals(aWSSecretKey)) {
return new AmazonRoute53Client(new BasicAWSCredentials(aWSAccessId, aWSSecretKey), clientConfiguration);
} else {
return new AmazonRoute53Client(new InstanceProfileCredentialsProvider(), clientConfiguration);
}
}
Aggregations