The CreateSecurityGroup operation creates a new security group.
Every instance is launched in a security group. If no security group is specified during launch, the instances are launched in the default security group. Instances within the same security group have unrestricted network access to each other. Instances will reject network access attempts from other instances in a different security group. As the owner of instances you can grant or revoke specific permissions using the AuthorizeSecurityGroupIngress and RevokeSecurityGroupIngress operations.
Access
public
Parameters
Parameter |
Type |
Required |
Description |
---|---|---|---|
|
Required |
Name of the security group. |
|
|
Required |
Description of the group. This is informational only. |
|
|
Optional |
An associative array of parameters that can have the following keys:
|
Returns
Type |
Description |
---|---|
A |
Examples
Create a new security group.
$ec2 = new AmazonEC2(); $response = $ec2->create_security_group('my-security-group', 'This is a test description.'); var_dump($response->isOK());Result:
bool(true)
Security groups only support US-ASCII characters.
The example below will fail with an error.
$ec2 = new AmazonEC2(); $response = $ec2->create_security_group('my-security-group', 'åéîøü¡™£¢∞§¶•ªº–≠'); var_dump($response->isOK());Result:
bool(false)
Create a new security group for a VPC.
$ec2 = new AmazonEC2(); $response = $ec2->create_security_group('my-vpc-security-group', 'This is a test VPC description', array( 'VpcId' => 'vpc-fd7cd194' )); var_dump($response->isOK());Result:
bool(true)
Related Methods
Source
Method defined in services/ec2.class.php | Toggle source view (8 lines) | View on GitHub