public void addPermissionsToSecurityGroup(String groupName,
      String ipRanges,
      String ipProtocol,
      Integer fromPort,
      Integer toPort) {

    final AmazonEC2 amazonEC2 = getEc2Client();

    final IpPermission ipPermission = new IpPermission()
        .withIpRanges(ipRanges)
        .withIpProtocol(ipProtocol)
        .withFromPort(fromPort)
        .withToPort(toPort);
    final AuthorizeSecurityGroupIngressRequest authorizeSecurityGroupIngressRequest =
        new AuthorizeSecurityGroupIngressRequest()
            .withGroupName(groupName)
            .withIpPermissions(ipPermission);
    amazonEC2.authorizeSecurityGroupIngress(authorizeSecurityGroupIngressRequest);

    LOGGER.info("Added permissions: " + ipPermission + " to security group: " + groupName);
  }
public void addPermissionsToSecurityGroup ( String groupName , String ipRanges , String ipProtocol , Integer fromPort , Integer toPort ) { final AmazonEC2 amazonEC2 = getEc2Client ( ) ; final IpPermission ipPermission = new IpPermission ( ) . withIpRanges ( ipRanges ) . withIpProtocol ( ipProtocol ) . withFromPort ( fromPort ) . withToPort ( toPort ) ; final AuthorizeSecurityGroupIngressRequest authorizeSecurityGroupIngressRequest = new AuthorizeSecurityGroupIngressRequest ( ) . withGroupName ( groupName ) . withIpPermissions ( ipPermission ) ; amazonEC2 . authorizeSecurityGroupIngress ( authorizeSecurityGroupIngressRequest ) ; LOGGER . info ( "Added permissions: " + ipPermission + " to security group: " + groupName ) ; }
*
Open firewall for a security group

@param groupName Open firewall for this security group
@param ipRanges Open firewall for this IP range
@param ipProtocol Open firewall for this protocol type (eg. tcp, udp)
@param fromPort Open firewall for port range starting at this port
@param toPort Open firewall for port range ending at this port