PhpRiot
Become Zend Certified

Prepare for the ZCE exam using our quizzes (web or iPad/iPhone). More info...


When you're ready get 7.5% off your exam voucher using voucher CJQNOV23 at the Zend Store

Security Group Maintenance

Example 762. Create a new Security Group

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

create returns boolean TRUE or FALSE

<?php
$ec2_sg 
= new Zend_Service_Amazon_Ec2_Securitygroups('aws_key',
                                                     
'aws_secret_key');
$return $ec2_sg->create('mygroup''my group description');

Example 763. Describe a Security Group

describe returns information about security groups that you own.

If you specify security group names, information about those security groups is returned. Otherwise, information for all security groups is returned. If you specify a group that does not exist, a fault is returned.

describe will return an array containing information about security groups which includes the ownerId, groupName, groupDescription and an array containing all the rules for that security group.

<?php
$ec2_sg 
= new Zend_Service_Amazon_Ec2_Securitygroups('aws_key',
                                                     
'aws_secret_key');
$return $ec2_sg->describe('mygroup');

Example 764. Delete a Security Group

delete will remove the security group. If you attempt to delete a security group that contains instances, a fault is returned. If you attempt to delete a security group that is referenced by another security group, a fault 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 allow rule is removed.

delete returns boolean TRUE or FALSE.

<?php
$ec2_sg 
= new Zend_Service_Amazon_Ec2_Securitygroups('aws_key',
                                                     
'aws_secret_key');
$return $ec2_sg->delete('mygroup');

Zend Framework