Amazon Elastic Compute Cloud
API Reference (API Version 2013-02-01)
« PreviousNext »
View the PDF for this guide.Go to the AWS Discussion Forum for this product.Did this page help you?  Yes | No |  Tell us about it...

DeleteSecurityGroup

Description

Deletes a security group.

Important

If you attempt to delete a security group that contains instances, or is referenced by another security group, the operation fails with InvalidGroup.InUse for EC2-Classic or DependencyViolation for EC2-VPC.

A security group is for use with instances either in the EC2-Classic platform or in a specific VPC. For more information, see Amazon EC2 Security Groups in the Amazon Elastic Compute Cloud User Guide and Security Groups for Your VPC in the Amazon Virtual Private Cloud User Guide.

Request Parameters

GroupName

The name of the security group.

Type: String

Default: None

Required: Conditional

Condition: For EC2-Classic, default VPC, you can specify either GroupName or GroupId

GroupId

The ID of the security group.

Type: String

Default: None

Required: Conditional

Condition: Required for a nondefault VPC; for EC2-Classic, default VPC, you can specify either GroupName or GroupId

Response Elements

The following elements are returned in a DeleteSecurityGroupResponse element.

requestId

The ID of the request.

Type: xsd:string

return

Returns true if the request succeeds. Otherwise, returns an error.

Type: xsd:boolean

Examples

Example Request

This example deletes the security group for EC2-Classic named websrv.

https://ec2.amazonaws.com/?Action=DeleteSecurityGroup
&GroupName=websrv
&AUTHPARAMS

Example Request

This example deletes the security group for EC2-VPC with the ID sg-1a2b3c4d.

https://ec2.amazonaws.com/?Action=DeleteSecurityGroup
&GroupId=sg-1a2b3c4d
&AUTHPARAMS

Example Response

<DeleteSecurityGroupResponse xmlns="http://ec2.amazonaws.com/doc/2013-02-01/">
  <requestId>59dbff89-35bd-4eac-99ed-be587EXAMPLE</requestId> 
  <return>true</return>
</DeleteSecurityGroupResponse>