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

AMI Attribute Utilities

Example 739. Modify Image Attributes

Modifies an attribute of an AMI

Table 150. Valid Attributes

Name Description
launchPermission

Controls who has permission to launch the AMI. Launch permissions can be granted to specific users by adding userIds.

To make the AMI public, add the all group.

productCodes

Associates a product code with AMIs. This allows developers to charge users for using AMIs. The user must be signed up for the product before they can launch the AMI. This is a write once attribute; after it is set, it cannot be changed or removed.


modifyAttribute returns boolean TRUE or FALSE.

<?php
$ec2_img 
= new Zend_Service_Amazon_Ec2_Image('aws_key','aws_secret_key');
// modify the launchPermission of an AMI
$return $ec2_img->modifyAttribute('imageId',
                                    
'launchPermission',
                                    
'add',
                                    
'userId',
                                    
'userGroup');

// set the product code of the AMI.
$return $ec2_img->modifyAttribute('imageId',
                                    
'productCodes',
                                    
'add',
                                    
null,
                                    
null,
                                    
'productCode');

Example 740. Reset an AMI Attribute

resetAttribute will reset the attribute of an AMI to its default value. The productCodes attribute cannot be reset.

<?php
$ec2_img 
= new Zend_Service_Amazon_Ec2_Image('aws_key','aws_secret_key');
$return $ec2_img->resetAttribute('imageId''launchPermission');

Example 741. Describe AMI Attribute

describeAttribute returns information about an attribute of an AMI. Only one attribute can be specified per call. Currently only launchPermission and productCodes are supported.

describeAttribute returns an array with the value of the attribute that was requested.

<?php
$ec2_img 
= new Zend_Service_Amazon_Ec2_Image('aws_key','aws_secret_key');
$return $ec2_img->describeAttribute('imageId''launchPermission');

Zend Framework