    //snippet-sourcedescription:[DeleteSecurityGroup.java demonstrates how to delete an EC2 security group.]
//snippet-keyword:[SDK for Java 2.0]
//snippet-keyword:[Code Sample]
//snippet-service:[ec2]
//snippet-sourcetype:[full-example]
//snippet-sourcedate:[]
//snippet-sourceauthor:[soo-aws]
/*
 * Copyright 2010-2019 Amazon.com, Inc. or its affiliates. All Rights Reserved.
 *
 * Licensed under the Apache License, Version 2.0 (the "License").
 * You may not use this file except in compliance with the License.
 * A copy of the License is located at
 *
 *  http://aws.amazon.com/apache2.0
 *
 * or in the "license" file accompanying this file. This file is distributed
 * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
 * express or implied. See the License for the specific language governing
 * permissions and limitations under the License.
 */
package com.example.ec2;
// snippet-start:[ec2.java2.delete_security_group.complete]
// snippet-start:[ec2.java2.delete_security_group.import]
import software.amazon.awssdk.services.ec2.Ec2Client;
import software.amazon.awssdk.services.ec2.model.DeleteSecurityGroupRequest;
import software.amazon.awssdk.services.ec2.model.DeleteSecurityGroupResponse;
 
// snippet-end:[ec2.java2.delete_security_group.import]
/**
 * Deletes an EC2 security group
 */
public class DeleteSecurityGroup
{
    public static void main(String[] args)
    {
        final String USAGE =
            "To run this example, supply a security group id\n" +
            "Ex: DeleteSecurityGroup <security-group-id>\n";

        if (args.length != 1) {
            System.out.println(USAGE);
            System.exit(1);
        }

        String group_id = args[0];
        // snippet-start:[ec2.java2.delete_security_group.main]

        Ec2Client ec2 = Ec2Client.create();

        DeleteSecurityGroupRequest request = DeleteSecurityGroupRequest.builder()
            .groupId(group_id)
            .build();

        DeleteSecurityGroupResponse response = ec2.deleteSecurityGroup(request);

        // snippet-end:[ec2.java2.delete_security_group.main]
        System.out.printf(
            "Successfully deleted security group with id %s", group_id);
    }
}
 
// snippet-end:[ec2.java2.delete_security_group.complete]

@@ -1,12 +1,8 @@
-    
 //snippe
@@ -254,16 +254,26 @@
 cedate:%5B
+11/02/2020
 %5D%0D%0A//sni
@@ -296,14 +296,15 @@
 r:%5Bs
-oo-aws
+cmacdon
 %5D%0D%0A/
@@ -330,10 +330,10 @@
 0-20
-19
+20
  Ama
@@ -1259,17 +1259,80 @@
 ponse;%0D%0A
- 
+import software.amazon.awssdk.services.ec2.model.Ec2Exception;%0D%0A
 %0D%0A// sni
@@ -1462,11 +1462,12 @@
 roup
+ %7B
 %0D%0A
-%7B
 %0D%0A  
@@ -1506,21 +1506,16 @@
 %5B%5D args)
-%0D%0A   
  %7B%0D%0A    
@@ -1540,16 +1540,20 @@
 SAGE =%0D%0A
+    
         
@@ -1611,16 +1611,28 @@
 d%5Cn%22 +%0D%0A
+            
         
@@ -1822,18 +1822,17 @@
 ng group
-_i
+I
 d = args
@@ -1947,24 +1947,45 @@
 reate();%0D%0A%0D%0A
+        try %7B%0D%0A%0D%0A    
         Dele
@@ -2067,16 +2067,20 @@
         
+    
 .groupId
@@ -2085,18 +2085,17 @@
 Id(group
-_i
+I
 d)%0D%0A    
@@ -2102,16 +2102,20 @@
         
+   
+ 
 .build()
@@ -2115,24 +2115,28 @@
 build();%0D%0A%0D%0A
+    
         Dele
@@ -2215,67 +2215,8 @@
     
-    // snippet-end:%5Bec2.java2.delete_security_group.main%5D%0D%0A
     
@@ -2239,16 +2239,20 @@
 rintf(%0D%0A
+    
         
@@ -2314,14 +2314,157 @@
 roup
-_i
+I
 d);%0D
+%0A%0D%0A        %7D catch (Ec2Exception e) %7B%0D%0A            e.getStackTrace();%0D%0A        %7D%0D%0A        // snippet-end:%5Bec2.java2.delete_security_group.main%5D%0D
 %0A   
@@ -2474,11 +2474,8 @@
 %0A%7D%0D%0A
- %0D%0A
 // s

Update DeleteSecurityGroup.java