List of usage examples for com.amazonaws.services.ec2 AmazonEC2 describeSecurityGroups
DescribeSecurityGroupsResult describeSecurityGroups();
From source file:edu.umass.cs.aws.support.AWSEC2.java
License:Apache License
/** * Describe Security Groups/*w ww . j a va2 s.c o m*/ * * @param ec2 */ public static void describeSecurityGroups(AmazonEC2 ec2) { StringBuilder output = new StringBuilder(); String prefix = currentTab + "Security Groups: "; DescribeSecurityGroupsResult describeSecurityGroupsResult = ec2.describeSecurityGroups(); for (SecurityGroup securityGroup : describeSecurityGroupsResult.getSecurityGroups()) { output.append(prefix); prefix = ", "; output.append(securityGroup.getGroupName()); } System.out.println(output); }
From source file:edu.umass.cs.aws.support.AWSEC2.java
License:Apache License
/** * Returns the name of an existing security group of the given name or null if one does not exist. * * @param ec2/* w ww. jav a 2 s . c o m*/ * @param name * @return the same name if it exists, null otherwise */ public static SecurityGroup findSecurityGroup(AmazonEC2 ec2, String name) { DescribeSecurityGroupsResult describeSecurityGroupsResult = ec2.describeSecurityGroups(); for (SecurityGroup securityGroup : describeSecurityGroupsResult.getSecurityGroups()) { if (name.equals(securityGroup.getGroupName())) { System.out.println("Found security group " + name); return securityGroup; } } return null; }