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

Authorizing Access

Example 765. Authorizing by IP

authorizeIp Adds permissions to a security group based on an IP address, protocol type and port range.

Permissions are specified by the IP protocol (TCP, UDP or ICMP), the source of the request (by IP range or an Amazon EC2 user-group pair), the source and destination port ranges (for TCP and UDP), and the ICMP codes and types (for ICMP). When authorizing ICMP, -1 can be used as a wildcard in the type and code fields.

Permission changes are propagated to instances within the security group as quickly as possible. However, depending on the number of instances, a small delay might occur.

authorizeIp returns boolean TRUE or FALSE

<?php
$ec2_sg 
= new Zend_Service_Amazon_Ec2_Securitygroups('aws_key',
                                                     
'aws_secret_key');
$return $ec2_sg->authorizeIp('mygroup',
                                
'protocol',
                                
'fromPort',
                                
'toPort',
                                
'ipRange');

Example 766. Authorize By Group

authorizeGroup Adds permissions to a security group.

Permission changes are propagated to instances within the security group as quickly as possible. However, depending on the number of instances, a small delay might occur.

authorizeGroup returns boolean TRUE or FALSE.

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

Zend Framework