use of software.amazon.awssdk.services.ec2.model.DescribeSecurityGroupsRequest in project Synapse-Stack-Builder by Sage-Bionetworks.
the class EC2SecuritySetup method describeResources.
public void describeResources() {
DescribeSecurityGroupsRequest req = new DescribeSecurityGroupsRequest();
req.setGroupNames(Arrays.asList(config.getElasticSecurityGroupName()));
DescribeSecurityGroupsResult res = ec2Client.describeSecurityGroups(req);
if ((res.getSecurityGroups() != null) && res.getSecurityGroups().size() == 1) {
SecurityGroup grp = res.getSecurityGroups().get(0);
resources.setElasticBeanstalkEC2SecurityGroup(grp);
String kpName = config.getStackKeyPairName();
KeyPairInfo inf = describeKeyPair();
if (inf != null) {
resources.setStackKeyPair(inf);
}
} else {
throw new IllegalStateException("Did not find one and ony one EC2 secruity group with the name: " + req.getGroupNames());
}
}
use of software.amazon.awssdk.services.ec2.model.DescribeSecurityGroupsRequest in project photon-model by vmware.
the class AWSSecurityGroupClient method getSecurityGroupById.
public SecurityGroup getSecurityGroupById(String groupId) {
SecurityGroup cellGroup = null;
DescribeSecurityGroupsRequest req = new DescribeSecurityGroupsRequest().withGroupIds(groupId);
DescribeSecurityGroupsResult cellGroups = this.client.describeSecurityGroups(req);
if (cellGroups != null) {
cellGroup = cellGroups.getSecurityGroups().get(0);
}
return cellGroup;
}
use of software.amazon.awssdk.services.ec2.model.DescribeSecurityGroupsRequest in project photon-model by vmware.
the class TestAWSSetupUtils method getSecurityGroupsIdUsingEC2Client.
public static SecurityGroup getSecurityGroupsIdUsingEC2Client(AmazonEC2AsyncClient client, String awsGroupId) {
if (awsGroupId == null) {
return null;
}
DescribeSecurityGroupsRequest describeSGsRequest = new DescribeSecurityGroupsRequest().withFilters(new Filter(AWSConstants.AWS_GROUP_ID_FILTER, Collections.singletonList(awsGroupId)));
DescribeSecurityGroupsResult describeSGResult = client.describeSecurityGroups(describeSGsRequest);
if (describeSGResult.getSecurityGroups().size() > 0) {
return describeSGResult.getSecurityGroups().get(0);
} else {
return null;
}
}
use of software.amazon.awssdk.services.ec2.model.DescribeSecurityGroupsRequest 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