use of software.amazon.awssdk.services.ec2.model.SecurityGroup in project photon-model by vmware.
the class TestAWSSecurityGroupService method testUpdateIngressRules.
/*
* Test updating ingress rules with the Security Group Service Allow
* object
*/
@Test
public void testUpdateIngressRules() throws Throwable {
String groupID = this.client.createDefaultSecurityGroup(null);
ArrayList<Rule> rules = TestUtils.getAllowIngressRules();
this.client.addIngressRules(groupID, this.client.buildRules(rules));
SecurityGroup awsSG = this.client.getSecurityGroupById(groupID);
List<IpPermission> ingress = awsSG.getIpPermissions();
for (IpPermission rule : ingress) {
assertDefaultRules(rule);
}
this.client.deleteSecurityGroup(groupID);
}
use of software.amazon.awssdk.services.ec2.model.SecurityGroup 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