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...

CreateSecurityGroup

Description

Creates a security group.

Important

EC2-Classic: You create have up to 500 security groups.

EC2-VPC: You can create up to 100 security groups per 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.

When you create a security group, you specify a friendly name of your choice. You can have a security group for EC2-Classic with the same name as a security group for a VPC. However, you can't have two security groups for EC2-Classic with the same name or two security groups for a VPC with the same name.

You have a default security group for EC2-Classic and a default security group for your VPC. If you don't specify a security group when you launch an instance, the instance is launched into the appropriate default security group. A default security group includes a default rule that grants instances unrestricted network access to each other.

You can add or remove rules from your security groups using the AuthorizeSecurityGroupIngress, AuthorizeSecurityGroupEgress, RevokeSecurityGroupIngress, and RevokeSecurityGroupEgress actions.

Request Parameters

GroupName

The name of the security group.

Type: String

Default: None

Constraints: Up to 255 characters in length

Constraints for EC2-Classic: ASCII characters

Constraints for EC2-VPC: a-z, A-Z, 0-9, spaces, and ._-:/()#,@[]+=&;{}!$*

Required: Yes

GroupDescription

A description for the security group. This is informational only.

Type: String

Default: None

Constraints: Up to 255 characters in length

Constraints for EC2-Classic: ASCII characters

Constraints for EC2-VPC: a-z, A-Z, 0-9, spaces, and ._-:/()#,@[]+=&;{}!$*

Required: Yes

VpcId

[EC2-VPC] The ID of the VPC.

Type: String

Default: None

Required: Conditional

Condition: Required for EC2-VPC.

Response Elements

The following elements are returned in a CreateSecurityGroupResponse element.

requestId

The ID of the request.

Type: xsd:string

return

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

Type: xsd:boolean

groupId

The ID that AWS assigns to the security group.

Type: xsd:string

Examples

Example Request

This example creates the websrv security group.

https://ec2.amazonaws.com/?Action=CreateSecurityGroup
&GroupName=websrv
&GroupDescription=Web Servers
&AUTHPARAMS

Example Response

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