com.amazonaws.services.ec2.model.DeleteSecurityGroupRequest Java Examples

The following examples show how to use com.amazonaws.services.ec2.model.DeleteSecurityGroupRequest. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: DeleteSecurityGroup.java    From aws-doc-sdk-examples with Apache License 2.0 6 votes vote down vote up
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];

    final AmazonEC2 ec2 = AmazonEC2ClientBuilder.defaultClient();

    DeleteSecurityGroupRequest request = new DeleteSecurityGroupRequest()
        .withGroupId(group_id);

    DeleteSecurityGroupResult response = ec2.deleteSecurityGroup(request);

    System.out.printf(
        "Successfully deleted security group with id %s", group_id);
}
 
Example #2
Source File: AmazonIpRuleManager.java    From usergrid with Apache License 2.0 5 votes vote down vote up
@Override
public boolean deleteRuleSet( final String name ) {
    try {
        DeleteSecurityGroupRequest request = new DeleteSecurityGroupRequest().withGroupName( name );
        client.deleteSecurityGroup( request );
        return true;
    }
    catch ( AmazonServiceException e ) {
        LOG.warn( "Error while trying to delete security group", e );
        return false;
    }
}
 
Example #3
Source File: BaseTest.java    From aws-mock with MIT License 5 votes vote down vote up
/**
 * Delete SecurityGroup.
 *
 * @param groupId the group id
 * @return true if deleted, otherwise false.
 */
protected final boolean deleteSecurityGroup(final String groupId) {
    DeleteSecurityGroupRequest req = new DeleteSecurityGroupRequest();
    req.setGroupId(groupId);
    DeleteSecurityGroupResult result = amazonEC2Client.deleteSecurityGroup(req);
    if (result != null) {
        return true;
    }

    /*CreateSecurityGroupRequest createSecurityGroupRequest = new CreateSecurityGroupRequest();
    AuthorizeSecurityGroupEgressRequest authorizeSecurityGroupEgressRequest = new AuthorizeSecurityGroupEgressRequest();
    authorizeSecurityGroupEgressRequest.setIpProtocol(ipProtocol);
    CreateSecurityGroupResult result = amazonEC2Client.authorizeSecurityGroupEgress(authorizeSecurityGroupEgressRequest);*/
    return false;
}
 
Example #4
Source File: SecurityGroupImpl.java    From aws-sdk-java-resources with Apache License 2.0 4 votes vote down vote up
@Override
public void delete(DeleteSecurityGroupRequest request) {
    delete(request, null);
}
 
Example #5
Source File: SecurityGroupImpl.java    From aws-sdk-java-resources with Apache License 2.0 4 votes vote down vote up
@Override
public void delete(DeleteSecurityGroupRequest request, ResultCapture<Void>
        extractor) {

    resource.performAction("Delete", request, extractor);
}
 
Example #6
Source File: PublicAccessAutoFix.java    From pacbot with Apache License 2.0 3 votes vote down vote up
/**
 * Delete security group.
 *
 * @param resourceId the resource id
 * @param ec2Client the ec 2 client
 * @return the boolean
 * @throws Exception the exception
 */
public static Boolean deleteSecurityGroup(String resourceId,AmazonEC2 ec2Client) throws Exception {
    DeleteSecurityGroupRequest deleteSecurityGroupRequest = new DeleteSecurityGroupRequest();
    deleteSecurityGroupRequest.setGroupId(resourceId);
    ec2Client.deleteSecurityGroup(deleteSecurityGroupRequest);
    return true;
}
 
Example #7
Source File: SecurityGroup.java    From aws-sdk-java-resources with Apache License 2.0 2 votes vote down vote up
/**
 * Performs the <code>Delete</code> action.
 *
 * <p>
 * The following request parameters will be populated from the data of this
 * <code>SecurityGroup</code> resource, and any conflicting parameter value
 * set in the request will be overridden:
 * <ul>
 *   <li>
 *     <b><code>GroupId</code></b>
 *         - mapped from the <code>Id</code> identifier.
 *   </li>
 * </ul>
 *
 * <p>
 *
 * @see DeleteSecurityGroupRequest
 */
void delete(DeleteSecurityGroupRequest request);
 
Example #8
Source File: SecurityGroup.java    From aws-sdk-java-resources with Apache License 2.0 2 votes vote down vote up
/**
 * Performs the <code>Delete</code> action and use a ResultCapture to
 * retrieve the low-level client response.
 *
 * <p>
 * The following request parameters will be populated from the data of this
 * <code>SecurityGroup</code> resource, and any conflicting parameter value
 * set in the request will be overridden:
 * <ul>
 *   <li>
 *     <b><code>GroupId</code></b>
 *         - mapped from the <code>Id</code> identifier.
 *   </li>
 * </ul>
 *
 * <p>
 *
 * @see DeleteSecurityGroupRequest
 */
void delete(DeleteSecurityGroupRequest request, ResultCapture<Void>
        extractor);