Search in sources :

Example 1 with AmazonRoute53Client

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'");
    }
}
Also used : NotFoundException(com.netflix.simianarmy.NotFoundException) AmazonRoute53Client(com.amazonaws.services.route53.AmazonRoute53Client)

Example 2 with AmazonRoute53Client

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;
}
Also used : AmazonRoute53Client(com.amazonaws.services.route53.AmazonRoute53Client)

Example 3 with AmazonRoute53Client

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();
}
Also used : PropertiesCredentials(com.amazonaws.auth.PropertiesCredentials) AWSCredentials(com.amazonaws.auth.AWSCredentials) AmazonRoute53Client(com.amazonaws.services.route53.AmazonRoute53Client)

Example 4 with AmazonRoute53Client

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);
    }
}
Also used : InstanceProfileCredentialsProvider(com.amazonaws.auth.InstanceProfileCredentialsProvider) ClientConfiguration(com.amazonaws.ClientConfiguration) AmazonRoute53Client(com.amazonaws.services.route53.AmazonRoute53Client) BasicAWSCredentials(com.amazonaws.auth.BasicAWSCredentials)

Aggregations

AmazonRoute53Client (com.amazonaws.services.route53.AmazonRoute53Client)4 ClientConfiguration (com.amazonaws.ClientConfiguration)1 AWSCredentials (com.amazonaws.auth.AWSCredentials)1 BasicAWSCredentials (com.amazonaws.auth.BasicAWSCredentials)1 InstanceProfileCredentialsProvider (com.amazonaws.auth.InstanceProfileCredentialsProvider)1 PropertiesCredentials (com.amazonaws.auth.PropertiesCredentials)1 NotFoundException (com.netflix.simianarmy.NotFoundException)1