Search in sources :

Example 6 with DeleteSecurityGroupRequest

use of software.amazon.awssdk.services.ec2.model.DeleteSecurityGroupRequest in project aws-doc-sdk-examples by awsdocs.

the class DeleteSecurityGroup method deleteEC2SecGroup.

// snippet-start:[ec2.java2.delete_security_group.main]
public static void deleteEC2SecGroup(Ec2Client ec2, String groupId) {
    try {
        DeleteSecurityGroupRequest request = DeleteSecurityGroupRequest.builder().groupId(groupId).build();
        ec2.deleteSecurityGroup(request);
        System.out.printf("Successfully deleted Security Group with id %s", groupId);
    } catch (Ec2Exception e) {
        System.err.println(e.awsErrorDetails().errorMessage());
        System.exit(1);
    }
}
Also used : DeleteSecurityGroupRequest(software.amazon.awssdk.services.ec2.model.DeleteSecurityGroupRequest) Ec2Exception(software.amazon.awssdk.services.ec2.model.Ec2Exception)

Aggregations

DeleteSecurityGroupRequest (com.amazonaws.services.ec2.model.DeleteSecurityGroupRequest)5 SecurityGroup (com.amazonaws.services.ec2.model.SecurityGroup)2 AmazonEC2 (com.amazonaws.services.ec2.AmazonEC2)1 AmazonEC2Exception (com.amazonaws.services.ec2.model.AmazonEC2Exception)1 DeleteSecurityGroupResult (com.amazonaws.services.ec2.model.DeleteSecurityGroupResult)1 DescribeSecurityGroupsRequest (com.amazonaws.services.ec2.model.DescribeSecurityGroupsRequest)1 DescribeSecurityGroupsResult (com.amazonaws.services.ec2.model.DescribeSecurityGroupsResult)1 Filter (com.amazonaws.services.ec2.model.Filter)1 UnknownHostException (java.net.UnknownHostException)1 TimeoutException (java.util.concurrent.TimeoutException)1 Test (org.junit.Test)1 DeleteSecurityGroupRequest (software.amazon.awssdk.services.ec2.model.DeleteSecurityGroupRequest)1 Ec2Exception (software.amazon.awssdk.services.ec2.model.Ec2Exception)1