aws ec2 create-security-group
Creates a security group. AWS CLI reference
2 examples 5 options Its page in the AWS CLI reference
Examples
Example 1: To create a security group for EC2-Classic
The following create-security-group example creates a security group named MySecurityGroup.
aws ec2 create-security-group --group-name MySecurityGroup --description "My security group"Identify--group-nameThe name of the security group.--descriptionA description for the security group.Its output
{
"GroupId": "sg-903004f8"
}For more information, see Amazon EC2 security groups for your EC2 instances in the Amazon EC2 User Guide.
Example 2: To create a security group for EC2-VPC
The following create-security-group example creates a security group named MySecurityGroup for the specified VPC.
aws ec2 create-security-group --group-name MySecurityGroup --description "My security group" --vpc-id vpc-1a2b3c4dIdentify--group-nameThe name of the security group.--descriptionA description for the security group.--vpc-idThe ID of the VPC.Its output
{
"GroupId": "sg-903004f8"
}For more information, see Creating, configuring, and deleting Amazon EC2 security groups in the AWS CLI in the AWS Command Line Interface User Guide.
Options
--descriptionA description for the security group.--dry-runChecks whether you have the required permissions for the action, without actually making the request, and provides an error response.--group-nameThe name of the security group.--tag-specificationsThe tags to assign to the security group.--vpc-idThe ID of the VPC.