Amazon Elastic Compute Cloud
API Reference (API Version 2011-12-15)
Print this pageEmail this pageGo to the ForumsView the PDFShare this page on TwitterShare this page on FacebookBookmark this page on DeliciousSubmit this page to RedditSubmit this page to DiggDid this page help you?  Yes  No   Tell us about it...

DeleteSecurityGroup

Description

Deletes a security group. This action applies to both EC2 security groups and VPC security groups. For information about VPC security groups and how they differ from EC2 security groups, go to Security Groups in the Amazon Virtual Private Cloud User Guide.

[Note]Note

If you attempt to delete a security group that contains instances, or attempt to delete a security group that is referenced by another security group, an error is returned. For example, if security group B has a rule that allows access from security group A, security group A cannot be deleted until the rule is removed.

The fault returned is InvalidGroup.InUse for EC2 security groups, or DependencyViolation for VPC security groups.

Request Parameters

NameDescriptionRequired

GroupName

Name of the security group to delete.

Type: String

Default: None

Condition: Either GroupName or GroupId is required

Conditional

GroupId

ID of the security group to delete.

Type: String

Default: None

Condition: Required for a VPC security group; for an EC2 security group, either GroupName or GroupId is required

Conditional

Response Elements

The elements in the following table are wrapped in a DeleteSecurityGroupResponse structure.

NameDescription

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 EC2 security group named websrv.

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

Example Request

This example deletes the VPC security group with ID sg-77d0f5a2.

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

Example Response

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