:doc:`SecurityGroup <index>` / Action / delete

******
delete
******



.. py:method:: EC2.SecurityGroup.delete(**kwargs)

  

  Deletes a security group.

   

  If you attempt to delete a security group that is associated with an instance or network interface, is referenced by another security group in the same VPC, or has a VPC association, the operation fails with ``DependencyViolation``.

  

  See also: `AWS API Documentation <https://docs.aws.amazon.com/goto/WebAPI/ec2-2016-11-15/DeleteSecurityGroup>`_  


  **Request Syntax**
  ::

    response = security_group.delete(
        GroupName='string',
        DryRun=True|False
    )
    
  :type GroupName: string
  :param GroupName: 

    [Default VPC] The name of the security group. You can specify either the security group name or the security group ID. For security groups in a nondefault VPC, you must specify the security group ID.

    

  
  :type DryRun: boolean
  :param DryRun: 

    Checks whether you have the required permissions for the action, without actually making the request, and provides an error response. If you have the required permissions, the error response is ``DryRunOperation``. Otherwise, it is ``UnauthorizedOperation``.

    

  
  
  :rtype: dict
  :returns: 
    
    **Response Syntax**

    
    ::

      {
          'Return': True|False,
          'GroupId': 'string'
      }
      
    **Response Structure**

    

    - *(dict) --* 
      

      - **Return** *(boolean) --* 

        Returns ``true`` if the request succeeds; otherwise, returns an error.

        
      

      - **GroupId** *(string) --* 

        The ID of the deleted security group.

        
  