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

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

Introduction

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

Prototype


public void setCIDRIP(String cIDRIP) 

Source Link

Document

The IP range to authorize.

Usage

From source file:RDSManager.java

public void createRDSSecurityGroup() {
    try {//  w ww  .j  a  v a2s. c  o m

        System.out.println("Creating RDS Security Group");

        CreateDBSecurityGroupRequest d = new CreateDBSecurityGroupRequest();
        d.setDBSecurityGroupName(SECURITY_GROUP_NAME);
        d.setDBSecurityGroupDescription(SECURITY_GROUP_DESC);
        rds.createDBSecurityGroup(d);

        AuthorizeDBSecurityGroupIngressRequest auth = new AuthorizeDBSecurityGroupIngressRequest();
        auth.setDBSecurityGroupName(SECURITY_GROUP_NAME);
        auth.setCIDRIP("0.0.0.0/0");
        //auth.setEC2SecurityGroupName(groupName);
        //auth.setEC2SecurityGroupOwnerId(OwnerId);
        DBSecurityGroup dbsecuritygroup = rds.authorizeDBSecurityGroupIngress(auth);

    } catch (Exception e) {
        e.printStackTrace();
        System.exit(0);
    }
}

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 {/*from www  . j a v  a  2s.co  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;
}