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

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

Introduction

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

Prototype

public AuthorizeDBSecurityGroupIngressRequest(String dBSecurityGroupName) 

Source Link

Document

Constructs a new AuthorizeDBSecurityGroupIngressRequest object.

Usage

From source file:beanstalk.BeansDatabase.java

License:Apache License

public boolean allowIPConnectionWithDB(String AWSKeyId, String AWSSecretKey, String dbIdentifier) {//throws Exception {

    boolean ret = false;
    String security_group = "Cloud4SoaSecGroup";
    BasicAWSCredentials basic_credentials = new BasicAWSCredentials(AWSKeyId, AWSSecretKey);

    AmazonRDSClient rDSClient = new AmazonRDSClient(basic_credentials);
    //1st step-->add group cloud4soa if not exist

    CreateDBSecurityGroupRequest create_secGroupRequest = new CreateDBSecurityGroupRequest(security_group,
            "GroupGeneratedByCloud4SoaAdapter");
    DBSecurityGroup securityGroup = new DBSecurityGroup();

    try {//  w ww . j a  v a  2 s  .c  o  m
        securityGroup = rDSClient.createDBSecurityGroup(create_secGroupRequest);
    } catch (AmazonClientException amazonClientException) {
        System.out.print("Error when trying to add Security Group.Security Group might exist already!");
    }

    //2nd step--> add IP to list of specific Security Group

    AuthorizeDBSecurityGroupIngressRequest ip2SecGroup = new AuthorizeDBSecurityGroupIngressRequest(
            security_group);
    //allow specific ip
    //ip2SecGroup.setCIDRIP("91.132.244.150/5");
    //allow everyone
    ip2SecGroup.setCIDRIP("0.0.0.0/0");
    try {
        rDSClient.authorizeDBSecurityGroupIngress(ip2SecGroup);
    } catch (AmazonClientException amazonClientException) {
        System.out.print(
                "Error when trying to add the specific IP address to the security group.IP might be already entered!");

    }

    return ret;
}

From source file:ch.admin.isb.hermes5.tools.deploysupport.DeploySupport.java

License:Apache License

public void addMyIPToRDSSecurityGroup() {

    AuthorizeDBSecurityGroupIngressRequest authorizeDBSecurityGroupIngressRequest = new AuthorizeDBSecurityGroupIngressRequest(
            rdsSecurityGroupName).withCIDRIP(clientIpRange);
    try {/*from   w  w w .  j av  a 2 s  .  co  m*/
        rds().authorizeDBSecurityGroupIngress(authorizeDBSecurityGroupIngressRequest);

        audit("Open for IP Range=" + clientIpRange);
    } catch (Exception e) {
        audit("Unable to opened for IP Range=" + clientIpRange);
        e.printStackTrace();
    }
}