Example usage for com.amazonaws.services.rds.model AuthorizeDBSecurityGroupIngressRequest setRequestCredentials

List of usage examples for com.amazonaws.services.rds.model AuthorizeDBSecurityGroupIngressRequest setRequestCredentials

Introduction

In this page you can find the example usage for com.amazonaws.services.rds.model AuthorizeDBSecurityGroupIngressRequest setRequestCredentials.

Prototype

@Deprecated
public void setRequestCredentials(AWSCredentials credentials) 

Source Link

Document

Sets the optional credentials to use for this request, overriding the default credentials set at the client level.

Usage

From source file:org.cloudml.connectors.BeanstalkConnector.java

License:Open Source License

public void openDBForIps(String dbInstanceIdentifier, Collection<String> ips, int timeout) {
    String groupName = dbInstanceIdentifier + "-security-group";
    for (String ip : ips) {
        AuthorizeDBSecurityGroupIngressRequest audbgi = new AuthorizeDBSecurityGroupIngressRequest()
                .withCIDRIP(ip + "/32").withDBSecurityGroupName(groupName);
        audbgi.setRequestCredentials(awsCredentials);
        rdsClient.authorizeDBSecurityGroupIngress(audbgi);

    }//from  www. j a  va2  s  . c o m
    rdsClient.authorizeDBSecurityGroupIngress(new AuthorizeDBSecurityGroupIngressRequest()
            .withCIDRIP("0.0.0.0/0").withDBSecurityGroupName(groupName));
    ModifyDBInstanceRequest request = new ModifyDBInstanceRequest();
    Collection<String> groups = new ArrayList();
    groups.add(groupName);
    request.setDBSecurityGroups(groups);
    request.setDBInstanceIdentifier(dbInstanceIdentifier);
    System.out.print("Modifying security group");
    while (timeout-- > 0) {
        System.out.print("-");
        try {
            Thread.sleep(1000);
        } catch (InterruptedException ex) {
            Logger.getLogger(BeanstalkConnector.class.getName()).log(Level.SEVERE, null, ex);
        }

        try {
            rdsClient.modifyDBInstance(request);
            break;
        } catch (Exception e) {
            continue;
        }

    }

}