use of software.amazon.awssdk.services.ec2.model.DescribeSecurityGroupsResponse in project aws-doc-sdk-examples by awsdocs.
the class DescribeSecurityGroups method describeEC2SecurityGroups.
// snippet-start:[ec2.java2.describe_security_groups.main]
public static void describeEC2SecurityGroups(Ec2Client ec2, String groupId) {
try {
DescribeSecurityGroupsRequest request = DescribeSecurityGroupsRequest.builder().groupIds(groupId).build();
DescribeSecurityGroupsResponse response = ec2.describeSecurityGroups(request);
for (SecurityGroup group : response.securityGroups()) {
System.out.printf("Found Security Group with id %s, " + "vpc id %s " + "and description %s", group.groupId(), group.vpcId(), group.description());
}
} catch (Ec2Exception e) {
System.err.println(e.awsErrorDetails().errorMessage());
System.exit(1);
}
}
Aggregations