Associating a Product Code with an AMI
You must be the owner of an AMI to associate a product code with it. Each AMI can have only a single product code associated with it, but you can associate a single product code with more than one AMI. You might do this if you have similar versions of an AMI (for example, a 32-bit version and a 64-bit version), you've assigned them all the same price, and you'd like to minimize the number of Amazon DevPay product codes you have (to make your bookkeeping easier).
To associate a product code with an AMI
-
Enter the following command:
PROMPT>
ec2-modify-image-attribute
<ami_id>
--product-code<product_code>
The
<ami_id>
is the AMI ID and<product_code>
is the product code.
To verify the product code is associated with the AMI
-
Enter the following command:
PROMPT>
ec2-describe-image-attribute
<ami_id>
--product-code
You can't change or remove the productCodes
attribute after you've set it.
If you want to use the same image without the product code or associate a different product code
with the image, you must reregister the image to obtain a new AMI ID. You can then use that AMI
without a product code or associate the new product code with the AMI ID.
Example
The following example associates the ami-2bb65342 AMI with the 774F4FF8 product code.
PROMPT>
ec2-modify-image-attribute
ami-2bb65342
--product-code774F4FF8
productCodes ami-2bb65342 productCode 774F4FF8
This example verifies that the product code is associated with the AMI.
PROMPT>
ec2-describe-image-attribute
ami-2bb65342
--product-code productCodes ami-2bb65342 productCode 774F4FF8